@easypayment/medusa-paypal 0.1.0
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 +2127 -0
- package/.medusa/server/src/admin/index.mjs +2128 -0
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js +25 -0
- package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.js +12 -0
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disconnect/route.js +9 -0
- package/.medusa/server/src/api/admin/paypal/disconnect/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.js +17 -0
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disputes/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/disputes/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disputes/route.js +27 -0
- package/.medusa/server/src/api/admin/paypal/disputes/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.js +17 -0
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/environment/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/paypal/environment/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/environment/route.js +23 -0
- package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts +8 -0
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js +41 -0
- package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js +35 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +20 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.js +8 -0
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.js +9 -0
- package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.js +13 -0
- package/.medusa/server/src/api/admin/paypal/save-credentials/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/settings/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/paypal/settings/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/settings/route.js +14 -0
- package/.medusa/server/src/api/admin/paypal/settings/route.js.map +1 -0
- package/.medusa/server/src/api/admin/paypal/status/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/paypal/status/route.d.ts.map +1 -0
- package/.medusa/server/src/api/admin/paypal/status/route.js +11 -0
- package/.medusa/server/src/api/admin/paypal/status/route.js.map +1 -0
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts +3 -0
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js +43 -0
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts +3 -0
- package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/paypal/capture-order/route.js +215 -0
- package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/config/route.d.ts +3 -0
- package/.medusa/server/src/api/store/paypal/config/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/paypal/config/route.js +45 -0
- package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts +3 -0
- package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/paypal/create-order/route.js +305 -0
- package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/disputes/route.d.ts +3 -0
- package/.medusa/server/src/api/store/paypal/disputes/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/paypal/disputes/route.js +46 -0
- package/.medusa/server/src/api/store/paypal/disputes/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/settings/route.d.ts +3 -0
- package/.medusa/server/src/api/store/paypal/settings/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/paypal/settings/route.js +14 -0
- package/.medusa/server/src/api/store/paypal/settings/route.js.map +1 -0
- package/.medusa/server/src/api/store/paypal/webhook/route.d.ts +3 -0
- package/.medusa/server/src/api/store/paypal/webhook/route.d.ts.map +1 -0
- package/.medusa/server/src/api/store/paypal/webhook/route.js +203 -0
- package/.medusa/server/src/api/store/paypal/webhook/route.js.map +1 -0
- package/.medusa/server/src/jobs/paypal-reconcile.d.ts +7 -0
- package/.medusa/server/src/jobs/paypal-reconcile.d.ts.map +1 -0
- package/.medusa/server/src/jobs/paypal-reconcile.js +131 -0
- package/.medusa/server/src/jobs/paypal-reconcile.js.map +1 -0
- package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts +7 -0
- package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts.map +1 -0
- package/.medusa/server/src/jobs/paypal-webhook-retry.js +78 -0
- package/.medusa/server/src/jobs/paypal-webhook-retry.js.map +1 -0
- package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.d.ts +14 -0
- package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js +65 -0
- package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js.map +1 -0
- package/.medusa/server/src/modules/paypal/index.d.ts +92 -0
- package/.medusa/server/src/modules/paypal/index.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/index.js +13 -0
- package/.medusa/server/src/modules/paypal/index.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.js +36 -0
- package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.js +25 -0
- package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.js +32 -0
- package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.js +29 -0
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.js +30 -0
- package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.js +43 -0
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.js +34 -0
- package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.d.ts +7 -0
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.js +10 -0
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts +14 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.js +17 -0
- package/.medusa/server/src/modules/paypal/models/paypal_connection.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.d.ts +16 -0
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.js +19 -0
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts +7 -0
- package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_metric.js +10 -0
- package/.medusa/server/src/modules/paypal/models/paypal_metric.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_settings.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/models/paypal_settings.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_settings.js +9 -0
- package/.medusa/server/src/modules/paypal/models/paypal_settings.js.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts +17 -0
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js +20 -0
- package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts +35 -0
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +569 -0
- package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/index.d.ts +10 -0
- package/.medusa/server/src/modules/paypal/payment-provider/index.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/index.js +22 -0
- package/.medusa/server/src/modules/paypal/payment-provider/index.js.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts +44 -0
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +825 -0
- package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.d.ts +3 -0
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js +74 -0
- package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js.map +1 -0
- package/.medusa/server/src/modules/paypal/service.d.ts +362 -0
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/service.js +1180 -0
- package/.medusa/server/src/modules/paypal/service.js.map +1 -0
- package/.medusa/server/src/modules/paypal/types/config.d.ts +14 -0
- package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/types/config.js +33 -0
- package/.medusa/server/src/modules/paypal/types/config.js.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/amounts.d.ts +3 -0
- package/.medusa/server/src/modules/paypal/utils/amounts.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/amounts.js +40 -0
- package/.medusa/server/src/modules/paypal/utils/amounts.js.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/crypto.d.ts +4 -0
- package/.medusa/server/src/modules/paypal/utils/crypto.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/crypto.js +47 -0
- package/.medusa/server/src/modules/paypal/utils/crypto.js.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/currencies.d.ts +19 -0
- package/.medusa/server/src/modules/paypal/utils/currencies.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/currencies.js +69 -0
- package/.medusa/server/src/modules/paypal/utils/currencies.js.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/provider-ids.d.ts +9 -0
- package/.medusa/server/src/modules/paypal/utils/provider-ids.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/utils/provider-ids.js +50 -0
- package/.medusa/server/src/modules/paypal/utils/provider-ids.js.map +1 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +38 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.js +265 -0
- package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/package.json +61 -0
- package/postcss.config.cjs +3 -0
- package/src/admin/index.ts +7 -0
- package/src/admin/routes/settings/paypal/_components/Tabs.tsx +55 -0
- package/src/admin/routes/settings/paypal/_components/Toast.tsx +51 -0
- package/src/admin/routes/settings/paypal/additional-settings/page.tsx +346 -0
- package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +381 -0
- package/src/admin/routes/settings/paypal/apple-pay/page.tsx +5 -0
- package/src/admin/routes/settings/paypal/audit-logs/page.tsx +131 -0
- package/src/admin/routes/settings/paypal/connection/page.tsx +750 -0
- package/src/admin/routes/settings/paypal/disputes/page.tsx +259 -0
- package/src/admin/routes/settings/paypal/google-pay/page.tsx +5 -0
- package/src/admin/routes/settings/paypal/page.tsx +16 -0
- package/src/admin/routes/settings/paypal/pay-later-messaging/page.tsx +5 -0
- package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +557 -0
- package/src/admin/routes/settings/paypal/reconciliation-status/page.tsx +165 -0
- package/src/api/admin/payment-collections/[id]/payment-sessions/route.ts +32 -0
- package/src/api/admin/paypal/audit-logs/route.ts +13 -0
- package/src/api/admin/paypal/disconnect/route.ts +8 -0
- package/src/api/admin/paypal/disputes/[id]/route.ts +19 -0
- package/src/api/admin/paypal/disputes/route.ts +30 -0
- package/src/api/admin/paypal/disputes/summary/route.ts +18 -0
- package/src/api/admin/paypal/environment/route.ts +25 -0
- package/src/api/admin/paypal/onboard-complete/route.ts +44 -0
- package/src/api/admin/paypal/onboarding-link/route.ts +45 -0
- package/src/api/admin/paypal/onboarding-status/route.ts +18 -0
- package/src/api/admin/paypal/reconciliation-status/route.ts +7 -0
- package/src/api/admin/paypal/rotate-credentials/route.ts +8 -0
- package/src/api/admin/paypal/save-credentials/route.ts +14 -0
- package/src/api/admin/paypal/settings/route.ts +14 -0
- package/src/api/admin/paypal/status/route.ts +12 -0
- package/src/api/store/payment-collections/[id]/payment-sessions/route.ts +51 -0
- package/src/api/store/paypal/capture-order/route.ts +270 -0
- package/src/api/store/paypal/config/route.ts +59 -0
- package/src/api/store/paypal/create-order/route.ts +374 -0
- package/src/api/store/paypal/disputes/route.ts +67 -0
- package/src/api/store/paypal/settings/route.ts +12 -0
- package/src/api/store/paypal/webhook/route.ts +247 -0
- package/src/jobs/paypal-reconcile.ts +135 -0
- package/src/jobs/paypal-webhook-retry.ts +86 -0
- package/src/modules/paypal/clients/paypal-seller.client.ts +59 -0
- package/src/modules/paypal/index.ts +8 -0
- package/src/modules/paypal/migrations/20260115120000_create_paypal_connection.ts +33 -0
- package/src/modules/paypal/migrations/20260123090000_create_paypal_settings.ts +22 -0
- package/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.ts +29 -0
- package/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.ts +26 -0
- package/src/modules/paypal/migrations/20260401090000_create_paypal_metric.ts +27 -0
- package/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.ts +40 -0
- package/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.ts +31 -0
- package/src/modules/paypal/models/paypal_audit_log.ts +9 -0
- package/src/modules/paypal/models/paypal_connection.ts +21 -0
- package/src/modules/paypal/models/paypal_dispute.ts +18 -0
- package/src/modules/paypal/models/paypal_metric.ts +9 -0
- package/src/modules/paypal/models/paypal_settings.ts +8 -0
- package/src/modules/paypal/models/paypal_webhook_event.ts +19 -0
- package/src/modules/paypal/payment-provider/README.md +22 -0
- package/src/modules/paypal/payment-provider/card-service.ts +710 -0
- package/src/modules/paypal/payment-provider/index.ts +19 -0
- package/src/modules/paypal/payment-provider/service.ts +1035 -0
- package/src/modules/paypal/payment-provider/webhook-utils.ts +88 -0
- package/src/modules/paypal/service.ts +1422 -0
- package/src/modules/paypal/types/config.ts +47 -0
- package/src/modules/paypal/utils/amounts.ts +41 -0
- package/src/modules/paypal/utils/crypto.ts +51 -0
- package/src/modules/paypal/utils/currencies.ts +84 -0
- package/src/modules/paypal/utils/provider-ids.ts +53 -0
- package/src/modules/paypal/webhook-processor.ts +313 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REQUIRED_EVENT_PREFIXES = exports.EVENT_STATUS_MAP = void 0;
|
|
4
|
+
exports.isAllowedEventType = isAllowedEventType;
|
|
5
|
+
exports.normalizeResource = normalizeResource;
|
|
6
|
+
exports.normalizeEventVersion = normalizeEventVersion;
|
|
7
|
+
exports.extractIdentifiers = extractIdentifiers;
|
|
8
|
+
exports.extractDisputeDetails = extractDisputeDetails;
|
|
9
|
+
exports.computeNextRetryAt = computeNextRetryAt;
|
|
10
|
+
exports.processPayPalWebhookEvent = processPayPalWebhookEvent;
|
|
11
|
+
const provider_ids_1 = require("./utils/provider-ids");
|
|
12
|
+
exports.EVENT_STATUS_MAP = {
|
|
13
|
+
"CHECKOUT.ORDER.APPROVED": "authorized",
|
|
14
|
+
"CHECKOUT.ORDER.CANCELLED": "canceled",
|
|
15
|
+
"PAYMENT.CAPTURE.COMPLETED": "captured",
|
|
16
|
+
"PAYMENT.CAPTURE.DENIED": "error",
|
|
17
|
+
"PAYMENT.CAPTURE.REFUNDED": "canceled",
|
|
18
|
+
"PAYMENT.CAPTURE.REVERSED": "canceled",
|
|
19
|
+
"PAYMENT.AUTHORIZATION.CREATED": "authorized",
|
|
20
|
+
"PAYMENT.AUTHORIZATION.VOIDED": "canceled",
|
|
21
|
+
"PAYMENT.AUTHORIZATION.DENIED": "error",
|
|
22
|
+
"PAYMENT.REFUND.COMPLETED": "canceled",
|
|
23
|
+
"PAYMENT.REFUND.DENIED": "error",
|
|
24
|
+
};
|
|
25
|
+
exports.REQUIRED_EVENT_PREFIXES = [
|
|
26
|
+
"PAYMENT.CAPTURE.",
|
|
27
|
+
"CHECKOUT.ORDER.",
|
|
28
|
+
"PAYMENT.AUTHORIZATION.",
|
|
29
|
+
"PAYMENT.REFUND.",
|
|
30
|
+
"CUSTOMER.DISPUTE.",
|
|
31
|
+
];
|
|
32
|
+
function isAllowedEventType(eventType) {
|
|
33
|
+
return exports.REQUIRED_EVENT_PREFIXES.some((prefix) => eventType.startsWith(prefix));
|
|
34
|
+
}
|
|
35
|
+
function normalizeResource(payload) {
|
|
36
|
+
const resource = payload?.resource;
|
|
37
|
+
if (!resource) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
if (typeof resource === "string") {
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(resource);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return resource;
|
|
49
|
+
}
|
|
50
|
+
function normalizeEventVersion(payload) {
|
|
51
|
+
const raw = payload?.event_version ??
|
|
52
|
+
payload?.resource_version ??
|
|
53
|
+
payload?.resource?.resource_version ??
|
|
54
|
+
payload?.resource?.version ??
|
|
55
|
+
null;
|
|
56
|
+
if (!raw) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return String(raw).trim().replace(/^v/i, "");
|
|
60
|
+
}
|
|
61
|
+
function extractIdentifiers(resource) {
|
|
62
|
+
const relatedIds = resource?.supplementary_data?.related_ids || {};
|
|
63
|
+
const orderId = relatedIds?.order_id ||
|
|
64
|
+
resource?.purchase_units?.[0]?.custom_id ||
|
|
65
|
+
resource?.custom_id ||
|
|
66
|
+
resource?.purchase_units?.[0]?.reference_id;
|
|
67
|
+
const captureId = relatedIds?.capture_id ||
|
|
68
|
+
resource?.id ||
|
|
69
|
+
resource?.purchase_units?.[0]?.payments?.captures?.[0]?.id;
|
|
70
|
+
const refundId = relatedIds?.refund_id ||
|
|
71
|
+
resource?.id ||
|
|
72
|
+
resource?.purchase_units?.[0]?.payments?.refunds?.[0]?.id;
|
|
73
|
+
const cartId = resource?.custom_id ||
|
|
74
|
+
resource?.purchase_units?.[0]?.custom_id ||
|
|
75
|
+
resource?.purchase_units?.[0]?.reference_id;
|
|
76
|
+
return { orderId, captureId, refundId, cartId, resource };
|
|
77
|
+
}
|
|
78
|
+
function extractDisputeDetails(resource) {
|
|
79
|
+
const disputeId = String(resource?.dispute_id || resource?.id || "");
|
|
80
|
+
const disputedTx = Array.isArray(resource?.disputed_transactions)
|
|
81
|
+
? resource.disputed_transactions[0]
|
|
82
|
+
: null;
|
|
83
|
+
const transactionId = disputedTx?.transaction_id || undefined;
|
|
84
|
+
const sellerTransactionId = disputedTx?.seller_transaction_id || undefined;
|
|
85
|
+
const customId = disputedTx?.custom_id || resource?.custom_id || undefined;
|
|
86
|
+
const orderId = resource?.order_id ||
|
|
87
|
+
resource?.supplementary_data?.related_ids?.order_id ||
|
|
88
|
+
customId ||
|
|
89
|
+
undefined;
|
|
90
|
+
const cartId = customId || undefined;
|
|
91
|
+
const amount = resource?.dispute_amount?.value ||
|
|
92
|
+
resource?.amount?.value ||
|
|
93
|
+
resource?.dispute_amount?.amount ||
|
|
94
|
+
undefined;
|
|
95
|
+
const currencyCode = resource?.dispute_amount?.currency_code ||
|
|
96
|
+
resource?.amount?.currency_code ||
|
|
97
|
+
resource?.dispute_amount?.currency ||
|
|
98
|
+
undefined;
|
|
99
|
+
return {
|
|
100
|
+
disputeId,
|
|
101
|
+
status: resource?.status || null,
|
|
102
|
+
reason: resource?.reason || null,
|
|
103
|
+
stage: resource?.dispute_life_cycle_stage || resource?.stage || null,
|
|
104
|
+
amount: amount ? String(amount) : null,
|
|
105
|
+
currencyCode: currencyCode ? String(currencyCode) : null,
|
|
106
|
+
transactionId: transactionId ? String(transactionId) : null,
|
|
107
|
+
sellerTransactionId: sellerTransactionId ? String(sellerTransactionId) : null,
|
|
108
|
+
orderId: orderId ? String(orderId) : null,
|
|
109
|
+
cartId: cartId ? String(cartId) : null,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function resolveDisputeOrderId(container, orderId, cartId) {
|
|
113
|
+
const query = container.resolve("query");
|
|
114
|
+
const cleanedOrderId = orderId?.trim();
|
|
115
|
+
const cleanedCartId = cartId?.trim();
|
|
116
|
+
if (cleanedOrderId) {
|
|
117
|
+
try {
|
|
118
|
+
const { data } = await query.graph({
|
|
119
|
+
entity: "order",
|
|
120
|
+
fields: ["id"],
|
|
121
|
+
filters: { id: cleanedOrderId },
|
|
122
|
+
});
|
|
123
|
+
const match = data?.[0]?.id;
|
|
124
|
+
if (match) {
|
|
125
|
+
return String(match);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// ignore order lookup failures
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (cleanedCartId) {
|
|
133
|
+
try {
|
|
134
|
+
const { data } = await query.graph({
|
|
135
|
+
entity: "order",
|
|
136
|
+
fields: ["id", "cart_id"],
|
|
137
|
+
filters: { cart_id: cleanedCartId },
|
|
138
|
+
});
|
|
139
|
+
const match = data?.[0]?.id;
|
|
140
|
+
if (match) {
|
|
141
|
+
return String(match);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// ignore order lookup failures
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
function mergeRefunds(existing, incoming) {
|
|
151
|
+
const seen = new Set();
|
|
152
|
+
const merged = [];
|
|
153
|
+
for (const refund of [...existing, ...incoming]) {
|
|
154
|
+
const id = refund?.id ? String(refund.id) : "";
|
|
155
|
+
if (id && seen.has(id)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (id) {
|
|
159
|
+
seen.add(id);
|
|
160
|
+
}
|
|
161
|
+
merged.push(refund);
|
|
162
|
+
}
|
|
163
|
+
return merged;
|
|
164
|
+
}
|
|
165
|
+
async function updatePaymentSession(container, cartId, status, data) {
|
|
166
|
+
const paymentCollectionService = container.resolve("payment_collection");
|
|
167
|
+
const paymentSessionService = container.resolve("payment_session");
|
|
168
|
+
const pc = await paymentCollectionService.retrieveByCartId(cartId).catch(() => null);
|
|
169
|
+
if (!pc?.id) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const sessions = await paymentSessionService.list({ payment_collection_id: pc.id });
|
|
173
|
+
const paypalSession = sessions?.find((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id));
|
|
174
|
+
if (!paypalSession) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const existingData = (paypalSession.data || {});
|
|
178
|
+
const existingPaypal = (existingData.paypal || {});
|
|
179
|
+
const existingRefunds = Array.isArray(existingPaypal.refunds) ? existingPaypal.refunds : [];
|
|
180
|
+
const incomingRefunds = Array.isArray(data.refunds) ? data.refunds : null;
|
|
181
|
+
const nextRefunds = incomingRefunds
|
|
182
|
+
? mergeRefunds(existingRefunds, incomingRefunds)
|
|
183
|
+
: existingRefunds;
|
|
184
|
+
await paymentSessionService.update(paypalSession.id, {
|
|
185
|
+
status,
|
|
186
|
+
data: {
|
|
187
|
+
...existingData,
|
|
188
|
+
paypal: {
|
|
189
|
+
...existingPaypal,
|
|
190
|
+
...data,
|
|
191
|
+
refunds: nextRefunds,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function computeNextRetryAt(attemptCount) {
|
|
197
|
+
const scheduleMinutes = [5, 15, 30, 60, 120];
|
|
198
|
+
const delayMinutes = scheduleMinutes[Math.min(attemptCount - 1, scheduleMinutes.length - 1)];
|
|
199
|
+
if (!delayMinutes || attemptCount <= 0) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
return new Date(Date.now() + delayMinutes * 60 * 1000);
|
|
203
|
+
}
|
|
204
|
+
async function processPayPalWebhookEvent(container, input) {
|
|
205
|
+
const paypal = container.resolve("paypal_onboarding");
|
|
206
|
+
const resource = normalizeResource(input.payload);
|
|
207
|
+
const { orderId, captureId, refundId, cartId } = extractIdentifiers(resource);
|
|
208
|
+
const disputeDetails = input.eventType.startsWith("CUSTOMER.DISPUTE.") ? extractDisputeDetails(resource) : null;
|
|
209
|
+
const refundReason = String(resource?.note_to_payer || resource?.reason || resource?.seller_note || "").trim() ||
|
|
210
|
+
undefined;
|
|
211
|
+
const refundReasonCode = String(resource?.reason_code || resource?.reasonCode || "").trim() || undefined;
|
|
212
|
+
if (input.eventType.startsWith("CUSTOMER.DISPUTE.")) {
|
|
213
|
+
if (disputeDetails?.disputeId) {
|
|
214
|
+
const resolvedOrderId = await resolveDisputeOrderId(container, disputeDetails.orderId, disputeDetails.cartId);
|
|
215
|
+
await paypal.upsertDispute({
|
|
216
|
+
dispute_id: disputeDetails.disputeId,
|
|
217
|
+
status: disputeDetails.status,
|
|
218
|
+
reason: disputeDetails.reason,
|
|
219
|
+
stage: disputeDetails.stage,
|
|
220
|
+
amount: disputeDetails.amount,
|
|
221
|
+
currency_code: disputeDetails.currencyCode,
|
|
222
|
+
transaction_id: disputeDetails.transactionId,
|
|
223
|
+
seller_transaction_id: disputeDetails.sellerTransactionId,
|
|
224
|
+
order_id: resolvedOrderId || disputeDetails.orderId,
|
|
225
|
+
cart_id: disputeDetails.cartId,
|
|
226
|
+
payload: resource,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const status = exports.EVENT_STATUS_MAP[input.eventType];
|
|
231
|
+
if (status && cartId) {
|
|
232
|
+
const refundEntry = refundId || resource?.status
|
|
233
|
+
? [
|
|
234
|
+
{
|
|
235
|
+
id: refundId,
|
|
236
|
+
status: resource?.status,
|
|
237
|
+
reason: refundReason,
|
|
238
|
+
reason_code: refundReasonCode,
|
|
239
|
+
amount: resource?.amount,
|
|
240
|
+
raw: resource,
|
|
241
|
+
},
|
|
242
|
+
]
|
|
243
|
+
: null;
|
|
244
|
+
await updatePaymentSession(container, cartId, status, {
|
|
245
|
+
order_id: orderId,
|
|
246
|
+
capture_id: captureId,
|
|
247
|
+
refund_id: refundId,
|
|
248
|
+
refund_status: resource?.status,
|
|
249
|
+
refund_reason: refundReason,
|
|
250
|
+
refund_reason_code: refundReasonCode,
|
|
251
|
+
refunds: refundEntry || undefined,
|
|
252
|
+
webhook_event_type: input.eventType,
|
|
253
|
+
webhook_resource: resource,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
orderId,
|
|
258
|
+
captureId,
|
|
259
|
+
refundId,
|
|
260
|
+
cartId,
|
|
261
|
+
disputeId: disputeDetails?.disputeId,
|
|
262
|
+
resource,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=webhook-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-processor.js","sourceRoot":"","sources":["../../../../../src/modules/paypal/webhook-processor.ts"],"names":[],"mappings":";;;AA0BA,gDAEC;AAED,8CAaC;AAED,sDAaC;AAED,gDAqBC;AAED,sDAqCC;AAyGD,gDAOC;AAED,8DA8EC;AAtTD,uDAAyD;AAE5C,QAAA,gBAAgB,GAAqE;IAChG,yBAAyB,EAAE,YAAY;IACvC,0BAA0B,EAAE,UAAU;IACtC,2BAA2B,EAAE,UAAU;IACvC,wBAAwB,EAAE,OAAO;IACjC,0BAA0B,EAAE,UAAU;IACtC,0BAA0B,EAAE,UAAU;IACtC,+BAA+B,EAAE,YAAY;IAC7C,8BAA8B,EAAE,UAAU;IAC1C,8BAA8B,EAAE,OAAO;IACvC,0BAA0B,EAAE,UAAU;IACtC,uBAAuB,EAAE,OAAO;CACjC,CAAA;AAEY,QAAA,uBAAuB,GAAG;IACrC,kBAAkB;IAClB,iBAAiB;IACjB,wBAAwB;IACxB,iBAAiB;IACjB,mBAAmB;CACpB,CAAA;AAED,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO,+BAAuB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED,SAAgB,iBAAiB,CAAC,OAA4B;IAC5D,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAA;IAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAA;QACX,CAA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,QAAQ;oBACZ,MAAM,EAAE,QAAQ,EAAE,MAAM;oBACxB,MAAM,EAAE,YAAY;oBACpB,WAAW,EAAE,gBAAgB;oBAC7B,MAAM,EAAG,QAAgB,EAAE,MAAM;oBACjC,GAAG,EAAE,QAAQ;iBACd;aACF;YACH,CAAC,CAAC,IAAI,CAAA;QAEV,MAAM,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE;YACpD,QAAQ,EAAE,OAAO;YACjB,UAAU,EAAE,SAAS;YACrB,SAAS,EAAE,QAAQ;YACnB,aAAa,EAAE,QAAQ,EAAE,MAAM;YAC/B,aAAa,EAAE,YAAY;YAC3B,kBAAkB,EAAE,gBAAgB;YACpC,OAAO,EAAE,WAAW,IAAI,SAAS;YACjC,kBAAkB,EAAE,KAAK,CAAC,SAAS;YACnC,gBAAgB,EAAE,QAAQ;SAC3B,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,OAAO;QACP,SAAS;QACT,QAAQ;QACR,MAAM;QACN,SAAS,EAAE,cAAc,EAAE,SAAS;QACpC,QAAQ;KACT,CAAA;AACH,CAAC"}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @easypayment/medusa-paypal
|
|
2
|
+
|
|
3
|
+
PayPal backend plugin for **Medusa v2** (payment providers + Admin settings extensions).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @easypayment/medusa-paypal
|
|
9
|
+
# or
|
|
10
|
+
yarn add @easypayment/medusa-paypal
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Register in `medusa-config.ts`
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
plugins: [
|
|
17
|
+
{ resolve: "@easypayment/medusa-paypal", options: {} },
|
|
18
|
+
]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> If you also register the payment providers via the Payment module, use the exported provider paths under
|
|
22
|
+
> `@easypayment/medusa-paypal/providers/*`.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Included backend code
|
|
27
|
+
|
|
28
|
+
- `src/modules/paypal/**` – PayPal module, provider, migrations, services, and utils.
|
|
29
|
+
- `src/api/admin/paypal/**` – Admin PayPal routes.
|
|
30
|
+
- `src/api/store/paypal/**` – Storefront PayPal routes.
|
|
31
|
+
- `src/api/admin/payment-collections/[id]/payment-sessions/**` – Admin PayPal payment sessions route.
|
|
32
|
+
- `src/api/store/payment-collections/[id]/payment-sessions/**` – Store PayPal payment sessions route.
|
|
33
|
+
- `src/jobs/paypal-*.ts` – PayPal jobs (reconcile and webhook retry).
|
|
34
|
+
|
|
35
|
+
## How to use this package (step-by-step)
|
|
36
|
+
|
|
37
|
+
1. **Move PayPal backend code into the package**
|
|
38
|
+
Keep all PayPal backend files in this package under `packages/paypal-backend/src`.
|
|
39
|
+
|
|
40
|
+
2. **Point Medusa to the package**
|
|
41
|
+
In `medusa-config.ts`, update the PayPal module/provider resolve paths to use
|
|
42
|
+
`./packages/paypal-backend/src/modules/paypal` (and the `dist` path for production).
|
|
43
|
+
|
|
44
|
+
3. **Install dependencies (if needed)**
|
|
45
|
+
If you later publish or share this package, add it to your project dependencies
|
|
46
|
+
via a `file:` dependency or workspace setup. For local use, the project can
|
|
47
|
+
reference the package by path.
|
|
48
|
+
|
|
49
|
+
4. **Run the project**
|
|
50
|
+
Start the Medusa server as usual:
|
|
51
|
+
- `pnpm dev` or `yarn dev`
|
|
52
|
+
|
|
53
|
+
## Removing PayPal backend files from `src`
|
|
54
|
+
|
|
55
|
+
Once the package is in place, remove the PayPal backend files from `src` so that
|
|
56
|
+
only the package holds the backend implementation. The PayPal frontend/admin UI
|
|
57
|
+
files can remain in `src/admin` if you still need them.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Publishing
|
|
61
|
+
|
|
62
|
+
1. Update `name` in `package.json` to your npm scope (for example `@yourorg/medusa-paypal`).
|
|
63
|
+
2. Run `npm install`.
|
|
64
|
+
3. Run `npm run build` (or `npx medusa plugin:build`).
|
|
65
|
+
4. Publish with `npm publish --access public` (scoped packages).
|
|
66
|
+
|
|
67
|
+
> Note: The plugin ships its compiled output under `.medusa/server`, and the `exports` map exposes the Admin extension at `@scope/pkg/admin`.
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@easypayment/medusa-paypal",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "PayPal integration for Medusa v2 (payment providers + admin settings pages)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"medusa-v2",
|
|
9
|
+
"medusa-plugin-integration",
|
|
10
|
+
"medusa-plugin-payment",
|
|
11
|
+
"paypal"
|
|
12
|
+
],
|
|
13
|
+
"main": "./.medusa/server/src/index.js",
|
|
14
|
+
"types": "./.medusa/server/src/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
".medusa/server",
|
|
17
|
+
"src",
|
|
18
|
+
"package.json",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"tsconfig.json",
|
|
22
|
+
"postcss.config.cjs"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
"./admin": "./.medusa/server/src/admin/index.mjs",
|
|
27
|
+
"./workflows": "./.medusa/server/src/workflows/index.js",
|
|
28
|
+
"./providers/*": "./.medusa/server/src/providers/*/index.js",
|
|
29
|
+
"./modules/*": "./.medusa/server/src/modules/*/index.js",
|
|
30
|
+
"./*": "./.medusa/server/src/*.js"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "medusa plugin:build",
|
|
34
|
+
"develop": "medusa plugin:develop",
|
|
35
|
+
"prepublishOnly": "medusa plugin:build"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@medusajs/admin-sdk": "2.12.5",
|
|
39
|
+
"@medusajs/cli": "2.12.5",
|
|
40
|
+
"@medusajs/framework": "2.12.5",
|
|
41
|
+
"@medusajs/medusa": "2.12.5",
|
|
42
|
+
"@medusajs/test-utils": "2.12.5",
|
|
43
|
+
"@medusajs/ui": "^4.0.0",
|
|
44
|
+
"@medusajs/icons": "2.12.5",
|
|
45
|
+
"@swc/core": "^1.5.7",
|
|
46
|
+
"typescript": "^5.6.2"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@medusajs/admin-sdk": "^2.12.0",
|
|
50
|
+
"@medusajs/framework": "^2.12.0",
|
|
51
|
+
"@medusajs/medusa": "^2.12.0",
|
|
52
|
+
"@medusajs/ui": "^4.0.0",
|
|
53
|
+
"@medusajs/icons": "^2.12.0"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=20"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Link, useLocation } from "react-router-dom"
|
|
3
|
+
|
|
4
|
+
type Tab = {
|
|
5
|
+
label: string
|
|
6
|
+
to: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const BASE = "/settings/paypal"
|
|
10
|
+
|
|
11
|
+
const TABS: Tab[] = [
|
|
12
|
+
{ label: "PayPal Connection", to: `${BASE}/connection` },
|
|
13
|
+
{ label: "PayPal Settings", to: `${BASE}/paypal-settings` },
|
|
14
|
+
{ label: "Advanced Card Payments", to: `${BASE}/advanced-card-payments` },
|
|
15
|
+
{ label: "Disputes", to: `${BASE}/disputes` },
|
|
16
|
+
{ label: "Reconciliation Status", to: `${BASE}/reconciliation-status` },
|
|
17
|
+
/* { label: "Google Pay", to: `${BASE}/google-pay` },
|
|
18
|
+
{ label: "Apple Pay", to: `${BASE}/apple-pay` },
|
|
19
|
+
{ label: "Pay Later Messaging", to: `${BASE}/pay-later-messaging` }, */
|
|
20
|
+
{ label: "Audit Logs", to: `${BASE}/audit-logs` },
|
|
21
|
+
{ label: "Additional Settings", to: `${BASE}/additional-settings` },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
function isActive(pathname: string, to: string) {
|
|
25
|
+
// exact match OR nested route under same tab
|
|
26
|
+
return pathname === to || pathname.startsWith(to + "/")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function PayPalTabs() {
|
|
30
|
+
const { pathname } = useLocation()
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="border-b border-ui-border-base">
|
|
34
|
+
<div className="flex flex-wrap gap-6 text-sm">
|
|
35
|
+
{TABS.map((t) => {
|
|
36
|
+
const active = isActive(pathname, t.to)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Link
|
|
40
|
+
key={t.to}
|
|
41
|
+
to={t.to}
|
|
42
|
+
className={
|
|
43
|
+
active
|
|
44
|
+
? "border-b-2 border-ui-fg-base pb-2 font-medium text-ui-fg-base"
|
|
45
|
+
: "pb-2 text-ui-fg-subtle hover:text-ui-fg-base"
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
{t.label}
|
|
49
|
+
</Link>
|
|
50
|
+
)
|
|
51
|
+
})}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useEffect } from "react"
|
|
2
|
+
|
|
3
|
+
export type ToastKind = "success" | "error"
|
|
4
|
+
|
|
5
|
+
export type ToastState = {
|
|
6
|
+
kind: ToastKind
|
|
7
|
+
message: string
|
|
8
|
+
} | null
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
toast: ToastState
|
|
12
|
+
onClose: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function Toast({ toast, onClose }: Props) {
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!toast) return
|
|
18
|
+
const t = setTimeout(() => onClose(), 2500)
|
|
19
|
+
return () => clearTimeout(t)
|
|
20
|
+
}, [toast, onClose])
|
|
21
|
+
|
|
22
|
+
if (!toast) return null
|
|
23
|
+
|
|
24
|
+
const isSuccess = toast.kind === "success"
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="fixed right-6 top-6 z-[9999]">
|
|
28
|
+
<div
|
|
29
|
+
className={[
|
|
30
|
+
"min-w-[280px] max-w-[420px] rounded-lg border px-4 py-3 shadow-md",
|
|
31
|
+
isSuccess ? "border-emerald-500/30 bg-emerald-500/10" : "border-rose-500/30 bg-rose-500/10",
|
|
32
|
+
].join(" ")}
|
|
33
|
+
role="status"
|
|
34
|
+
aria-live="polite"
|
|
35
|
+
>
|
|
36
|
+
<div className="flex items-start gap-3">
|
|
37
|
+
<div className={["mt-0.5 h-2.5 w-2.5 rounded-full", isSuccess ? "bg-emerald-500" : "bg-rose-500"].join(" ")} />
|
|
38
|
+
<div className="flex-1 text-sm text-ui-fg-base">{toast.message}</div>
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
onClick={onClose}
|
|
42
|
+
className="text-ui-fg-subtle hover:text-ui-fg-base"
|
|
43
|
+
aria-label="Close"
|
|
44
|
+
>
|
|
45
|
+
×
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
}
|