diff --git a/server/routes/webhooks.js b/server/routes/webhooks.js index 3d67daf..0a6e877 100644 --- a/server/routes/webhooks.js +++ b/server/routes/webhooks.js @@ -231,8 +231,6 @@ async function fulfillOrder(order, session) { tons: order.tons, portfolioId: order.portfolio_id, customerEmail: session.customer_details?.email || order.customer_email, - currency: order.currency, - amountCents: order.total_amount, dryRun: isDryRun, }); diff --git a/server/utils/wrenClient.js b/server/utils/wrenClient.js index f1149e3..35c59ca 100644 --- a/server/utils/wrenClient.js +++ b/server/utils/wrenClient.js @@ -7,18 +7,14 @@ const WREN_API_BASE_URL = 'https://www.wren.co/api'; * @param {Object} orderData - Order data * @param {number} orderData.tons - Number of tons to offset * @param {number} orderData.portfolioId - Portfolio ID - * @param {string} orderData.customerEmail - Customer email - * @param {string} orderData.currency - Currency code - * @param {number} orderData.amountCents - Amount in cents + * @param {string} orderData.customerEmail - Customer email (included in note) * @param {boolean} orderData.dryRun - Dry run mode (default: false) - * @returns {Promise} Wren order response + * @returns {Promise} Wren order response with amountCharged, currency, portfolio, tons */ export async function createWrenOffsetOrder({ tons, portfolioId, customerEmail, - currency, - amountCents, dryRun = false }) { const startTime = Date.now(); @@ -32,10 +28,8 @@ export async function createWrenOffsetOrder({ console.log('🔵 [WREN API SERVER] Parameters:', JSON.stringify({ tons: parseFloat(tons), portfolioId, - customerEmail, - currency: currency.toUpperCase(), - amountCents, - dryRun + dryRun, + note: `Puffin App order - Customer: ${customerEmail}` }, null, 2)); if (!apiToken) { @@ -48,14 +42,9 @@ export async function createWrenOffsetOrder({ `${WREN_API_BASE_URL}/offset-orders`, { tons: parseFloat(tons), - portfolio: portfolioId, - currency: currency.toUpperCase(), - amount_charged: amountCents, - dry_run: dryRun, - source: { - name: 'Puffin App', - email: customerEmail - } + portfolioId: portfolioId, + dryRun: dryRun, + note: `Puffin App order - Customer: ${customerEmail}` }, { headers: {