@easypayment/medusa-payment-paypal 1.2.3 → 1.2.4
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 +387 -133
- package/.medusa/server/src/admin/index.mjs +387 -133
- 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 +5 -0
- 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 +54 -20
- 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 +33 -6
- 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.map +1 -1
- 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 -6
- 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 +55 -32
- 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 +8 -0
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +39 -12
- package/.medusa/server/src/modules/paypal/payment-provider/service.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.map +1 -1
- package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +3 -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 +11 -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 +63 -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 +586 -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 +157 -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 +287 -275
- package/src/modules/paypal/payment-provider/card-service.ts +927 -855
- package/src/modules/paypal/payment-provider/index.ts +14 -15
- package/src/modules/paypal/payment-provider/service.ts +906 -836
- package/src/modules/paypal/payment-provider/status-utils.ts +59 -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 +275 -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
|
@@ -1,39 +1,48 @@
|
|
|
1
|
-
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
-
import { runCoreWorkflow } from "../../../../../modules/paypal/utils/core-workflow"
|
|
3
|
-
|
|
4
|
-
type CreatePaymentSessionBody = {
|
|
5
|
-
provider_id: string
|
|
6
|
-
data?: Record<string, unknown>
|
|
7
|
-
customer_id?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
+
import { runCoreWorkflow } from "../../../../../modules/paypal/utils/core-workflow"
|
|
3
|
+
|
|
4
|
+
type CreatePaymentSessionBody = {
|
|
5
|
+
provider_id: string
|
|
6
|
+
data?: Record<string, unknown>
|
|
7
|
+
customer_id?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Only PayPal sessions may be created through this admin-side route. */
|
|
11
|
+
const ALLOWED_PROVIDERS = new Set([
|
|
12
|
+
"pp_paypal_paypal",
|
|
13
|
+
"pp_paypal_card_paypal_card",
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
/** POST /admin/payment-collections/:id/payment-sessions — create a PayPal session. */
|
|
17
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
18
|
+
const collectionId = req.params.id
|
|
19
|
+
const { provider_id, data, customer_id } =
|
|
20
|
+
req.body as CreatePaymentSessionBody
|
|
21
|
+
|
|
22
|
+
if (!provider_id || !ALLOWED_PROVIDERS.has(provider_id)) {
|
|
23
|
+
return res
|
|
24
|
+
.status(400)
|
|
25
|
+
.json({ message: "Invalid or unsupported provider_id" })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!collectionId || typeof collectionId !== "string") {
|
|
29
|
+
return res.status(400).json({ message: "Invalid collection id" })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const { result } = await runCoreWorkflow(
|
|
34
|
+
req.scope,
|
|
35
|
+
"create-payment-sessions",
|
|
36
|
+
{
|
|
37
|
+
payment_collection_id: collectionId,
|
|
38
|
+
provider_id,
|
|
39
|
+
customer_id,
|
|
40
|
+
data,
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
res.status(200).json({ payment_session: result })
|
|
45
|
+
} catch {
|
|
46
|
+
res.status(500).json({ message: "Failed to create payment session" })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
-
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
1
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
+
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
+
|
|
4
|
+
/** POST /admin/paypal/disconnect — drop the active environment's credentials. */
|
|
5
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
6
|
+
try {
|
|
7
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
8
|
+
await paypal.disconnect()
|
|
9
|
+
return res.json({ ok: true })
|
|
10
|
+
} catch (e: unknown) {
|
|
11
|
+
const message = e instanceof Error ? e.message : String(e)
|
|
12
|
+
console.error("[PayPal] disconnect failed:", message)
|
|
13
|
+
return res.status(500).json({ message: "Failed to disconnect PayPal" })
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
-
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
-
|
|
4
|
-
type Body = {
|
|
5
|
-
environment?: "sandbox" | "live"
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return res.
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
+
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
+
|
|
4
|
+
type Body = {
|
|
5
|
+
environment?: "sandbox" | "live"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** GET /admin/paypal/environment — the active environment (`sandbox` | `live`). */
|
|
9
|
+
export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
10
|
+
try {
|
|
11
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
12
|
+
const status = await paypal.getStatus()
|
|
13
|
+
return res.json({ environment: status.environment })
|
|
14
|
+
} catch {
|
|
15
|
+
// This GET runs on every connection-page load; an unguarded rejection here
|
|
16
|
+
// (no connection row yet, transient DB / decrypt error) would surface as an
|
|
17
|
+
// unhandled 500. Fail soft so the admin page can still render.
|
|
18
|
+
return res.status(500).json({ message: "Failed to load environment" })
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** POST /admin/paypal/environment — switch environment and return the new status. */
|
|
23
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
24
|
+
try {
|
|
25
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
26
|
+
const body = (req.body || {}) as Body
|
|
27
|
+
const env = body.environment === "sandbox" ? "sandbox" : "live"
|
|
28
|
+
await paypal.setEnvironment(env)
|
|
29
|
+
const status = await paypal.getStatus()
|
|
30
|
+
return res.json(status)
|
|
31
|
+
} catch {
|
|
32
|
+
return res.status(500).json({ message: "Failed to update environment" })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,50 +1,61 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthenticatedMedusaRequest,
|
|
3
|
-
MedusaRequest,
|
|
4
|
-
MedusaResponse,
|
|
5
|
-
} from "@medusajs/framework/http"
|
|
6
|
-
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The PayPal onboarding `return_url` (the page the mini-browser popup lands on)
|
|
10
|
-
* is the PUBLIC route `GET /store/paypal/onboard-return` — `/admin/*` routes
|
|
11
|
-
* require an auth token that a top-level popup navigation cannot carry, which
|
|
12
|
-
* would leave the popup stuck on a 401 page. This admin GET is therefore not part
|
|
13
|
-
* of the browser flow; it only documents the contract for the POST below.
|
|
14
|
-
*/
|
|
15
|
-
export async function GET(_req: MedusaRequest, res: MedusaResponse) {
|
|
16
|
-
return res.status(405).json({
|
|
17
|
-
message:
|
|
18
|
-
"Method Not Allowed. Use POST with JSON: { authCode, sharedId, env }. This endpoint is called by the PayPal onboarding callback.",
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AuthenticatedMedusaRequest,
|
|
3
|
+
MedusaRequest,
|
|
4
|
+
MedusaResponse,
|
|
5
|
+
} from "@medusajs/framework/http"
|
|
6
|
+
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The PayPal onboarding `return_url` (the page the mini-browser popup lands on)
|
|
10
|
+
* is the PUBLIC route `GET /store/paypal/onboard-return` — `/admin/*` routes
|
|
11
|
+
* require an auth token that a top-level popup navigation cannot carry, which
|
|
12
|
+
* would leave the popup stuck on a 401 page. This admin GET is therefore not part
|
|
13
|
+
* of the browser flow; it only documents the contract for the POST below.
|
|
14
|
+
*/
|
|
15
|
+
export async function GET(_req: MedusaRequest, res: MedusaResponse) {
|
|
16
|
+
return res.status(405).json({
|
|
17
|
+
message:
|
|
18
|
+
"Method Not Allowed. Use POST with JSON: { authCode, sharedId, env }. This endpoint is called by the PayPal onboarding callback.",
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* POST /admin/paypal/onboard-complete — exchange PayPal's `authCode` +
|
|
24
|
+
* `sharedId` for seller credentials (idempotent).
|
|
25
|
+
*
|
|
26
|
+
* Typed as AuthenticatedMedusaRequest: every /admin/* route is gated by
|
|
27
|
+
* Medusa's built-in admin authentication, so this credential-exchange endpoint
|
|
28
|
+
* only runs for an authenticated admin. The typed request makes that contract
|
|
29
|
+
* explicit (and gives access to the authenticated actor if ever needed).
|
|
30
|
+
*/
|
|
31
|
+
export async function POST(
|
|
32
|
+
req: AuthenticatedMedusaRequest,
|
|
33
|
+
res: MedusaResponse
|
|
34
|
+
) {
|
|
35
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
36
|
+
const body = req.body as {
|
|
37
|
+
authCode?: string
|
|
38
|
+
sharedId?: string
|
|
39
|
+
env?: "sandbox" | "live"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!body?.authCode || !body?.sharedId) {
|
|
43
|
+
return res.status(400).json({ message: "Missing authCode/sharedId" })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
await paypal.exchangeAndSaveSellerCredentials({
|
|
48
|
+
authCode: body.authCode,
|
|
49
|
+
sharedId: body.sharedId,
|
|
50
|
+
env: body.env,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return res.json({ ok: true })
|
|
54
|
+
} catch (e: unknown) {
|
|
55
|
+
const message = e instanceof Error ? e.message : String(e)
|
|
56
|
+
console.error("[PayPal] onboard-complete failed:", message)
|
|
57
|
+
return res.status(500).json({
|
|
58
|
+
message: "Failed to exchange and save PayPal credentials",
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,76 +1,91 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthenticatedMedusaRequest,
|
|
3
|
-
MedusaRequest,
|
|
4
|
-
MedusaResponse,
|
|
5
|
-
} from "@medusajs/framework/http"
|
|
6
|
-
import type { IUserModuleService } from "@medusajs/framework/types"
|
|
7
|
-
import { Modules } from "@medusajs/framework/utils"
|
|
8
|
-
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
9
|
-
|
|
10
|
-
type Body = {
|
|
11
|
-
email?: string
|
|
12
|
-
products?: string[]
|
|
13
|
-
environment?: "sandbox" | "live"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
76
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AuthenticatedMedusaRequest,
|
|
3
|
+
MedusaRequest,
|
|
4
|
+
MedusaResponse,
|
|
5
|
+
} from "@medusajs/framework/http"
|
|
6
|
+
import type { IUserModuleService } from "@medusajs/framework/types"
|
|
7
|
+
import { Modules } from "@medusajs/framework/utils"
|
|
8
|
+
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
9
|
+
|
|
10
|
+
type Body = {
|
|
11
|
+
email?: string
|
|
12
|
+
products?: string[]
|
|
13
|
+
environment?: "sandbox" | "live"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* POST /admin/paypal/onboarding-link — mint a partner onboarding URL.
|
|
18
|
+
*
|
|
19
|
+
* The seller email is taken from the authenticated admin user when possible so
|
|
20
|
+
* PayPal pre-fills it; `body.email` is only a fallback.
|
|
21
|
+
*/
|
|
22
|
+
export async function POST(
|
|
23
|
+
req: AuthenticatedMedusaRequest,
|
|
24
|
+
res: MedusaResponse
|
|
25
|
+
) {
|
|
26
|
+
try {
|
|
27
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
28
|
+
const body = (req.body || {}) as Body
|
|
29
|
+
|
|
30
|
+
let authEmail: string | undefined
|
|
31
|
+
const actorId = req.auth_context?.actor_id
|
|
32
|
+
if (actorId) {
|
|
33
|
+
try {
|
|
34
|
+
const userModule = req.scope.resolve<IUserModuleService>(Modules.USER)
|
|
35
|
+
const user = await userModule.retrieveUser(actorId)
|
|
36
|
+
if (user.email && user.email.includes("@")) {
|
|
37
|
+
authEmail = user.email
|
|
38
|
+
}
|
|
39
|
+
} catch (err: any) {
|
|
40
|
+
console.warn(
|
|
41
|
+
"[paypal_onboarding] Could not resolve admin user email for actor",
|
|
42
|
+
actorId,
|
|
43
|
+
err?.message
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
console.warn("[paypal_onboarding] No actor_id in auth_context")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const email =
|
|
51
|
+
authEmail ||
|
|
52
|
+
(body.email && body.email.includes("@") ? body.email : undefined)
|
|
53
|
+
if (!email) {
|
|
54
|
+
return res.status(400).json({
|
|
55
|
+
message:
|
|
56
|
+
"Could not determine seller email. Please provide an email in the request body.",
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
const env =
|
|
60
|
+
body.environment === "sandbox" || body.environment === "live"
|
|
61
|
+
? body.environment
|
|
62
|
+
: undefined
|
|
63
|
+
|
|
64
|
+
const link = await paypal.createOnboardingLink({
|
|
65
|
+
email,
|
|
66
|
+
products: body.products,
|
|
67
|
+
env,
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return res.json({
|
|
71
|
+
status: "pending",
|
|
72
|
+
onboarding_url: link.onboarding_url,
|
|
73
|
+
return_url: link.return_url,
|
|
74
|
+
})
|
|
75
|
+
} catch (e: any) {
|
|
76
|
+
console.error(
|
|
77
|
+
"[paypal_onboarding] onboarding-link error:",
|
|
78
|
+
e?.message || e,
|
|
79
|
+
e?.stack
|
|
80
|
+
)
|
|
81
|
+
return res.status(500).json({
|
|
82
|
+
message: "Failed to generate PayPal onboarding link",
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function GET(_req: MedusaRequest, res: MedusaResponse) {
|
|
88
|
+
return res.status(405).json({
|
|
89
|
+
message: "Use POST /admin/paypal/onboarding-link",
|
|
90
|
+
})
|
|
91
|
+
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
-
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
1
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
+
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
+
|
|
4
|
+
/** GET /admin/paypal/onboarding-status — connection status for the active environment. */
|
|
5
|
+
export async function GET(req: MedusaRequest, res: MedusaResponse) {
|
|
6
|
+
try {
|
|
7
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
8
|
+
const status = await paypal.getStatus()
|
|
9
|
+
return res.json(status)
|
|
10
|
+
} catch (e: unknown) {
|
|
11
|
+
const message = e instanceof Error ? e.message : String(e)
|
|
12
|
+
console.error("[paypal_onboarding] onboarding-status error:", message)
|
|
13
|
+
// Do NOT report a definitive `status: "disconnected"` here — a transient DB
|
|
14
|
+
// or decrypt error would then look like the merchant is not connected and
|
|
15
|
+
// could trigger a needless re-onboarding. Signal the error with `unknown`.
|
|
16
|
+
return res.status(500).json({
|
|
17
|
+
status: "unknown",
|
|
18
|
+
message: "Failed to retrieve PayPal status",
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,37 +1,48 @@
|
|
|
1
|
-
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
-
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|
2
|
+
import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
3
|
+
|
|
4
|
+
/** POST /admin/paypal/save-credentials — store manually-entered REST credentials. */
|
|
5
|
+
export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
6
|
+
const paypal = req.scope.resolve<PayPalModuleService>("paypal_onboarding")
|
|
7
|
+
const body = req.body as {
|
|
8
|
+
clientId?: string
|
|
9
|
+
clientSecret?: string
|
|
10
|
+
environment?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
!body?.clientId ||
|
|
15
|
+
typeof body.clientId !== "string" ||
|
|
16
|
+
body.clientId.length > 200
|
|
17
|
+
) {
|
|
18
|
+
return res.status(400).json({ message: "Invalid or missing clientId" })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
!body?.clientSecret ||
|
|
23
|
+
typeof body.clientSecret !== "string" ||
|
|
24
|
+
body.clientSecret.length > 200
|
|
25
|
+
) {
|
|
26
|
+
return res.status(400).json({ message: "Invalid or missing clientSecret" })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const environment =
|
|
30
|
+
body.environment === "sandbox" || body.environment === "live"
|
|
31
|
+
? body.environment
|
|
32
|
+
: undefined
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
await paypal.saveAndHydrateSellerCredentials({
|
|
36
|
+
clientId: body.clientId.trim(),
|
|
37
|
+
clientSecret: body.clientSecret.trim(),
|
|
38
|
+
environment,
|
|
39
|
+
})
|
|
40
|
+
return res.json({ ok: true })
|
|
41
|
+
} catch (e: unknown) {
|
|
42
|
+
const message = e instanceof Error ? e.message : String(e)
|
|
43
|
+
console.error("[PayPal] save-credentials failed:", message)
|
|
44
|
+
return res
|
|
45
|
+
.status(500)
|
|
46
|
+
.json({ message: "Failed to save PayPal credentials" })
|
|
47
|
+
}
|
|
48
|
+
}
|