Add WREN_DRY_RUN environment variable for safe testing
All checks were successful
Build and Push Docker Image / docker (push) Successful in 42s
All checks were successful
Build and Push Docker Image / docker (push) Successful in 42s
Prevent accidental creation of real carbon offsets during development: - Add WREN_DRY_RUN environment variable (default: true for dev) - Update webhook fulfillment to use env variable instead of hardcoded value - Log warning when in dry run mode for visibility - Production deployments should set WREN_DRY_RUN=false This allows safe testing with Stripe test cards without creating real Wren offset orders. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
06733cb2cb
commit
9e621042db
@ -4,6 +4,8 @@ STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here
|
|||||||
|
|
||||||
# Wren Climate API
|
# Wren Climate API
|
||||||
WREN_API_TOKEN=35c025d9-5dbb-404b-85aa-19b09da0578d
|
WREN_API_TOKEN=35c025d9-5dbb-404b-85aa-19b09da0578d
|
||||||
|
# Set to 'true' for testing (no real offsets created), 'false' for production
|
||||||
|
WREN_DRY_RUN=true
|
||||||
|
|
||||||
# Server Configuration
|
# Server Configuration
|
||||||
PORT=3001
|
PORT=3001
|
||||||
|
|||||||
@ -144,6 +144,13 @@ async function fulfillOrder(order, session) {
|
|||||||
try {
|
try {
|
||||||
console.log(`🌱 Fulfilling order ${order.id} via Wren API...`);
|
console.log(`🌱 Fulfilling order ${order.id} via Wren API...`);
|
||||||
|
|
||||||
|
// Determine if we should use dry run mode based on environment
|
||||||
|
const isDryRun = process.env.WREN_DRY_RUN === 'true';
|
||||||
|
|
||||||
|
if (isDryRun) {
|
||||||
|
console.log('⚠️ DRY RUN MODE: No real offset will be created');
|
||||||
|
}
|
||||||
|
|
||||||
// Create Wren offset order
|
// Create Wren offset order
|
||||||
const wrenOrder = await createWrenOffsetOrder({
|
const wrenOrder = await createWrenOffsetOrder({
|
||||||
tons: order.tons,
|
tons: order.tons,
|
||||||
@ -151,7 +158,7 @@ async function fulfillOrder(order, session) {
|
|||||||
customerEmail: session.customer_details?.email || order.customer_email,
|
customerEmail: session.customer_details?.email || order.customer_email,
|
||||||
currency: order.currency,
|
currency: order.currency,
|
||||||
amountCents: order.total_amount,
|
amountCents: order.total_amount,
|
||||||
dryRun: false, // Set to true for testing without creating real offsets
|
dryRun: isDryRun,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update order with Wren order ID
|
// Update order with Wren order ID
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user