@easypayment/medusa-payment-paypal 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +392 -138
- package/.medusa/server/src/admin/index.mjs +392 -138
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts +1 -0
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js +5 -1
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts +1 -0
- package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/disconnect/route.js +1 -0
- package/.medusa/server/src/api/admin/paypal/disconnect/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/environment/route.d.ts +2 -0
- package/.medusa/server/src/api/admin/paypal/environment/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/environment/route.js +2 -0
- package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts +9 -0
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js +9 -4
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts +7 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js +9 -2
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts +1 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +1 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts +1 -0
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.js +10 -3
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/settings/route.d.ts +2 -0
- package/.medusa/server/src/api/admin/paypal/settings/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/settings/route.js +9 -2
- package/.medusa/server/src/api/admin/paypal/settings/route.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/status/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/paypal/status/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/status/route.js +9 -1
- package/.medusa/server/src/api/admin/paypal/status/route.js.map +1 -1
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts +4 -0
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js +11 -1
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts +8 -0
- package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/capture-order/route.js +23 -3
- package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/config/route.d.ts +5 -0
- package/.medusa/server/src/api/store/paypal/config/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/config/route.js +12 -5
- package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts +8 -0
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/create-order/route.js +80 -26
- package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/onboard-return/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/onboard-return/route.js +19 -19
- package/.medusa/server/src/api/store/paypal/onboard-return/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/settings/route.d.ts +1 -0
- package/.medusa/server/src/api/store/paypal/settings/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/settings/route.js +4 -1
- package/.medusa/server/src/api/store/paypal/settings/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal/webhook/route.d.ts +7 -0
- package/.medusa/server/src/api/store/paypal/webhook/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/webhook/route.js +34 -3
- package/.medusa/server/src/api/store/paypal/webhook/route.js.map +1 -1
- package/.medusa/server/src/api/store/paypal-complete/route.d.ts +8 -0
- package/.medusa/server/src/api/store/paypal-complete/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal-complete/route.js +55 -8
- package/.medusa/server/src/api/store/paypal-complete/route.js.map +1 -1
- package/.medusa/server/src/api/utils/rate-limit.d.ts +4 -0
- package/.medusa/server/src/api/utils/rate-limit.d.ts.map +1 -1
- package/.medusa/server/src/api/utils/rate-limit.js +9 -4
- package/.medusa/server/src/api/utils/rate-limit.js.map +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts +5 -0
- package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts.map +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.js +13 -2
- package/.medusa/server/src/jobs/paypal-webhook-retry.js.map +1 -1
- package/.medusa/server/src/modules/paypal/index.d.ts +1 -0
- package/.medusa/server/src/modules/paypal/index.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/index.js +1 -0
- package/.medusa/server/src/modules/paypal/index.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.js +22 -22
- package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.js +11 -11
- package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.js +18 -18
- package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.js +16 -16
- package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.js +20 -20
- package/.medusa/server/src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.js +14 -14
- package/.medusa/server/src/modules/paypal/migrations/20261201090000_remove_paypal_audit_log.js +15 -15
- package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.js.map +1 -1
- package/.medusa/server/src/modules/paypal/migrations/20270201000000_add_webhook_dead_letter.js +6 -6
- package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts +5 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_connection.js +5 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.js.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts +4 -0
- package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_metric.js +4 -0
- package/.medusa/server/src/modules/paypal/models/paypal_metric.js.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_settings.d.ts +5 -0
- package/.medusa/server/src/modules/paypal/models/paypal_settings.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_settings.js +5 -0
- package/.medusa/server/src/modules/paypal/models/paypal_settings.js.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts +7 -0
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js +7 -0
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts +24 -1
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js +296 -0
- package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts +14 -7
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +40 -198
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/index.d.ts +6 -1
- package/.medusa/server/src/modules/paypal/payment-provider/index.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/index.js +6 -4
- package/.medusa/server/src/modules/paypal/payment-provider/index.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts +9 -2
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +29 -181
- package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/status-utils.d.ts +21 -0
- package/.medusa/server/src/modules/paypal/payment-provider/status-utils.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/status-utils.js +54 -0
- package/.medusa/server/src/modules/paypal/payment-provider/status-utils.js.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +72 -2
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +159 -33
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/types/config.d.ts +2 -0
- package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/types/config.js +5 -2
- package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/amounts.d.ts +1 -0
- package/.medusa/server/src/modules/paypal/utils/amounts.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/amounts.js +15 -5
- package/.medusa/server/src/modules/paypal/utils/amounts.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts +10 -0
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +45 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/currencies.d.ts +9 -0
- package/.medusa/server/src/modules/paypal/utils/currencies.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/currencies.js +13 -0
- package/.medusa/server/src/modules/paypal/utils/currencies.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/payment-session.d.ts +12 -0
- package/.medusa/server/src/modules/paypal/utils/payment-session.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/payment-session.js +4 -3
- package/.medusa/server/src/modules/paypal/utils/payment-session.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.d.ts +1 -0
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.js +1 -0
- package/.medusa/server/src/modules/paypal/utils/paypal-auth.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.d.ts +11 -0
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js +17 -1
- package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/provider-ids.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/utils/provider-ids.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/provider-ids.js +6 -0
- package/.medusa/server/src/modules/paypal/utils/provider-ids.js.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/secret-crypto.d.ts +2 -0
- package/.medusa/server/src/modules/paypal/utils/secret-crypto.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/secret-crypto.js +6 -1
- package/.medusa/server/src/modules/paypal/utils/secret-crypto.js.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +43 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.js +57 -5
- package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
- package/.medusa/server/src/providers/paypal/index.d.ts +1 -0
- package/.medusa/server/src/providers/paypal/index.d.ts.map +1 -1
- package/.medusa/server/src/providers/paypal/index.js +1 -0
- package/.medusa/server/src/providers/paypal/index.js.map +1 -1
- package/.medusa/server/src/providers/paypal_card/index.d.ts +1 -0
- package/.medusa/server/src/providers/paypal_card/index.d.ts.map +1 -1
- package/.medusa/server/src/providers/paypal_card/index.js +1 -0
- package/.medusa/server/src/providers/paypal_card/index.js.map +1 -1
- package/.medusa/server/src/subscribers/paypal-order-invoice.d.ts +6 -0
- package/.medusa/server/src/subscribers/paypal-order-invoice.d.ts.map +1 -1
- package/.medusa/server/src/subscribers/paypal-order-invoice.js +9 -1
- package/.medusa/server/src/subscribers/paypal-order-invoice.js.map +1 -1
- package/.medusa/server/src/subscribers/paypal-webhook-process.d.ts +1 -0
- package/.medusa/server/src/subscribers/paypal-webhook-process.d.ts.map +1 -1
- package/.medusa/server/src/subscribers/paypal-webhook-process.js +17 -4
- package/.medusa/server/src/subscribers/paypal-webhook-process.js.map +1 -1
- package/CHANGELOG.md +65 -0
- package/README.md +184 -184
- package/package.json +7 -4
- package/src/admin/index.ts +1 -1
- package/src/admin/routes/settings/paypal/_components/FieldRow.tsx +38 -29
- package/src/admin/routes/settings/paypal/_components/SectionCard.tsx +29 -26
- package/src/admin/routes/settings/paypal/_components/Tabs.tsx +49 -48
- package/src/admin/routes/settings/paypal/_components/Toast.tsx +63 -52
- package/src/admin/routes/settings/paypal/_utils/adminFetch.ts +52 -32
- package/src/admin/routes/settings/paypal/additional-settings/page.tsx +246 -139
- package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +208 -123
- package/src/admin/routes/settings/paypal/apple-pay/page.tsx +9 -5
- package/src/admin/routes/settings/paypal/connection/page.tsx +974 -908
- package/src/admin/routes/settings/paypal/google-pay/page.tsx +9 -5
- package/src/admin/routes/settings/paypal/page.tsx +14 -13
- package/src/admin/routes/settings/paypal/pay-later-messaging/page.tsx +9 -5
- package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +304 -273
- package/src/api/admin/payment-collections/[id]/payment-sessions/route.ts +48 -39
- package/src/api/admin/paypal/disconnect/route.ts +15 -14
- package/src/api/admin/paypal/environment/route.ts +34 -32
- package/src/api/admin/paypal/onboard-complete/route.ts +61 -50
- package/src/api/admin/paypal/onboarding-link/route.ts +91 -76
- package/src/api/admin/paypal/onboarding-status/route.ts +21 -20
- package/src/api/admin/paypal/save-credentials/route.ts +48 -37
- package/src/api/admin/paypal/settings/route.ts +63 -45
- package/src/api/admin/paypal/status/route.ts +29 -17
- package/src/api/hooks/paypal/onboard-return/route.ts +15 -15
- package/src/api/hooks/paypal/webhook/route.ts +17 -17
- package/src/api/middlewares.ts +61 -61
- package/src/api/store/payment-collections/[id]/payment-sessions/route.ts +69 -54
- package/src/api/store/paypal/capture-order/route.ts +416 -370
- package/src/api/store/paypal/config/route.ts +121 -115
- package/src/api/store/paypal/create-order/route.ts +611 -539
- package/src/api/store/paypal/onboard-return/route.ts +116 -113
- package/src/api/store/paypal/settings/route.ts +29 -19
- package/src/api/store/paypal/webhook/route.ts +380 -314
- package/src/api/store/paypal-complete/route.ts +184 -128
- package/src/api/utils/rate-limit.ts +143 -129
- package/src/index.ts +1 -1
- package/src/jobs/paypal-webhook-retry.ts +257 -241
- package/src/modules/paypal/index.ts +9 -8
- package/src/modules/paypal/migrations/20260115120000_create_paypal_connection.ts +33 -33
- package/src/modules/paypal/migrations/20260123090000_create_paypal_settings.ts +22 -22
- package/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.ts +29 -29
- package/src/modules/paypal/migrations/20260401090000_create_paypal_metric.ts +27 -27
- package/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.ts +31 -31
- package/src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.ts +25 -25
- package/src/modules/paypal/migrations/20261201090000_remove_paypal_audit_log.ts +26 -26
- package/src/modules/paypal/migrations/20270101090000_set_paypal_environment_default_live.ts +15 -11
- package/src/modules/paypal/migrations/20270102090000_add_paypal_seller_email.ts +15 -11
- package/src/modules/paypal/migrations/20270103090000_add_paypal_seller_merchant_id.ts +15 -11
- package/src/modules/paypal/migrations/20270201000000_add_webhook_dead_letter.ts +17 -17
- package/src/modules/paypal/migrations/20270202000000_align_nullable_defaults.ts +44 -44
- package/src/modules/paypal/migrations/20270301000000_add_webhook_transmission_id_index.ts +15 -15
- package/src/modules/paypal/models/paypal_connection.ts +28 -23
- package/src/modules/paypal/models/paypal_metric.ts +13 -9
- package/src/modules/paypal/models/paypal_settings.ts +13 -8
- package/src/modules/paypal/models/paypal_webhook_event.ts +26 -19
- package/src/modules/paypal/payment-provider/base-provider.ts +700 -275
- package/src/modules/paypal/payment-provider/card-service.ts +693 -855
- package/src/modules/paypal/payment-provider/index.ts +14 -15
- package/src/modules/paypal/payment-provider/service.ts +673 -836
- package/src/modules/paypal/payment-provider/status-utils.ts +116 -59
- package/src/modules/paypal/payment-provider/webhook-utils.ts +109 -109
- package/src/modules/paypal/service.ts +362 -115
- package/src/modules/paypal/types/config.ts +70 -65
- package/src/modules/paypal/utils/amounts.ts +123 -107
- package/src/modules/paypal/utils/core-workflow.ts +46 -46
- package/src/modules/paypal/utils/credential-resolver.ts +315 -271
- package/src/modules/paypal/utils/currencies.ts +97 -84
- package/src/modules/paypal/utils/partner.ts +8 -8
- package/src/modules/paypal/utils/payment-session.ts +144 -138
- package/src/modules/paypal/utils/paypal-auth.ts +6 -5
- package/src/modules/paypal/utils/paypal-fetch.ts +197 -181
- package/src/modules/paypal/utils/provider-ids.ts +21 -15
- package/src/modules/paypal/utils/secret-crypto.ts +226 -197
- package/src/modules/paypal/utils/webhook-verify.ts +61 -61
- package/src/modules/paypal/webhook-processor.ts +641 -573
- package/src/providers/paypal/index.ts +9 -8
- package/src/providers/paypal_card/index.ts +9 -8
- package/src/subscribers/paypal-order-invoice.ts +180 -173
- package/src/subscribers/paypal-webhook-process.ts +147 -131
- package/tsconfig.json +21 -31
|
@@ -6,10 +6,12 @@ const paypal_fetch_1 = require("../../../../modules/paypal/utils/paypal-fetch");
|
|
|
6
6
|
const webhook_processor_1 = require("../../../../modules/paypal/webhook-processor");
|
|
7
7
|
const paypal_webhook_process_1 = require("../../../../subscribers/paypal-webhook-process");
|
|
8
8
|
const webhook_verify_1 = require("../../../../modules/paypal/utils/webhook-verify");
|
|
9
|
+
/** Deliveries whose transmission time is older than this are rejected as replays. */
|
|
9
10
|
const REPLAY_WINDOW_MINUTES = (() => {
|
|
10
11
|
const v = Number(process.env.PAYPAL_WEBHOOK_REPLAY_WINDOW_MINUTES);
|
|
11
12
|
return Number.isFinite(v) && v > 0 ? v : 60;
|
|
12
13
|
})();
|
|
14
|
+
/** Case-insensitive single-value header lookup. */
|
|
13
15
|
function getHeader(headers, name) {
|
|
14
16
|
const direct = headers[name];
|
|
15
17
|
if (Array.isArray(direct))
|
|
@@ -23,12 +25,20 @@ function getHeader(headers, name) {
|
|
|
23
25
|
const val = headers[key];
|
|
24
26
|
return Array.isArray(val) ? val[0] : val;
|
|
25
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Structural checks that run before any DB or PayPal call: required fields,
|
|
30
|
+
* a parseable `paypal-transmission-time`, and the replay window.
|
|
31
|
+
*/
|
|
26
32
|
function validateRequest(req) {
|
|
27
33
|
const payload = (req.body || {});
|
|
28
34
|
const eventId = String(payload?.id || payload?.event_id || "").trim();
|
|
29
35
|
const eventType = String(payload?.event_type || payload?.eventType || "").trim();
|
|
30
36
|
if (!eventId || !eventType) {
|
|
31
|
-
return {
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
status: 400,
|
|
40
|
+
message: "Missing required fields: id and event_type",
|
|
41
|
+
};
|
|
32
42
|
}
|
|
33
43
|
const transmissionTimeHeader = getHeader(req.headers, "paypal-transmission-time");
|
|
34
44
|
if (!transmissionTimeHeader) {
|
|
@@ -62,6 +72,10 @@ function validateRequest(req) {
|
|
|
62
72
|
transmissionTime: new Date(transmissionMs),
|
|
63
73
|
};
|
|
64
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* The registered webhook id for an environment: admin settings first
|
|
77
|
+
* (`api_details.webhook_ids`), then the `PAYPAL_WEBHOOK_ID_*` env override.
|
|
78
|
+
*/
|
|
65
79
|
function resolveWebhookId(environment, settings) {
|
|
66
80
|
const ids = (settings?.webhook_ids || {});
|
|
67
81
|
if (environment === "live") {
|
|
@@ -73,6 +87,11 @@ function resolveWebhookId(environment, settings) {
|
|
|
73
87
|
settings?.webhook_id_sandbox ||
|
|
74
88
|
process.env.PAYPAL_WEBHOOK_ID_SANDBOX);
|
|
75
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Verify the delivery with PayPal's `verify-webhook-signature` API. Throws
|
|
92
|
+
* unless PayPal answers `VERIFIED`; also rejects a `paypal-cert-url` that
|
|
93
|
+
* does not point at paypal.com before making the call.
|
|
94
|
+
*/
|
|
76
95
|
async function verifyWebhookSignature(paypal, environment, body, headers, rawBody) {
|
|
77
96
|
const settings = await paypal.getSettings().catch(() => ({ data: {} }));
|
|
78
97
|
const webhookId = resolveWebhookId(environment, settings?.data || {});
|
|
@@ -127,6 +146,13 @@ async function verifyWebhookSignature(paypal, environment, body, headers, rawBod
|
|
|
127
146
|
(debugId ? ` debug_id=${debugId}` : ""));
|
|
128
147
|
}
|
|
129
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* POST /store/paypal/webhook (also mounted at /hooks/paypal/webhook).
|
|
151
|
+
*
|
|
152
|
+
* Validate → dedupe by transmission id → verify signature → persist as
|
|
153
|
+
* "processing" → dedupe by event id → hand off to the async subscriber and
|
|
154
|
+
* acknowledge immediately. All heavy work happens off the request path.
|
|
155
|
+
*/
|
|
130
156
|
async function POST(req, res) {
|
|
131
157
|
const paypal = req.scope.resolve("paypal_onboarding");
|
|
132
158
|
const validation = validateRequest(req);
|
|
@@ -176,7 +202,10 @@ async function POST(req, res) {
|
|
|
176
202
|
attempt_count: 1,
|
|
177
203
|
});
|
|
178
204
|
if (!recordResult.created) {
|
|
179
|
-
console.info("[PayPal] webhook: duplicate event_id", {
|
|
205
|
+
console.info("[PayPal] webhook: duplicate event_id", {
|
|
206
|
+
eventId,
|
|
207
|
+
eventType,
|
|
208
|
+
});
|
|
180
209
|
return res.json({ ok: true, duplicate: true });
|
|
181
210
|
}
|
|
182
211
|
recordId = recordResult.event?.id ?? null;
|
|
@@ -186,7 +215,9 @@ async function POST(req, res) {
|
|
|
186
215
|
return res.status(500).json({ message: "Failed to record webhook event" });
|
|
187
216
|
}
|
|
188
217
|
if (!(0, webhook_processor_1.isAllowedEventType)(eventType)) {
|
|
189
|
-
console.info("[PayPal] webhook: unsupported event type, ignoring", {
|
|
218
|
+
console.info("[PayPal] webhook: unsupported event type, ignoring", {
|
|
219
|
+
eventType,
|
|
220
|
+
});
|
|
190
221
|
await paypal.recordAuditEvent("webhook_unsupported_event", {
|
|
191
222
|
event_id: eventId,
|
|
192
223
|
event_type: eventType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/webhook/route.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/webhook/route.ts"],"names":[],"mappings":";;AA+OA,oBA4IC;AA1XD,qDAAmD;AAGnD,gFAA2E;AAC3E,oFAGqD;AACrD,2FAA8F;AAC9F,oFAIwD;AAExD,qFAAqF;AACrF,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE;IAClC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;IAClE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC7C,CAAC,CAAC,EAAE,CAAA;AAEJ,mDAAmD;AACnD,SAAS,SAAS,CAChB,OAAsD,EACtD,IAAY;IAEZ,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;IAC3C,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAA;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAA;IACvE,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAA;IAC1B,MAAM,GAAG,GAAG,OAAO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C,CAAA;IACJ,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,6EAA6E;QAC7E,6EAA6E;QAC7E,mDAAmD;QACnD,OAAO,CAAC,KAAK,CACX,gFAAgF,EAChF;YACE,QAAQ,EAAE,OAAO;YACjB,UAAU,EAAE,SAAS;YACrB,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,CAAC,EAAE,OAAO;SAClB,CACF,CAAA;IACH,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;AAC/C,CAAC"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
|
|
2
|
+
/**
|
|
3
|
+
* POST /store/paypal-complete — finalize a cart after the buyer's PayPal
|
|
4
|
+
* payment was captured/authorized.
|
|
5
|
+
*
|
|
6
|
+
* Authorizes the PayPal payment session (which re-verifies the payment against
|
|
7
|
+
* PayPal) and then runs the core complete-cart workflow. A cart completed by a
|
|
8
|
+
* concurrent request (e.g. the webhook safety net) is reported as success.
|
|
9
|
+
*/
|
|
2
10
|
export declare function POST(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
|
|
3
11
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/store/paypal-complete/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/store/paypal-complete/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAW7E;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAoKjE"}
|
|
@@ -5,6 +5,14 @@ const utils_1 = require("@medusajs/framework/utils");
|
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const provider_ids_1 = require("../../../modules/paypal/utils/provider-ids");
|
|
7
7
|
const core_workflow_1 = require("../../../modules/paypal/utils/core-workflow");
|
|
8
|
+
/**
|
|
9
|
+
* POST /store/paypal-complete — finalize a cart after the buyer's PayPal
|
|
10
|
+
* payment was captured/authorized.
|
|
11
|
+
*
|
|
12
|
+
* Authorizes the PayPal payment session (which re-verifies the payment against
|
|
13
|
+
* PayPal) and then runs the core complete-cart workflow. A cart completed by a
|
|
14
|
+
* concurrent request (e.g. the webhook safety net) is reported as success.
|
|
15
|
+
*/
|
|
8
16
|
async function POST(req, res) {
|
|
9
17
|
const logger = req.scope.resolve(utils_1.ContainerRegistrationKeys.LOGGER);
|
|
10
18
|
const requestId = (0, crypto_1.randomUUID)();
|
|
@@ -39,9 +47,12 @@ async function POST(req, res) {
|
|
|
39
47
|
const sessions = cart?.payment_collection?.payment_sessions || [];
|
|
40
48
|
const session = sessions
|
|
41
49
|
.filter((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id))
|
|
42
|
-
.sort((a, b) => new Date(b.created_at || 0).getTime() -
|
|
50
|
+
.sort((a, b) => new Date(b.created_at || 0).getTime() -
|
|
51
|
+
new Date(a.created_at || 0).getTime())[0];
|
|
43
52
|
if (!session) {
|
|
44
|
-
return res
|
|
53
|
+
return res
|
|
54
|
+
.status(400)
|
|
55
|
+
.json({ message: "No PayPal payment session found for cart" });
|
|
45
56
|
}
|
|
46
57
|
const paymentModule = req.scope.resolve(utils_1.Modules.PAYMENT);
|
|
47
58
|
// Do NOT fabricate captured_at/authorized_at here. The authoritative
|
|
@@ -56,24 +67,58 @@ async function POST(req, res) {
|
|
|
56
67
|
logger.info(`[paypal] paypal-complete authorizePaymentSession succeeded (request_id=${requestId}, session_id=${session.id})`);
|
|
57
68
|
}
|
|
58
69
|
catch (e) {
|
|
59
|
-
// Authorization is the gate for completion; if it fails, the
|
|
60
|
-
// completeCartWorkflow below fails too and we report that honestly.
|
|
61
70
|
logger.warn(`[paypal] paypal-complete authorizePaymentSession failed (request_id=${requestId}, session_id=${session.id}): ${e?.message ?? String(e)}`);
|
|
71
|
+
// The providers throw NOT_ALLOWED when PayPal has no approved /
|
|
72
|
+
// captured payment for the session (buyer never approved, capture
|
|
73
|
+
// declined, …). Nothing was charged, so say so — the generic
|
|
74
|
+
// "payment was processed but the order could not be finalized" below
|
|
75
|
+
// would tell a storefront to show "do not pay again" for a payment
|
|
76
|
+
// that never happened. Anything else (transient DB/PayPal errors) is
|
|
77
|
+
// still allowed to fall through to the completion attempt and its
|
|
78
|
+
// retryable 5xx. Checked via the `__isMedusaError` flag, not
|
|
79
|
+
// `instanceof`: the provider runs inside the payment module's own
|
|
80
|
+
// loader and its MedusaError is a different class instance than ours.
|
|
81
|
+
if (utils_1.MedusaError.isMedusaError(e) &&
|
|
82
|
+
e.type === utils_1.MedusaError.Types.NOT_ALLOWED) {
|
|
83
|
+
return res.status(402).json({
|
|
84
|
+
success: false,
|
|
85
|
+
cart_id,
|
|
86
|
+
session_id: session.id,
|
|
87
|
+
payment_authorized: false,
|
|
88
|
+
message: e.message ||
|
|
89
|
+
"The PayPal payment for this cart has not been approved.",
|
|
90
|
+
request_id: requestId,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
62
93
|
}
|
|
63
94
|
}
|
|
64
95
|
try {
|
|
65
96
|
const { result } = await (0, core_workflow_1.runCoreWorkflow)(req.scope, "complete-cart", { id: cart_id });
|
|
66
97
|
logger.info(`[paypal] paypal-complete cart completed (request_id=${requestId}, cart_id=${cart_id}, order_id=${result?.id})`);
|
|
67
|
-
return res.json({
|
|
98
|
+
return res.json({
|
|
99
|
+
success: true,
|
|
100
|
+
cart_id,
|
|
101
|
+
order_id: result?.id,
|
|
102
|
+
request_id: requestId,
|
|
103
|
+
});
|
|
68
104
|
}
|
|
69
105
|
catch (e) {
|
|
70
106
|
// The cart may have been completed by a concurrent request between our
|
|
71
107
|
// initial check and now — treat that as success, not an error.
|
|
72
108
|
const recheck = await query
|
|
73
|
-
.graph({
|
|
109
|
+
.graph({
|
|
110
|
+
entity: "cart",
|
|
111
|
+
fields: ["id", "completed_at"],
|
|
112
|
+
filters: { id: cart_id },
|
|
113
|
+
})
|
|
74
114
|
.catch(() => ({ data: [] }));
|
|
75
115
|
if (recheck?.data?.[0]?.completed_at) {
|
|
76
|
-
return res.json({
|
|
116
|
+
return res.json({
|
|
117
|
+
success: true,
|
|
118
|
+
cart_id,
|
|
119
|
+
already_completed: true,
|
|
120
|
+
request_id: requestId,
|
|
121
|
+
});
|
|
77
122
|
}
|
|
78
123
|
logger.error(`[paypal] paypal-complete completeCartWorkflow failed (request_id=${requestId}, cart_id=${cart_id}): ${e?.message ?? String(e)}`, e instanceof Error ? e : undefined);
|
|
79
124
|
// The payment may have been captured at PayPal but the order was not
|
|
@@ -90,7 +135,9 @@ async function POST(req, res) {
|
|
|
90
135
|
}
|
|
91
136
|
catch (e) {
|
|
92
137
|
logger.error(`[paypal] paypal-complete failed (request_id=${requestId}, cart_id=${cart_id}): ${e?.message ?? String(e)}`, e instanceof Error ? e : undefined);
|
|
93
|
-
return res
|
|
138
|
+
return res
|
|
139
|
+
.status(500)
|
|
140
|
+
.json({ message: "Internal error", request_id: requestId });
|
|
94
141
|
}
|
|
95
142
|
}
|
|
96
143
|
//# sourceMappingURL=route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../src/api/store/paypal-complete/route.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../src/api/store/paypal-complete/route.ts"],"names":[],"mappings":";;AAmBA,oBAoKC;AArLD,qDAIkC;AAClC,mCAAmC;AACnC,6EAA+E;AAC/E,+EAA6E;AAE7E;;;;;;;GAOG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AE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC"}
|
|
@@ -11,5 +11,9 @@ export type RateLimiterOptions = {
|
|
|
11
11
|
/** Env var for the window; defaults to PAYPAL_RATE_LIMIT_WINDOW_MS. */
|
|
12
12
|
windowEnvVar?: string;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Build a fixed-window rate-limit middleware with its own bucket map. `scope`
|
|
16
|
+
* namespaces the buckets so limiters on different routes never share counts.
|
|
17
|
+
*/
|
|
14
18
|
export declare function createRateLimiter(scope: string, options?: RateLimiterOptions): (req: MedusaRequest, res: MedusaResponse, next: MedusaNextFunction) => void | MedusaResponse;
|
|
15
19
|
//# sourceMappingURL=rate-limit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/rate-limit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/rate-limit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACf,MAAM,0BAA0B,CAAA;AAgEjC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,kBAAuB,IAO9B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,MAAM,kBAAkB,2BA8C3B"}
|
|
@@ -48,13 +48,18 @@ function clientKey(req) {
|
|
|
48
48
|
const fwd = req.headers["x-forwarded-for"];
|
|
49
49
|
const fwdRaw = Array.isArray(fwd) ? fwd[fwd.length - 1] : fwd;
|
|
50
50
|
const parts = fwdRaw
|
|
51
|
-
? fwdRaw
|
|
51
|
+
? fwdRaw
|
|
52
|
+
.split(",")
|
|
53
|
+
.map((s) => s.trim())
|
|
54
|
+
.filter(Boolean)
|
|
52
55
|
: [];
|
|
53
|
-
const ip = parts[parts.length - 1] ||
|
|
54
|
-
req.socket?.remoteAddress ||
|
|
55
|
-
"unknown";
|
|
56
|
+
const ip = parts[parts.length - 1] || req.socket?.remoteAddress || "unknown";
|
|
56
57
|
return ip;
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Build a fixed-window rate-limit middleware with its own bucket map. `scope`
|
|
61
|
+
* namespaces the buckets so limiters on different routes never share counts.
|
|
62
|
+
*/
|
|
58
63
|
function createRateLimiter(scope, options = {}) {
|
|
59
64
|
const buckets = new Map();
|
|
60
65
|
const maxEnvVar = options.maxEnvVar || "PAYPAL_RATE_LIMIT_MAX";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../../../../src/api/utils/rate-limit.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../../../../src/api/utils/rate-limit.ts"],"names":[],"mappings":";;AAqFA,8CAyDC;AAxID;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAEhC,2EAA2E;AAC3E,8EAA8E;AAC9E,8DAA8D;AAC9D,MAAM,WAAW,GAAG,MAAM,CAAA;AAI1B,SAAS,UAAU,CAAC,IAAY,EAAE,QAAgB;IAChD,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;AACnD,CAAC;AAED,2EAA2E;AA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,WAAW,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;gBAC1C,IAAI,MAAM,KAAK,SAAS;oBAAE,MAAK;gBAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC;YACvB,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAC5B,CAAC,EACD,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CACzC,CAAA;YACD,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC,CAAA;YACnD,OAAO,GAAG;iBACP,MAAM,CAAC,GAAG,CAAC;iBACX,IAAI,CAAC,EAAE,OAAO,EAAE,oDAAoD,EAAE,CAAC,CAAA;QAC5E,CAAC;QAED,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { MedusaContainer } from "@medusajs/framework/types";
|
|
2
|
+
/**
|
|
3
|
+
* Scheduled job: re-process failed webhook events whose backoff has elapsed
|
|
4
|
+
* and recover events stuck in "processing". Events that exhaust
|
|
5
|
+
* `MAX_WEBHOOK_ATTEMPTS` (or fail non-retryably) are dead-lettered.
|
|
6
|
+
*/
|
|
2
7
|
export default function paypalWebhookRetry(container: MedusaContainer): Promise<void>;
|
|
3
8
|
export declare const config: {
|
|
4
9
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-webhook-retry.d.ts","sourceRoot":"","sources":["../../../../src/jobs/paypal-webhook-retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AA6BhE,wBAA8B,kBAAkB,CAAC,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"paypal-webhook-retry.d.ts","sourceRoot":"","sources":["../../../../src/jobs/paypal-webhook-retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AA6BhE;;;;GAIG;AACH,wBAA8B,kBAAkB,CAAC,SAAS,EAAE,eAAe,iBAwC1E;AAmLD,eAAO,MAAM,MAAM;;;CAGlB,CAAA"}
|
|
@@ -19,6 +19,11 @@ const STALE_PROCESSING_MS = (() => {
|
|
|
19
19
|
// instances. pg_try_advisory_xact_lock auto-releases at transaction end, so
|
|
20
20
|
// there is no unlock to pair (and no risk of a leaked lock).
|
|
21
21
|
const RETRY_ADVISORY_LOCK_KEY = 838907812;
|
|
22
|
+
/**
|
|
23
|
+
* Scheduled job: re-process failed webhook events whose backoff has elapsed
|
|
24
|
+
* and recover events stuck in "processing". Events that exhaust
|
|
25
|
+
* `MAX_WEBHOOK_ATTEMPTS` (or fail non-retryably) are dead-lettered.
|
|
26
|
+
*/
|
|
22
27
|
async function paypalWebhookRetry(container) {
|
|
23
28
|
// Run the sweep under a Postgres advisory lock so that with multiple server
|
|
24
29
|
// instances running this cron, only one drains the queue per cycle (each
|
|
@@ -127,13 +132,19 @@ async function attemptRetry(paypal, container, event) {
|
|
|
127
132
|
}
|
|
128
133
|
try {
|
|
129
134
|
const payload = (event.payload || {});
|
|
130
|
-
const processed = await (0, webhook_processor_1.processPayPalWebhookEvent)(container, {
|
|
135
|
+
const processed = await (0, webhook_processor_1.processPayPalWebhookEvent)(container, {
|
|
136
|
+
eventType,
|
|
137
|
+
payload,
|
|
138
|
+
});
|
|
131
139
|
await paypal
|
|
132
140
|
.updateWebhookEventRecord({
|
|
133
141
|
id: event.id,
|
|
134
142
|
status: "processed",
|
|
135
143
|
processed_at: new Date(),
|
|
136
|
-
resource_id: processed.refundId ||
|
|
144
|
+
resource_id: processed.refundId ||
|
|
145
|
+
processed.captureId ||
|
|
146
|
+
processed.orderId ||
|
|
147
|
+
null,
|
|
137
148
|
})
|
|
138
149
|
.catch(() => { });
|
|
139
150
|
console.info("[PayPal] webhook-retry: processed successfully", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-webhook-retry.js","sourceRoot":"","sources":["../../../../src/jobs/paypal-webhook-retry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"paypal-webhook-retry.js","sourceRoot":"","sources":["../../../../src/jobs/paypal-webhook-retry.ts"],"names":[],"mappings":";;;AAkCA,qCAwCC;AAzED,qDAAqE;AAErE,2EAM4C;AAE5C,wEAAwE;AACxE,iCAAiC;AACjC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAC9E,0EAA0E;AAC1E,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE;IAChC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;IAChE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;AACxD,CAAC,CAAC,EAAE,CAAA;AAEJ,6EAA6E;AAC7E,4EAA4E;AAC5E,6DAA6D;AAC7D,MAAM,uBAAuB,GAAG,SAAS,CAAA;AAEzC;;;;GAIG;AACY,KAAK,UAAU,kBAAkB,CAAC,SAA0B;IACzE,4EAA4E;IAC5E,yEAAyE;IACzE,0EAA0E;IAC1E,yEAAyE;IACzE,iBAAiB;IACjB,IAAI,EAAE,GAAQ,IAAI,CAAA;IAClB,IAAI,CAAC;QACH,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,iCAAyB,CAAC,aAAa,CAAC,CAAA;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,EAAE,GAAG,IAAI,C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1B,aAAa,EAAE,SAAS;gBACxB,UAAU,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC;aAC5C,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YAClB,OAAO,CAAC,IAAI,CAAC,yCAAyC,EAAE;gBACtD,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,UAAU,EAAE,SAAS;gBACrB,OAAO,EAAE,WAAW;gBACpB,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE;gBACvC,KAAK,EAAE,KAAK,EAAE,OAAO;aACtB,CAAC,CAAA;YACF,MAAM,MAAM,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;AACH,CAAC;AAEY,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,cAAc;CACzB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PayPalModuleService from "./service";
|
|
2
|
+
/** Container registration key for the module service. */
|
|
2
3
|
export declare const PAYPAL_MODULE = "paypal_onboarding";
|
|
3
4
|
declare const _default: import("@medusajs/types").ModuleExports<typeof PayPalModuleService> & {
|
|
4
5
|
linkable: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/paypal/index.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,WAAW,CAAA;AAE3C,eAAO,MAAM,aAAa,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhD,wBAEE"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/paypal/index.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,WAAW,CAAA;AAE3C,yDAAyD;AACzD,eAAO,MAAM,aAAa,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhD,wBAEE"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PAYPAL_MODULE = void 0;
|
|
7
7
|
const utils_1 = require("@medusajs/framework/utils");
|
|
8
8
|
const service_1 = __importDefault(require("./service"));
|
|
9
|
+
/** Container registration key for the module service. */
|
|
9
10
|
exports.PAYPAL_MODULE = "paypal_onboarding";
|
|
10
11
|
exports.default = (0, utils_1.Module)(exports.PAYPAL_MODULE, {
|
|
11
12
|
service: service_1.default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/paypal/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkD;AAClD,wDAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/paypal/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkD;AAClD,wDAA2C;AAE3C,yDAAyD;AAC5C,QAAA,aAAa,GAAG,mBAAmB,CAAA;AAEhD,kBAAe,IAAA,cAAM,EAAC,qBAAa,EAAE;IACnC,OAAO,EAAE,iBAAmB;CAC7B,CAAC,CAAA"}
|
package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.js
CHANGED
|
@@ -4,31 +4,31 @@ exports.Migration20260115120000 = void 0;
|
|
|
4
4
|
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20260115120000 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
|
-
this.addSql(`
|
|
8
|
-
CREATE TABLE IF NOT EXISTS "paypal_connection" (
|
|
9
|
-
"id" text NOT NULL,
|
|
10
|
-
"environment" text NOT NULL DEFAULT 'sandbox',
|
|
11
|
-
"status" text NOT NULL DEFAULT 'disconnected',
|
|
12
|
-
"shared_id" text NULL,
|
|
13
|
-
"auth_code" text NULL,
|
|
14
|
-
"seller_client_id" text NULL,
|
|
15
|
-
"seller_client_secret" text NULL,
|
|
16
|
-
"app_access_token" text NULL,
|
|
17
|
-
"app_access_token_expires_at" timestamptz NULL,
|
|
18
|
-
"metadata" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
19
|
-
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
20
|
-
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
21
|
-
"deleted_at" timestamptz NULL,
|
|
22
|
-
CONSTRAINT "paypal_connection_pkey" PRIMARY KEY ("id")
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
CREATE INDEX IF NOT EXISTS "idx_paypal_connection_deleted_at"
|
|
26
|
-
ON "paypal_connection" ("deleted_at");
|
|
7
|
+
this.addSql(`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS "paypal_connection" (
|
|
9
|
+
"id" text NOT NULL,
|
|
10
|
+
"environment" text NOT NULL DEFAULT 'sandbox',
|
|
11
|
+
"status" text NOT NULL DEFAULT 'disconnected',
|
|
12
|
+
"shared_id" text NULL,
|
|
13
|
+
"auth_code" text NULL,
|
|
14
|
+
"seller_client_id" text NULL,
|
|
15
|
+
"seller_client_secret" text NULL,
|
|
16
|
+
"app_access_token" text NULL,
|
|
17
|
+
"app_access_token_expires_at" timestamptz NULL,
|
|
18
|
+
"metadata" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
19
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
20
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
21
|
+
"deleted_at" timestamptz NULL,
|
|
22
|
+
CONSTRAINT "paypal_connection_pkey" PRIMARY KEY ("id")
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
CREATE INDEX IF NOT EXISTS "idx_paypal_connection_deleted_at"
|
|
26
|
+
ON "paypal_connection" ("deleted_at");
|
|
27
27
|
`);
|
|
28
28
|
}
|
|
29
29
|
async down() {
|
|
30
|
-
this.addSql(`
|
|
31
|
-
DROP TABLE IF EXISTS "paypal_connection" CASCADE;
|
|
30
|
+
this.addSql(`
|
|
31
|
+
DROP TABLE IF EXISTS "paypal_connection" CASCADE;
|
|
32
32
|
`);
|
|
33
33
|
}
|
|
34
34
|
}
|
package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.js
CHANGED
|
@@ -4,17 +4,17 @@ exports.Migration20260123090000 = void 0;
|
|
|
4
4
|
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20260123090000 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
|
-
this.addSql(`
|
|
8
|
-
CREATE TABLE IF NOT EXISTS "paypal_settings" (
|
|
9
|
-
"id" text NOT NULL,
|
|
10
|
-
"data" jsonb NULL,
|
|
11
|
-
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
12
|
-
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
13
|
-
"deleted_at" timestamptz NULL,
|
|
14
|
-
CONSTRAINT "paypal_settings_pkey" PRIMARY KEY ("id")
|
|
15
|
-
);
|
|
16
|
-
CREATE INDEX IF NOT EXISTS "idx_paypal_settings_deleted_at"
|
|
17
|
-
ON "paypal_settings" ("deleted_at");
|
|
7
|
+
this.addSql(`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS "paypal_settings" (
|
|
9
|
+
"id" text NOT NULL,
|
|
10
|
+
"data" jsonb NULL,
|
|
11
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
12
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
13
|
+
"deleted_at" timestamptz NULL,
|
|
14
|
+
CONSTRAINT "paypal_settings_pkey" PRIMARY KEY ("id")
|
|
15
|
+
);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS "idx_paypal_settings_deleted_at"
|
|
17
|
+
ON "paypal_settings" ("deleted_at");
|
|
18
18
|
`);
|
|
19
19
|
}
|
|
20
20
|
async down() {
|
package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.js
CHANGED
|
@@ -4,27 +4,27 @@ exports.Migration20260201090000 = void 0;
|
|
|
4
4
|
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20260201090000 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
|
-
this.addSql(`
|
|
8
|
-
CREATE TABLE IF NOT EXISTS "paypal_webhook_event" (
|
|
9
|
-
"id" text NOT NULL,
|
|
10
|
-
"event_id" text NOT NULL,
|
|
11
|
-
"event_type" text NOT NULL,
|
|
12
|
-
"resource_id" text NULL,
|
|
13
|
-
"payload" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
14
|
-
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
15
|
-
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
16
|
-
"deleted_at" timestamptz NULL,
|
|
17
|
-
CONSTRAINT "paypal_webhook_event_pkey" PRIMARY KEY ("id"),
|
|
18
|
-
CONSTRAINT "paypal_webhook_event_event_id_unique" UNIQUE ("event_id")
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
CREATE INDEX IF NOT EXISTS "idx_paypal_webhook_event_deleted_at"
|
|
22
|
-
ON "paypal_webhook_event" ("deleted_at");
|
|
7
|
+
this.addSql(`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS "paypal_webhook_event" (
|
|
9
|
+
"id" text NOT NULL,
|
|
10
|
+
"event_id" text NOT NULL,
|
|
11
|
+
"event_type" text NOT NULL,
|
|
12
|
+
"resource_id" text NULL,
|
|
13
|
+
"payload" jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
14
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
15
|
+
"updated_at" timestamptz NOT NULL DEFAULT now(),
|
|
16
|
+
"deleted_at" timestamptz NULL,
|
|
17
|
+
CONSTRAINT "paypal_webhook_event_pkey" PRIMARY KEY ("id"),
|
|
18
|
+
CONSTRAINT "paypal_webhook_event_event_id_unique" UNIQUE ("event_id")
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
CREATE INDEX IF NOT EXISTS "idx_paypal_webhook_event_deleted_at"
|
|
22
|
+
ON "paypal_webhook_event" ("deleted_at");
|
|
23
23
|
`);
|
|
24
24
|
}
|
|
25
25
|
async down() {
|
|
26
|
-
this.addSql(`
|
|
27
|
-
DROP TABLE IF EXISTS "paypal_webhook_event" CASCADE;
|
|
26
|
+
this.addSql(`
|
|
27
|
+
DROP TABLE IF EXISTS "paypal_webhook_event" CASCADE;
|
|
28
28
|
`);
|
|
29
29
|
}
|
|
30
30
|
}
|