@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
|
@@ -1,123 +1,208 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from "react"
|
|
2
|
-
import PayPalTabs from "../_components/Tabs"
|
|
3
|
-
import SectionCard from "../_components/SectionCard"
|
|
4
|
-
import FieldRow from "../_components/FieldRow"
|
|
5
|
-
import Toast, { ToastState } from "../_components/Toast"
|
|
6
|
-
import { adminFetch } from "../_utils/adminFetch"
|
|
7
|
-
|
|
8
|
-
type ThreeDSContingency = "sli" | "when_required" | "always"
|
|
9
|
-
|
|
10
|
-
type AdvancedCardPaymentsForm = {
|
|
11
|
-
enabled: boolean
|
|
12
|
-
title: string
|
|
13
|
-
threeDS: ThreeDSContingency
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const DEFAULT_FORM: AdvancedCardPaymentsForm = {
|
|
17
|
-
enabled: true,
|
|
18
|
-
title: "Credit or Debit Card",
|
|
19
|
-
threeDS: "when_required",
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react"
|
|
2
|
+
import PayPalTabs from "../_components/Tabs"
|
|
3
|
+
import SectionCard from "../_components/SectionCard"
|
|
4
|
+
import FieldRow from "../_components/FieldRow"
|
|
5
|
+
import Toast, { ToastState } from "../_components/Toast"
|
|
6
|
+
import { adminFetch } from "../_utils/adminFetch"
|
|
7
|
+
|
|
8
|
+
type ThreeDSContingency = "sli" | "when_required" | "always"
|
|
9
|
+
|
|
10
|
+
type AdvancedCardPaymentsForm = {
|
|
11
|
+
enabled: boolean
|
|
12
|
+
title: string
|
|
13
|
+
threeDS: ThreeDSContingency
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DEFAULT_FORM: AdvancedCardPaymentsForm = {
|
|
17
|
+
enabled: true,
|
|
18
|
+
title: "Credit or Debit Card",
|
|
19
|
+
threeDS: "when_required",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Overlay saved values on the defaults, ignoring `undefined` entries. */
|
|
23
|
+
function mergeWithDefaults(saved?: Partial<AdvancedCardPaymentsForm> | null) {
|
|
24
|
+
if (!saved) return { ...DEFAULT_FORM }
|
|
25
|
+
const entries = Object.entries(saved).filter(
|
|
26
|
+
([, value]) => value !== undefined
|
|
27
|
+
)
|
|
28
|
+
return {
|
|
29
|
+
...DEFAULT_FORM,
|
|
30
|
+
...(Object.fromEntries(entries) as Partial<AdvancedCardPaymentsForm>),
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const THREE_DS_OPTIONS: {
|
|
35
|
+
value: ThreeDSContingency
|
|
36
|
+
label: string
|
|
37
|
+
hint?: string
|
|
38
|
+
}[] = [
|
|
39
|
+
{
|
|
40
|
+
value: "when_required",
|
|
41
|
+
label: "3D Secure when required",
|
|
42
|
+
hint: "Triggers 3DS only when the card / issuer requires it.",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: "sli",
|
|
46
|
+
label: "3D Secure (SCA) / liability shift (recommended)",
|
|
47
|
+
hint: "Attempts to optimize for liability shift while remaining compliant.",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
value: "always",
|
|
51
|
+
label: "Always request 3D Secure",
|
|
52
|
+
hint: "Forces 3DS challenge whenever possible (may reduce conversion).",
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
/** Settings → PayPal → Advanced Card Payments (hosted card fields + 3-D Secure). */
|
|
57
|
+
export default function AdvancedCardPaymentsTab() {
|
|
58
|
+
const [form, setForm] = useState<AdvancedCardPaymentsForm>(() => ({
|
|
59
|
+
...DEFAULT_FORM,
|
|
60
|
+
}))
|
|
61
|
+
const [loading, setLoading] = useState(false)
|
|
62
|
+
const [saving, setSaving] = useState(false)
|
|
63
|
+
const [toast, setToast] = useState<ToastState>(null)
|
|
64
|
+
const didInit = useRef(false)
|
|
65
|
+
|
|
66
|
+
const dismissToast = useCallback(() => setToast(null), [])
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (didInit.current) return
|
|
70
|
+
didInit.current = true
|
|
71
|
+
;(async () => {
|
|
72
|
+
try {
|
|
73
|
+
setLoading(true)
|
|
74
|
+
const json = await adminFetch<any>("/admin/paypal/settings")
|
|
75
|
+
const payload = json?.data ?? json
|
|
76
|
+
const saved = payload?.advanced_card_payments
|
|
77
|
+
if (saved && typeof saved === "object")
|
|
78
|
+
setForm(mergeWithDefaults(saved))
|
|
79
|
+
} catch {
|
|
80
|
+
// Keep the defaults if settings can't be loaded; saving still works.
|
|
81
|
+
} finally {
|
|
82
|
+
setLoading(false)
|
|
83
|
+
}
|
|
84
|
+
})()
|
|
85
|
+
}, [])
|
|
86
|
+
|
|
87
|
+
async function onSave() {
|
|
88
|
+
try {
|
|
89
|
+
setSaving(true)
|
|
90
|
+
const json = await adminFetch<any>("/admin/paypal/settings", {
|
|
91
|
+
method: "POST",
|
|
92
|
+
body: {
|
|
93
|
+
advanced_card_payments: form as unknown as Record<string, unknown>,
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
const payload = json?.data ?? json
|
|
97
|
+
const saved = payload?.advanced_card_payments
|
|
98
|
+
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved))
|
|
99
|
+
setToast({ kind: "success", message: "Settings saved" })
|
|
100
|
+
} catch (e: unknown) {
|
|
101
|
+
setToast({
|
|
102
|
+
kind: "error",
|
|
103
|
+
message:
|
|
104
|
+
(e instanceof Error ? e.message : "") || "Failed to save settings.",
|
|
105
|
+
})
|
|
106
|
+
} finally {
|
|
107
|
+
setSaving(false)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className="p-6">
|
|
113
|
+
<div className="flex flex-col gap-6">
|
|
114
|
+
<div className="flex items-start justify-between gap-4">
|
|
115
|
+
<div>
|
|
116
|
+
<h1 className="text-xl font-semibold text-ui-fg-base">
|
|
117
|
+
PayPal Gateway By Easy Payment
|
|
118
|
+
</h1>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
<PayPalTabs />
|
|
122
|
+
<Toast toast={toast} onClose={dismissToast} />
|
|
123
|
+
<SectionCard
|
|
124
|
+
title="Advanced Card Payments"
|
|
125
|
+
description="Control card checkout settings and 3D Secure behavior."
|
|
126
|
+
right={
|
|
127
|
+
<div className="flex items-center gap-3">
|
|
128
|
+
<button
|
|
129
|
+
type="button"
|
|
130
|
+
onClick={onSave}
|
|
131
|
+
disabled={saving || loading}
|
|
132
|
+
className="transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5"
|
|
133
|
+
>
|
|
134
|
+
{saving ? "Saving..." : "Save settings"}
|
|
135
|
+
</button>
|
|
136
|
+
{loading ? (
|
|
137
|
+
<span className="text-sm text-ui-fg-subtle">Loading…</span>
|
|
138
|
+
) : null}
|
|
139
|
+
</div>
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
<div className="divide-y divide-ui-border-base">
|
|
143
|
+
<FieldRow label="Enable/Disable">
|
|
144
|
+
<label className="inline-flex items-center gap-2">
|
|
145
|
+
<input
|
|
146
|
+
type="checkbox"
|
|
147
|
+
checked={form.enabled}
|
|
148
|
+
onChange={(e) =>
|
|
149
|
+
setForm((p) => ({ ...p, enabled: e.target.checked }))
|
|
150
|
+
}
|
|
151
|
+
className="h-4 w-4 rounded border-ui-border-base"
|
|
152
|
+
/>
|
|
153
|
+
<span className="text-sm text-ui-fg-base">
|
|
154
|
+
Enable Advanced Credit/Debit Card
|
|
155
|
+
</span>
|
|
156
|
+
</label>
|
|
157
|
+
</FieldRow>
|
|
158
|
+
<FieldRow label="Title" htmlFor="acp-title">
|
|
159
|
+
<input
|
|
160
|
+
id="acp-title"
|
|
161
|
+
value={form.title}
|
|
162
|
+
onChange={(e) =>
|
|
163
|
+
setForm((p) => ({ ...p, title: e.target.value }))
|
|
164
|
+
}
|
|
165
|
+
className="w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive"
|
|
166
|
+
placeholder="Credit or Debit Card"
|
|
167
|
+
/>
|
|
168
|
+
</FieldRow>
|
|
169
|
+
<FieldRow
|
|
170
|
+
label="Contingency for 3D Secure"
|
|
171
|
+
hint="Choose when 3D Secure should be triggered during card payments."
|
|
172
|
+
htmlFor="acp-threeds"
|
|
173
|
+
>
|
|
174
|
+
<div className="flex flex-col gap-2">
|
|
175
|
+
<select
|
|
176
|
+
id="acp-threeds"
|
|
177
|
+
value={form.threeDS}
|
|
178
|
+
onChange={(e) =>
|
|
179
|
+
setForm((p) => ({
|
|
180
|
+
...p,
|
|
181
|
+
threeDS: e.target.value as ThreeDSContingency,
|
|
182
|
+
}))
|
|
183
|
+
}
|
|
184
|
+
className="w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive"
|
|
185
|
+
>
|
|
186
|
+
{THREE_DS_OPTIONS.map((o) => (
|
|
187
|
+
<option key={o.value} value={o.value}>
|
|
188
|
+
{o.label}
|
|
189
|
+
</option>
|
|
190
|
+
))}
|
|
191
|
+
</select>
|
|
192
|
+
{THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)
|
|
193
|
+
?.hint ? (
|
|
194
|
+
<div className="text-xs text-ui-fg-subtle">
|
|
195
|
+
{
|
|
196
|
+
THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)
|
|
197
|
+
?.hint
|
|
198
|
+
}
|
|
199
|
+
</div>
|
|
200
|
+
) : null}
|
|
201
|
+
</div>
|
|
202
|
+
</FieldRow>
|
|
203
|
+
</div>
|
|
204
|
+
</SectionCard>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { Navigate } from "react-router-dom"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Navigate } from "react-router-dom"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Legacy route kept so old bookmarks/links keep working; the feature is not
|
|
5
|
+
* exposed in the current tab bar.
|
|
6
|
+
*/
|
|
7
|
+
export default function PayPalApplePayPage() {
|
|
8
|
+
return <Navigate to="/settings/paypal/connection" replace />
|
|
9
|
+
}
|