Skip to content

Add shipping, base currency, and payment data to purchase events - #44

Merged
MikeVerlinde merged 1 commit into
masterfrom
claude/adpage-webhook-shipping-data-6svt6x
Aug 3, 2026
Merged

Add shipping, base currency, and payment data to purchase events#44
MikeVerlinde merged 1 commit into
masterfrom
claude/adpage-webhook-shipping-data-6svt6x

Conversation

@koenvdwetering

Copy link
Copy Markdown

Summary

Extends the purchase webhook event to include additional order data (shipping details, base currency values, and payment method) that AdPage uses to calculate actual profit metrics per order, including COGS, carrier rates, and payment fees.

Changes

  • PurchaseWebhookEvent.php: Added new ecommerce data fields to the purchase event payload:

    • Shipping information: shipping_method, shipping_method_code, shipping_excl_tax, base_shipping_excl_tax
    • Base currency values: base_value, base_tax, base_currency
    • Payment method: payment_type
    • All new fields are additive and preserve existing keys and values
    • Wrapped in try-catch with debug logging to handle potential data resolution failures gracefully
  • composer.json: Version bump from 1.6.0 to 1.7.0

Implementation Details

  • Uses the existing priceFormatter service to format monetary values consistently
  • Safely handles nullable order properties with null coalescing operators
  • Includes comprehensive error handling with debug logging for troubleshooting
  • Maintains backward compatibility by only adding new keys to the ecommerce data structure

https://claude.ai/code/session_01FtDTszbhPXRNU49GjSuiPD

AdPage calculates per-order profit (COGS, carrier rate, payment fees) from
the order_created payload. Two things were missing to do that exactly:

- the chosen shipping method, so the real carrier rate can be applied
- shipping/order totals excl. tax and in the store base currency, so
  multi-currency shops don't mix currencies in the profit calculation

Adds to ecommerce: shipping_method, shipping_method_code,
shipping_excl_tax, base_shipping_excl_tax, base_value, base_tax,
base_currency and payment_type.

Purely additive - shipping, value, tax, items, transaction_id and all
other existing keys keep their current name, meaning and value so live
tracking implementations are unaffected. Resolution is wrapped in a
try/catch so a failure here can never break the webhook.

Bumps the package version to 1.7.0 so the plugin_version in the payload
tells AdPage whether the new fields are available.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FtDTszbhPXRNU49GjSuiPD
@MikeVerlinde
MikeVerlinde merged commit ccf149a into master Aug 3, 2026
1 check passed
@MikeVerlinde
MikeVerlinde deleted the claude/adpage-webhook-shipping-data-6svt6x branch August 3, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants