@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.
Files changed (272) hide show
  1. package/.medusa/server/src/admin/index.js +2127 -0
  2. package/.medusa/server/src/admin/index.mjs +2128 -0
  3. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts +3 -0
  4. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -0
  5. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js +25 -0
  6. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js.map +1 -0
  7. package/.medusa/server/src/api/admin/paypal/audit-logs/route.d.ts +3 -0
  8. package/.medusa/server/src/api/admin/paypal/audit-logs/route.d.ts.map +1 -0
  9. package/.medusa/server/src/api/admin/paypal/audit-logs/route.js +12 -0
  10. package/.medusa/server/src/api/admin/paypal/audit-logs/route.js.map +1 -0
  11. package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts +3 -0
  12. package/.medusa/server/src/api/admin/paypal/disconnect/route.d.ts.map +1 -0
  13. package/.medusa/server/src/api/admin/paypal/disconnect/route.js +9 -0
  14. package/.medusa/server/src/api/admin/paypal/disconnect/route.js.map +1 -0
  15. package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.d.ts +3 -0
  16. package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.d.ts.map +1 -0
  17. package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.js +17 -0
  18. package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.js.map +1 -0
  19. package/.medusa/server/src/api/admin/paypal/disputes/route.d.ts +3 -0
  20. package/.medusa/server/src/api/admin/paypal/disputes/route.d.ts.map +1 -0
  21. package/.medusa/server/src/api/admin/paypal/disputes/route.js +27 -0
  22. package/.medusa/server/src/api/admin/paypal/disputes/route.js.map +1 -0
  23. package/.medusa/server/src/api/admin/paypal/disputes/summary/route.d.ts +3 -0
  24. package/.medusa/server/src/api/admin/paypal/disputes/summary/route.d.ts.map +1 -0
  25. package/.medusa/server/src/api/admin/paypal/disputes/summary/route.js +17 -0
  26. package/.medusa/server/src/api/admin/paypal/disputes/summary/route.js.map +1 -0
  27. package/.medusa/server/src/api/admin/paypal/environment/route.d.ts +4 -0
  28. package/.medusa/server/src/api/admin/paypal/environment/route.d.ts.map +1 -0
  29. package/.medusa/server/src/api/admin/paypal/environment/route.js +23 -0
  30. package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -0
  31. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts +8 -0
  32. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.d.ts.map +1 -0
  33. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js +41 -0
  34. package/.medusa/server/src/api/admin/paypal/onboard-complete/route.js.map +1 -0
  35. package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts +4 -0
  36. package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts.map +1 -0
  37. package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js +35 -0
  38. package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js.map +1 -0
  39. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts +3 -0
  40. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts.map +1 -0
  41. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +20 -0
  42. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -0
  43. package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.d.ts +3 -0
  44. package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.d.ts.map +1 -0
  45. package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.js +8 -0
  46. package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.js.map +1 -0
  47. package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.d.ts +3 -0
  48. package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.d.ts.map +1 -0
  49. package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.js +9 -0
  50. package/.medusa/server/src/api/admin/paypal/rotate-credentials/route.js.map +1 -0
  51. package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts +3 -0
  52. package/.medusa/server/src/api/admin/paypal/save-credentials/route.d.ts.map +1 -0
  53. package/.medusa/server/src/api/admin/paypal/save-credentials/route.js +13 -0
  54. package/.medusa/server/src/api/admin/paypal/save-credentials/route.js.map +1 -0
  55. package/.medusa/server/src/api/admin/paypal/settings/route.d.ts +4 -0
  56. package/.medusa/server/src/api/admin/paypal/settings/route.d.ts.map +1 -0
  57. package/.medusa/server/src/api/admin/paypal/settings/route.js +14 -0
  58. package/.medusa/server/src/api/admin/paypal/settings/route.js.map +1 -0
  59. package/.medusa/server/src/api/admin/paypal/status/route.d.ts +3 -0
  60. package/.medusa/server/src/api/admin/paypal/status/route.d.ts.map +1 -0
  61. package/.medusa/server/src/api/admin/paypal/status/route.js +11 -0
  62. package/.medusa/server/src/api/admin/paypal/status/route.js.map +1 -0
  63. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts +3 -0
  64. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -0
  65. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js +43 -0
  66. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js.map +1 -0
  67. package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts +3 -0
  68. package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -0
  69. package/.medusa/server/src/api/store/paypal/capture-order/route.js +215 -0
  70. package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -0
  71. package/.medusa/server/src/api/store/paypal/config/route.d.ts +3 -0
  72. package/.medusa/server/src/api/store/paypal/config/route.d.ts.map +1 -0
  73. package/.medusa/server/src/api/store/paypal/config/route.js +45 -0
  74. package/.medusa/server/src/api/store/paypal/config/route.js.map +1 -0
  75. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts +3 -0
  76. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -0
  77. package/.medusa/server/src/api/store/paypal/create-order/route.js +305 -0
  78. package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -0
  79. package/.medusa/server/src/api/store/paypal/disputes/route.d.ts +3 -0
  80. package/.medusa/server/src/api/store/paypal/disputes/route.d.ts.map +1 -0
  81. package/.medusa/server/src/api/store/paypal/disputes/route.js +46 -0
  82. package/.medusa/server/src/api/store/paypal/disputes/route.js.map +1 -0
  83. package/.medusa/server/src/api/store/paypal/settings/route.d.ts +3 -0
  84. package/.medusa/server/src/api/store/paypal/settings/route.d.ts.map +1 -0
  85. package/.medusa/server/src/api/store/paypal/settings/route.js +14 -0
  86. package/.medusa/server/src/api/store/paypal/settings/route.js.map +1 -0
  87. package/.medusa/server/src/api/store/paypal/webhook/route.d.ts +3 -0
  88. package/.medusa/server/src/api/store/paypal/webhook/route.d.ts.map +1 -0
  89. package/.medusa/server/src/api/store/paypal/webhook/route.js +203 -0
  90. package/.medusa/server/src/api/store/paypal/webhook/route.js.map +1 -0
  91. package/.medusa/server/src/jobs/paypal-reconcile.d.ts +7 -0
  92. package/.medusa/server/src/jobs/paypal-reconcile.d.ts.map +1 -0
  93. package/.medusa/server/src/jobs/paypal-reconcile.js +131 -0
  94. package/.medusa/server/src/jobs/paypal-reconcile.js.map +1 -0
  95. package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts +7 -0
  96. package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts.map +1 -0
  97. package/.medusa/server/src/jobs/paypal-webhook-retry.js +78 -0
  98. package/.medusa/server/src/jobs/paypal-webhook-retry.js.map +1 -0
  99. package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.d.ts +14 -0
  100. package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.d.ts.map +1 -0
  101. package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js +65 -0
  102. package/.medusa/server/src/modules/paypal/clients/paypal-seller.client.js.map +1 -0
  103. package/.medusa/server/src/modules/paypal/index.d.ts +92 -0
  104. package/.medusa/server/src/modules/paypal/index.d.ts.map +1 -0
  105. package/.medusa/server/src/modules/paypal/index.js +13 -0
  106. package/.medusa/server/src/modules/paypal/index.js.map +1 -0
  107. package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.d.ts +6 -0
  108. package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.d.ts.map +1 -0
  109. package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.js +36 -0
  110. package/.medusa/server/src/modules/paypal/migrations/20260115120000_create_paypal_connection.js.map +1 -0
  111. package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.d.ts +6 -0
  112. package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.d.ts.map +1 -0
  113. package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.js +25 -0
  114. package/.medusa/server/src/modules/paypal/migrations/20260123090000_create_paypal_settings.js.map +1 -0
  115. package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.d.ts +6 -0
  116. package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.d.ts.map +1 -0
  117. package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.js +32 -0
  118. package/.medusa/server/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.js.map +1 -0
  119. package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.d.ts +6 -0
  120. package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.d.ts.map +1 -0
  121. package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.js +29 -0
  122. package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.js.map +1 -0
  123. package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.d.ts +6 -0
  124. package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.d.ts.map +1 -0
  125. package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.js +30 -0
  126. package/.medusa/server/src/modules/paypal/migrations/20260401090000_create_paypal_metric.js.map +1 -0
  127. package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.d.ts +6 -0
  128. package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.d.ts.map +1 -0
  129. package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.js +43 -0
  130. package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.js.map +1 -0
  131. package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.d.ts +6 -0
  132. package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.d.ts.map +1 -0
  133. package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.js +34 -0
  134. package/.medusa/server/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.js.map +1 -0
  135. package/.medusa/server/src/modules/paypal/models/paypal_audit_log.d.ts +7 -0
  136. package/.medusa/server/src/modules/paypal/models/paypal_audit_log.d.ts.map +1 -0
  137. package/.medusa/server/src/modules/paypal/models/paypal_audit_log.js +10 -0
  138. package/.medusa/server/src/modules/paypal/models/paypal_audit_log.js.map +1 -0
  139. package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts +14 -0
  140. package/.medusa/server/src/modules/paypal/models/paypal_connection.d.ts.map +1 -0
  141. package/.medusa/server/src/modules/paypal/models/paypal_connection.js +17 -0
  142. package/.medusa/server/src/modules/paypal/models/paypal_connection.js.map +1 -0
  143. package/.medusa/server/src/modules/paypal/models/paypal_dispute.d.ts +16 -0
  144. package/.medusa/server/src/modules/paypal/models/paypal_dispute.d.ts.map +1 -0
  145. package/.medusa/server/src/modules/paypal/models/paypal_dispute.js +19 -0
  146. package/.medusa/server/src/modules/paypal/models/paypal_dispute.js.map +1 -0
  147. package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts +7 -0
  148. package/.medusa/server/src/modules/paypal/models/paypal_metric.d.ts.map +1 -0
  149. package/.medusa/server/src/modules/paypal/models/paypal_metric.js +10 -0
  150. package/.medusa/server/src/modules/paypal/models/paypal_metric.js.map +1 -0
  151. package/.medusa/server/src/modules/paypal/models/paypal_settings.d.ts +6 -0
  152. package/.medusa/server/src/modules/paypal/models/paypal_settings.d.ts.map +1 -0
  153. package/.medusa/server/src/modules/paypal/models/paypal_settings.js +9 -0
  154. package/.medusa/server/src/modules/paypal/models/paypal_settings.js.map +1 -0
  155. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts +17 -0
  156. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.d.ts.map +1 -0
  157. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js +20 -0
  158. package/.medusa/server/src/modules/paypal/models/paypal_webhook_event.js.map +1 -0
  159. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts +35 -0
  160. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -0
  161. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +569 -0
  162. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -0
  163. package/.medusa/server/src/modules/paypal/payment-provider/index.d.ts +10 -0
  164. package/.medusa/server/src/modules/paypal/payment-provider/index.d.ts.map +1 -0
  165. package/.medusa/server/src/modules/paypal/payment-provider/index.js +22 -0
  166. package/.medusa/server/src/modules/paypal/payment-provider/index.js.map +1 -0
  167. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts +44 -0
  168. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -0
  169. package/.medusa/server/src/modules/paypal/payment-provider/service.js +825 -0
  170. package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -0
  171. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.d.ts +3 -0
  172. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.d.ts.map +1 -0
  173. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js +74 -0
  174. package/.medusa/server/src/modules/paypal/payment-provider/webhook-utils.js.map +1 -0
  175. package/.medusa/server/src/modules/paypal/service.d.ts +362 -0
  176. package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -0
  177. package/.medusa/server/src/modules/paypal/service.js +1180 -0
  178. package/.medusa/server/src/modules/paypal/service.js.map +1 -0
  179. package/.medusa/server/src/modules/paypal/types/config.d.ts +14 -0
  180. package/.medusa/server/src/modules/paypal/types/config.d.ts.map +1 -0
  181. package/.medusa/server/src/modules/paypal/types/config.js +33 -0
  182. package/.medusa/server/src/modules/paypal/types/config.js.map +1 -0
  183. package/.medusa/server/src/modules/paypal/utils/amounts.d.ts +3 -0
  184. package/.medusa/server/src/modules/paypal/utils/amounts.d.ts.map +1 -0
  185. package/.medusa/server/src/modules/paypal/utils/amounts.js +40 -0
  186. package/.medusa/server/src/modules/paypal/utils/amounts.js.map +1 -0
  187. package/.medusa/server/src/modules/paypal/utils/crypto.d.ts +4 -0
  188. package/.medusa/server/src/modules/paypal/utils/crypto.d.ts.map +1 -0
  189. package/.medusa/server/src/modules/paypal/utils/crypto.js +47 -0
  190. package/.medusa/server/src/modules/paypal/utils/crypto.js.map +1 -0
  191. package/.medusa/server/src/modules/paypal/utils/currencies.d.ts +19 -0
  192. package/.medusa/server/src/modules/paypal/utils/currencies.d.ts.map +1 -0
  193. package/.medusa/server/src/modules/paypal/utils/currencies.js +69 -0
  194. package/.medusa/server/src/modules/paypal/utils/currencies.js.map +1 -0
  195. package/.medusa/server/src/modules/paypal/utils/provider-ids.d.ts +9 -0
  196. package/.medusa/server/src/modules/paypal/utils/provider-ids.d.ts.map +1 -0
  197. package/.medusa/server/src/modules/paypal/utils/provider-ids.js +50 -0
  198. package/.medusa/server/src/modules/paypal/utils/provider-ids.js.map +1 -0
  199. package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +38 -0
  200. package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -0
  201. package/.medusa/server/src/modules/paypal/webhook-processor.js +265 -0
  202. package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -0
  203. package/LICENSE +21 -0
  204. package/README.md +67 -0
  205. package/package.json +61 -0
  206. package/postcss.config.cjs +3 -0
  207. package/src/admin/index.ts +7 -0
  208. package/src/admin/routes/settings/paypal/_components/Tabs.tsx +55 -0
  209. package/src/admin/routes/settings/paypal/_components/Toast.tsx +51 -0
  210. package/src/admin/routes/settings/paypal/additional-settings/page.tsx +346 -0
  211. package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +381 -0
  212. package/src/admin/routes/settings/paypal/apple-pay/page.tsx +5 -0
  213. package/src/admin/routes/settings/paypal/audit-logs/page.tsx +131 -0
  214. package/src/admin/routes/settings/paypal/connection/page.tsx +750 -0
  215. package/src/admin/routes/settings/paypal/disputes/page.tsx +259 -0
  216. package/src/admin/routes/settings/paypal/google-pay/page.tsx +5 -0
  217. package/src/admin/routes/settings/paypal/page.tsx +16 -0
  218. package/src/admin/routes/settings/paypal/pay-later-messaging/page.tsx +5 -0
  219. package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +557 -0
  220. package/src/admin/routes/settings/paypal/reconciliation-status/page.tsx +165 -0
  221. package/src/api/admin/payment-collections/[id]/payment-sessions/route.ts +32 -0
  222. package/src/api/admin/paypal/audit-logs/route.ts +13 -0
  223. package/src/api/admin/paypal/disconnect/route.ts +8 -0
  224. package/src/api/admin/paypal/disputes/[id]/route.ts +19 -0
  225. package/src/api/admin/paypal/disputes/route.ts +30 -0
  226. package/src/api/admin/paypal/disputes/summary/route.ts +18 -0
  227. package/src/api/admin/paypal/environment/route.ts +25 -0
  228. package/src/api/admin/paypal/onboard-complete/route.ts +44 -0
  229. package/src/api/admin/paypal/onboarding-link/route.ts +45 -0
  230. package/src/api/admin/paypal/onboarding-status/route.ts +18 -0
  231. package/src/api/admin/paypal/reconciliation-status/route.ts +7 -0
  232. package/src/api/admin/paypal/rotate-credentials/route.ts +8 -0
  233. package/src/api/admin/paypal/save-credentials/route.ts +14 -0
  234. package/src/api/admin/paypal/settings/route.ts +14 -0
  235. package/src/api/admin/paypal/status/route.ts +12 -0
  236. package/src/api/store/payment-collections/[id]/payment-sessions/route.ts +51 -0
  237. package/src/api/store/paypal/capture-order/route.ts +270 -0
  238. package/src/api/store/paypal/config/route.ts +59 -0
  239. package/src/api/store/paypal/create-order/route.ts +374 -0
  240. package/src/api/store/paypal/disputes/route.ts +67 -0
  241. package/src/api/store/paypal/settings/route.ts +12 -0
  242. package/src/api/store/paypal/webhook/route.ts +247 -0
  243. package/src/jobs/paypal-reconcile.ts +135 -0
  244. package/src/jobs/paypal-webhook-retry.ts +86 -0
  245. package/src/modules/paypal/clients/paypal-seller.client.ts +59 -0
  246. package/src/modules/paypal/index.ts +8 -0
  247. package/src/modules/paypal/migrations/20260115120000_create_paypal_connection.ts +33 -0
  248. package/src/modules/paypal/migrations/20260123090000_create_paypal_settings.ts +22 -0
  249. package/src/modules/paypal/migrations/20260201090000_create_paypal_webhook_event.ts +29 -0
  250. package/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.ts +26 -0
  251. package/src/modules/paypal/migrations/20260401090000_create_paypal_metric.ts +27 -0
  252. package/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.ts +40 -0
  253. package/src/modules/paypal/migrations/20260701090000_add_paypal_webhook_event_processing.ts +31 -0
  254. package/src/modules/paypal/models/paypal_audit_log.ts +9 -0
  255. package/src/modules/paypal/models/paypal_connection.ts +21 -0
  256. package/src/modules/paypal/models/paypal_dispute.ts +18 -0
  257. package/src/modules/paypal/models/paypal_metric.ts +9 -0
  258. package/src/modules/paypal/models/paypal_settings.ts +8 -0
  259. package/src/modules/paypal/models/paypal_webhook_event.ts +19 -0
  260. package/src/modules/paypal/payment-provider/README.md +22 -0
  261. package/src/modules/paypal/payment-provider/card-service.ts +710 -0
  262. package/src/modules/paypal/payment-provider/index.ts +19 -0
  263. package/src/modules/paypal/payment-provider/service.ts +1035 -0
  264. package/src/modules/paypal/payment-provider/webhook-utils.ts +88 -0
  265. package/src/modules/paypal/service.ts +1422 -0
  266. package/src/modules/paypal/types/config.ts +47 -0
  267. package/src/modules/paypal/utils/amounts.ts +41 -0
  268. package/src/modules/paypal/utils/crypto.ts +51 -0
  269. package/src/modules/paypal/utils/currencies.ts +84 -0
  270. package/src/modules/paypal/utils/provider-ids.ts +53 -0
  271. package/src/modules/paypal/webhook-processor.ts +313 -0
  272. package/tsconfig.json +31 -0
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POST = POST;
4
+ const crypto_1 = require("crypto");
5
+ const provider_ids_1 = require("../../../../modules/paypal/utils/provider-ids");
6
+ async function getPayPalApiBase(environment) {
7
+ return environment === "live"
8
+ ? "https://api-m.paypal.com"
9
+ : "https://api-m.sandbox.paypal.com";
10
+ }
11
+ async function getPayPalAccessToken(opts) {
12
+ const base = await getPayPalApiBase(opts.environment);
13
+ const auth = Buffer.from(`${opts.client_id}:${opts.client_secret}`).toString("base64");
14
+ const resp = await fetch(`${base}/v1/oauth2/token`, {
15
+ method: "POST",
16
+ headers: {
17
+ Authorization: `Basic ${auth}`,
18
+ "Content-Type": "application/x-www-form-urlencoded",
19
+ },
20
+ body: "grant_type=client_credentials",
21
+ });
22
+ const text = await resp.text();
23
+ if (!resp.ok) {
24
+ throw new Error(`PayPal token error (${resp.status}): ${text}`);
25
+ }
26
+ const json = JSON.parse(text);
27
+ return { accessToken: String(json.access_token), base };
28
+ }
29
+ function resolveIdempotencyKey(req, suffix, fallback) {
30
+ const header = req.headers["idempotency-key"] ||
31
+ req.headers["Idempotency-Key"] ||
32
+ req.headers["x-idempotency-key"] ||
33
+ req.headers["X-Idempotency-Key"];
34
+ const key = Array.isArray(header) ? header[0] : header;
35
+ if (key && String(key).trim()) {
36
+ return `${String(key).trim()}-${suffix}`;
37
+ }
38
+ return fallback || `pp-${suffix}-${(0, crypto_1.randomUUID)()}`;
39
+ }
40
+ async function attachPayPalCaptureToSession(req, cartId, orderId, capture) {
41
+ try {
42
+ const paymentCollectionService = req.scope.resolve("payment_collection");
43
+ const paymentSessionService = req.scope.resolve("payment_session");
44
+ const pc = await paymentCollectionService.retrieveByCartId(cartId).catch(() => null);
45
+ if (!pc?.id) {
46
+ return;
47
+ }
48
+ const sessions = await paymentSessionService.list({ payment_collection_id: pc.id });
49
+ const paypalSession = sessions?.find((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id));
50
+ if (!paypalSession) {
51
+ return;
52
+ }
53
+ await paymentSessionService.update(paypalSession.id, {
54
+ status: "captured",
55
+ data: {
56
+ ...(paypalSession.data || {}),
57
+ paypal: {
58
+ ...((paypalSession.data || {}).paypal || {}),
59
+ order_id: orderId,
60
+ capture_id: capture?.id || capture?.purchase_units?.[0]?.payments?.captures?.[0]?.id,
61
+ capture,
62
+ },
63
+ },
64
+ });
65
+ }
66
+ catch {
67
+ // ignore
68
+ }
69
+ }
70
+ async function attachPayPalAuthorizationToSession(req, cartId, orderId, authorization) {
71
+ try {
72
+ const paymentCollectionService = req.scope.resolve("payment_collection");
73
+ const paymentSessionService = req.scope.resolve("payment_session");
74
+ const pc = await paymentCollectionService.retrieveByCartId(cartId).catch(() => null);
75
+ if (!pc?.id) {
76
+ return;
77
+ }
78
+ const sessions = await paymentSessionService.list({ payment_collection_id: pc.id });
79
+ const paypalSession = sessions?.find((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id));
80
+ if (!paypalSession) {
81
+ return;
82
+ }
83
+ await paymentSessionService.update(paypalSession.id, {
84
+ status: "authorized",
85
+ data: {
86
+ ...(paypalSession.data || {}),
87
+ paypal: {
88
+ ...((paypalSession.data || {}).paypal || {}),
89
+ order_id: orderId,
90
+ authorization_id: authorization?.purchase_units?.[0]?.payments?.authorizations?.[0]?.id,
91
+ authorization,
92
+ },
93
+ },
94
+ });
95
+ }
96
+ catch {
97
+ // ignore
98
+ }
99
+ }
100
+ async function getExistingCapture(req, cartId, orderId) {
101
+ try {
102
+ const paymentCollectionService = req.scope.resolve("payment_collection");
103
+ const paymentSessionService = req.scope.resolve("payment_session");
104
+ const pc = await paymentCollectionService.retrieveByCartId(cartId).catch(() => null);
105
+ if (!pc?.id) {
106
+ return null;
107
+ }
108
+ const sessions = await paymentSessionService.list({ payment_collection_id: pc.id });
109
+ const paypalSession = sessions?.find((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id));
110
+ if (!paypalSession) {
111
+ return null;
112
+ }
113
+ const paypalData = (paypalSession.data || {}).paypal || {};
114
+ const existingOrderId = String(paypalData.order_id || "");
115
+ if (existingOrderId && existingOrderId !== orderId) {
116
+ return null;
117
+ }
118
+ if (paypalData.capture) {
119
+ return paypalData.capture;
120
+ }
121
+ if (paypalData.capture_id) {
122
+ return { id: paypalData.capture_id };
123
+ }
124
+ return null;
125
+ }
126
+ catch {
127
+ return null;
128
+ }
129
+ }
130
+ async function POST(req, res) {
131
+ const paypal = req.scope.resolve("paypal_onboarding");
132
+ let debugId = null;
133
+ try {
134
+ const body = (req.body || {});
135
+ const cartId = body.cart_id;
136
+ const orderId = body.order_id;
137
+ if (!cartId || !orderId) {
138
+ return res.status(400).json({ message: "cart_id and order_id are required" });
139
+ }
140
+ const existingCapture = await getExistingCapture(req, cartId, orderId);
141
+ if (existingCapture) {
142
+ return res.json({ capture: existingCapture });
143
+ }
144
+ const creds = await paypal.getActiveCredentials();
145
+ const { accessToken, base } = await getPayPalAccessToken(creds);
146
+ const settings = await paypal.getSettings().catch(() => ({}));
147
+ const data = settings && typeof settings === "object" && "data" in settings
148
+ ? (settings.data ?? {})
149
+ : {};
150
+ const additionalSettings = (data.additional_settings || {});
151
+ const paymentAction = typeof additionalSettings.paymentAction === "string"
152
+ ? additionalSettings.paymentAction
153
+ : "capture";
154
+ const requestId = resolveIdempotencyKey(req, "capture-order", `pp-capture-${orderId}`);
155
+ const endpoint = paymentAction === "authorize"
156
+ ? `${base}/v2/checkout/orders/${orderId}/authorize`
157
+ : `${base}/v2/checkout/orders/${orderId}/capture`;
158
+ const ppResp = await fetch(endpoint, {
159
+ method: "POST",
160
+ headers: {
161
+ Authorization: `Bearer ${accessToken}`,
162
+ "Content-Type": "application/json",
163
+ "PayPal-Request-Id": requestId,
164
+ },
165
+ });
166
+ const ppText = await ppResp.text();
167
+ debugId = ppResp.headers.get("paypal-debug-id");
168
+ if (!ppResp.ok) {
169
+ throw new Error(`PayPal capture error (${ppResp.status}): ${ppText}${debugId ? ` debug_id=${debugId}` : ""}`);
170
+ }
171
+ const payload = JSON.parse(ppText);
172
+ if (paymentAction === "authorize") {
173
+ await attachPayPalAuthorizationToSession(req, cartId, orderId, payload);
174
+ }
175
+ else {
176
+ await attachPayPalCaptureToSession(req, cartId, orderId, payload);
177
+ }
178
+ console.info("[PayPal] capture-order", {
179
+ cart_id: cartId,
180
+ order_id: orderId,
181
+ request_id: requestId,
182
+ debug_id: ppResp.headers.get("paypal-debug-id"),
183
+ capture_id: payload?.id,
184
+ });
185
+ try {
186
+ await paypal.recordMetric(paymentAction === "authorize" ? "authorize_order_success" : "capture_order_success");
187
+ }
188
+ catch {
189
+ // ignore metrics failures
190
+ }
191
+ // Clear storefront cart cookie (httpOnly) so user gets a fresh cart after successful payment
192
+ // Note: works when storefront and backend share the same cookie domain (e.g. localhost)
193
+ res.setHeader("Set-Cookie", "_medusa_cart_id=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; SameSite=Strict");
194
+ return paymentAction === "authorize"
195
+ ? res.json({ authorization: payload })
196
+ : res.json({ capture: payload });
197
+ }
198
+ catch (e) {
199
+ try {
200
+ const body = (req.body || {});
201
+ await paypal.recordAuditEvent("capture_order_failed", {
202
+ cart_id: body.cart_id,
203
+ order_id: body.order_id,
204
+ debug_id: debugId,
205
+ message: e?.message || String(e),
206
+ });
207
+ await paypal.recordMetric("capture_order_failed");
208
+ }
209
+ catch {
210
+ // ignore audit logging failures
211
+ }
212
+ return res.status(500).json({ message: e?.message || "Failed to capture PayPal order" });
213
+ }
214
+ }
215
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/capture-order/route.ts"],"names":[],"mappings":";;AAyKA,oBAoGC;AA5QD,mCAAmC;AAEnC,gFAAkF;AAOlF,KAAK,UAAU,gBAAgB,CAAC,WAAmB;IACjD,OAAO,WAAW,KAAK,MAAM;QAC3B,CAAC,CAAC,0BAA0B;QAC5B,CAAC,CAAC,kCAAkC,CAAA;AACxC,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,IAInC;IACC,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACrD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAEtF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,kBAAkB,EAAE;QAClD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,SAAS,IAAI,EAAE;YAC9B,cAAc,EAAE,mCAAmC;SACpD;QACD,IAAI,EAAE,+BAA+B;KACtC,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAA;IACjE,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,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Request, MedusaResponse } from "@medusajs/framework/http";
2
+ export declare function GET(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
3
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/config/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAQ7E,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAkDhE"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET = GET;
4
+ const currencies_1 = require("../../../../modules/paypal/utils/currencies");
5
+ async function GET(req, res) {
6
+ const paypal = req.scope.resolve("paypal_onboarding");
7
+ try {
8
+ const creds = await paypal.getActiveCredentials();
9
+ const apiDetails = await paypal.getApiDetails().catch(() => null);
10
+ // CardFields/PaymentFields require a client token on the script tag.
11
+ // Generate it server-side and return it with config.
12
+ const client_token = await paypal.generateClientToken({ locale: "en_US" }).catch(() => "");
13
+ const cartId = req.query?.cart_id || "";
14
+ const query = req.scope.resolve("query");
15
+ let currency = (0, currencies_1.normalizeCurrencyCode)(apiDetails?.apiDetails?.currency_code || process.env.PAYPAL_CURRENCY || "USD");
16
+ if (cartId) {
17
+ const { data: carts } = await query.graph({
18
+ entity: "cart",
19
+ fields: ["id", "currency_code", "region.currency_code"],
20
+ filters: { id: cartId },
21
+ });
22
+ const cart = carts?.[0];
23
+ if (cart) {
24
+ currency = (0, currencies_1.normalizeCurrencyCode)(cart.region?.currency_code || cart.currency_code || currency);
25
+ }
26
+ }
27
+ const compatibility = (0, currencies_1.getPayPalCurrencyCompatibility)({
28
+ currencyCode: currency,
29
+ paypalCurrencyOverride: apiDetails?.apiDetails?.currency_code || process.env.PAYPAL_CURRENCY,
30
+ });
31
+ return res.json({
32
+ environment: creds.environment,
33
+ client_id: creds.client_id,
34
+ currency: compatibility.currency,
35
+ currency_supported: compatibility.supported,
36
+ currency_errors: compatibility.errors,
37
+ supported_currencies: (0, currencies_1.getPayPalSupportedCurrencies)(),
38
+ client_token,
39
+ });
40
+ }
41
+ catch (e) {
42
+ return res.status(500).json({ message: e?.message || "Failed to load PayPal config" });
43
+ }
44
+ }
45
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/config/route.ts"],"names":[],"mappings":";;AAQA,kBAkDC;AAxDD,4EAIoD;AAE7C,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAsB,mBAAmB,CAAC,CAAA;IAE1E,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,oBAAoB,EAAE,CAAA;QACjD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;QAEjE,qEAAqE;QACrE,qDAAqD;QACrD,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QAE1F,MAAM,MAAM,GAAI,GAAG,CAAC,KAAK,EAAE,OAAkB,IAAI,EAAE,CAAA;QACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAExC,IAAI,QAAQ,GAAG,IAAA,kCAAqB,EAClC,UAAU,EAAE,UAAU,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,KAAK,CAC9E,CAAA;QACD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC;gBACxC,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,sBAAsB,CAAC;gBACvD,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;aACxB,CAAC,CAAA;YAEF,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;YACvB,IAAI,IAAI,EAAE,CAAC;gBACT,QAAQ,GAAG,IAAA,kCAAqB,EAC9B,IAAI,CAAC,MAAM,EAAE,aAAa,IAAI,IAAI,CAAC,aAAa,IAAI,QAAQ,CAC7D,CAAA;YACH,CAAC;QACH,CAAC;QAED,MAAM,aAAa,GAAG,IAAA,2CAA8B,EAAC;YACnD,YAAY,EAAE,QAAQ;YACtB,sBAAsB,EACpB,UAAU,EAAE,UAAU,EAAE,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;SACvE,CAAC,CAAA;QAEF,OAAO,GAAG,CAAC,IAAI,CAAC;YACd,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,kBAAkB,EAAE,aAAa,CAAC,SAAS;YAC3C,eAAe,EAAE,aAAa,CAAC,MAAM;YACrC,oBAAoB,EAAE,IAAA,yCAA4B,GAAE;YACpD,YAAY;SACb,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,IAAI,8BAA8B,EAAE,CAAC,CAAA;IACxF,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
2
+ export declare function POST(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
3
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/create-order/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAoI7E,wBAAsB,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAiPjE"}
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.POST = POST;
4
+ const crypto_1 = require("crypto");
5
+ const amounts_1 = require("../../../../modules/paypal/utils/amounts");
6
+ const currencies_1 = require("../../../../modules/paypal/utils/currencies");
7
+ const provider_ids_1 = require("../../../../modules/paypal/utils/provider-ids");
8
+ async function getPayPalApiBase(environment) {
9
+ return environment === "live"
10
+ ? "https://api-m.paypal.com"
11
+ : "https://api-m.sandbox.paypal.com";
12
+ }
13
+ async function getPayPalAccessToken(opts) {
14
+ const base = await getPayPalApiBase(opts.environment);
15
+ const auth = Buffer.from(`${opts.client_id}:${opts.client_secret}`).toString("base64");
16
+ const resp = await fetch(`${base}/v1/oauth2/token`, {
17
+ method: "POST",
18
+ headers: {
19
+ Authorization: `Basic ${auth}`,
20
+ "Content-Type": "application/x-www-form-urlencoded",
21
+ },
22
+ body: "grant_type=client_credentials",
23
+ });
24
+ const text = await resp.text();
25
+ if (!resp.ok) {
26
+ throw new Error(`PayPal token error (${resp.status}): ${text}`);
27
+ }
28
+ const json = JSON.parse(text);
29
+ return { accessToken: String(json.access_token), base };
30
+ }
31
+ function resolveIdempotencyKey(req, suffix, fallback) {
32
+ const header = req.headers["idempotency-key"] ||
33
+ req.headers["Idempotency-Key"] ||
34
+ req.headers["x-idempotency-key"] ||
35
+ req.headers["X-Idempotency-Key"];
36
+ const key = Array.isArray(header) ? header[0] : header;
37
+ if (key && String(key).trim()) {
38
+ return `${String(key).trim()}-${suffix}`;
39
+ }
40
+ return fallback || `pp-${suffix}-${(0, crypto_1.randomUUID)()}`;
41
+ }
42
+ async function attachPayPalOrderToSession(req, cartId, orderId) {
43
+ try {
44
+ const paymentCollectionService = req.scope.resolve("payment_collection");
45
+ const paymentSessionService = req.scope.resolve("payment_session");
46
+ const pc = await paymentCollectionService.retrieveByCartId(cartId).catch(() => null);
47
+ if (!pc?.id) {
48
+ return;
49
+ }
50
+ const sessions = await paymentSessionService.list({ payment_collection_id: pc.id });
51
+ const paypalSession = sessions?.find((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id));
52
+ if (!paypalSession) {
53
+ return;
54
+ }
55
+ await paymentSessionService.update(paypalSession.id, {
56
+ data: {
57
+ ...(paypalSession.data || {}),
58
+ paypal: {
59
+ ...((paypalSession.data || {}).paypal || {}),
60
+ order_id: orderId,
61
+ },
62
+ },
63
+ });
64
+ }
65
+ catch {
66
+ // ignore best-effort session update
67
+ }
68
+ }
69
+ async function getExistingPayPalOrderId(req, cartId) {
70
+ try {
71
+ const paymentCollectionService = req.scope.resolve("payment_collection");
72
+ const paymentSessionService = req.scope.resolve("payment_session");
73
+ const pc = await paymentCollectionService.retrieveByCartId(cartId).catch(() => null);
74
+ if (!pc?.id) {
75
+ return null;
76
+ }
77
+ const sessions = await paymentSessionService.list({ payment_collection_id: pc.id });
78
+ const paypalSession = sessions?.find((s) => (0, provider_ids_1.isPayPalProviderId)(s.provider_id));
79
+ if (!paypalSession) {
80
+ return null;
81
+ }
82
+ const paypalData = (paypalSession.data || {}).paypal || {};
83
+ return paypalData.order_id ? String(paypalData.order_id) : null;
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
89
+ function resolveReturnUrl(req) {
90
+ const configured = process.env.STOREFRONT_URL || process.env.STORE_URL;
91
+ if (!configured) {
92
+ return undefined;
93
+ }
94
+ return `${configured.replace(/\/$/, "")}/checkout`;
95
+ }
96
+ function resolveCancelUrl(req) {
97
+ const configured = process.env.STOREFRONT_URL || process.env.STORE_URL;
98
+ if (!configured) {
99
+ return undefined;
100
+ }
101
+ return `${configured.replace(/\/$/, "")}/cart`;
102
+ }
103
+ async function POST(req, res) {
104
+ const paypal = req.scope.resolve("paypal_onboarding");
105
+ let debugId = null;
106
+ try {
107
+ const body = (req.body || {});
108
+ const cartId = body.cart_id;
109
+ if (!cartId) {
110
+ return res.status(400).json({ message: "cart_id is required" });
111
+ }
112
+ const existingOrderId = await getExistingPayPalOrderId(req, cartId);
113
+ if (existingOrderId) {
114
+ return res.json({ id: existingOrderId });
115
+ }
116
+ /**
117
+ * ✅ Medusa v2 cart retrieval via Query Graph
118
+ */
119
+ const query = req.scope.resolve("query");
120
+ const { data } = await query.graph({
121
+ entity: "cart",
122
+ fields: [
123
+ "id",
124
+ "total",
125
+ "subtotal",
126
+ "shipping_total",
127
+ "tax_total",
128
+ "discount_total",
129
+ "gift_card_total",
130
+ "currency_code",
131
+ "region.currency_code",
132
+ ],
133
+ filters: { id: cartId },
134
+ });
135
+ const cart = data?.[0] || null;
136
+ if (!cart) {
137
+ return res.status(404).json({ message: "Cart not found" });
138
+ }
139
+ const creds = await paypal.getActiveCredentials();
140
+ const settings = await paypal
141
+ .getSettings()
142
+ .catch(() => ({}));
143
+ const additionalSettings = settings.data?.additional_settings || {};
144
+ const apiDetails = settings.data?.api_details || {};
145
+ const configuredCurrency = typeof apiDetails.currency_code === "string"
146
+ ? (0, currencies_1.normalizeCurrencyCode)(apiDetails.currency_code)
147
+ : (0, currencies_1.normalizeCurrencyCode)(process.env.PAYPAL_CURRENCY || "USD");
148
+ const currency = (0, currencies_1.normalizeCurrencyCode)(cart.region?.currency_code || cart.currency_code || configuredCurrency);
149
+ (0, currencies_1.assertPayPalCurrencySupported)({
150
+ currencyCode: currency,
151
+ paypalCurrencyOverride: configuredCurrency,
152
+ });
153
+ const totalMinor = Number(cart.total || 0);
154
+ const value = (0, amounts_1.formatAmountForPayPal)(totalMinor, currency);
155
+ const paymentActionRaw = typeof additionalSettings.paymentAction === "string"
156
+ ? additionalSettings.paymentAction
157
+ : "capture";
158
+ const paymentAction = paymentActionRaw === "authorize" ? "AUTHORIZE" : "CAPTURE";
159
+ const brandName = typeof additionalSettings.brandName === "string"
160
+ ? additionalSettings.brandName
161
+ : undefined;
162
+ const landingPageRaw = typeof additionalSettings.landingPage === "string"
163
+ ? additionalSettings.landingPage
164
+ : undefined;
165
+ const landingPage = landingPageRaw === "login"
166
+ ? "LOGIN"
167
+ : landingPageRaw === "billing"
168
+ ? "BILLING"
169
+ : landingPageRaw === "no_preference"
170
+ ? "NO_PREFERENCE"
171
+ : undefined;
172
+ const skipReview = typeof additionalSettings.skipOrderReviewPage === "boolean"
173
+ ? additionalSettings.skipOrderReviewPage
174
+ : undefined;
175
+ const requireInstantPayment = typeof additionalSettings.requireInstantPayment === "boolean"
176
+ ? additionalSettings.requireInstantPayment
177
+ : undefined;
178
+ const invoicePrefix = typeof additionalSettings.invoicePrefix === "string"
179
+ ? additionalSettings.invoicePrefix
180
+ : "";
181
+ const invoiceId = `${invoicePrefix}${cart.id}`.trim() || cart.id;
182
+ const returnUrl = (typeof apiDetails.storefront_url === "string" && apiDetails.storefront_url.trim()
183
+ ? `${apiDetails.storefront_url.replace(/\/$/, "")}/checkout`
184
+ : resolveReturnUrl(req));
185
+ const cancelUrl = (typeof apiDetails.storefront_url === "string" && apiDetails.storefront_url.trim()
186
+ ? `${apiDetails.storefront_url.replace(/\/$/, "")}/cart`
187
+ : resolveCancelUrl(req));
188
+ const applicationContext = {
189
+ ...(brandName ? { brand_name: brandName } : {}),
190
+ ...(landingPage ? { landing_page: landingPage } : {}),
191
+ ...(typeof skipReview === "boolean"
192
+ ? { user_action: skipReview ? "PAY_NOW" : "CONTINUE" }
193
+ : {}),
194
+ ...(requireInstantPayment ? { payment_method_preference: "IMMEDIATE_PAYMENT_REQUIRED" } : {}),
195
+ ...(returnUrl ? { return_url: returnUrl } : {}),
196
+ ...(cancelUrl ? { cancel_url: cancelUrl } : {}),
197
+ };
198
+ const breakdown = {};
199
+ const subtotalMinor = Number(cart.subtotal || 0);
200
+ const shippingMinor = Number(cart.shipping_total || 0);
201
+ const taxMinor = Number(cart.tax_total || 0);
202
+ const discountMinor = Number(cart.discount_total || 0);
203
+ const giftCardMinor = Number(cart.gift_card_total || 0);
204
+ const adjustmentMinor = Math.max(0, subtotalMinor + shippingMinor + taxMinor - totalMinor);
205
+ if (subtotalMinor > 0) {
206
+ breakdown.item_total = {
207
+ currency_code: currency,
208
+ value: (0, amounts_1.formatAmountForPayPal)(subtotalMinor, currency),
209
+ };
210
+ }
211
+ if (shippingMinor > 0) {
212
+ breakdown.shipping = {
213
+ currency_code: currency,
214
+ value: (0, amounts_1.formatAmountForPayPal)(shippingMinor, currency),
215
+ };
216
+ }
217
+ if (taxMinor > 0) {
218
+ breakdown.tax_total = {
219
+ currency_code: currency,
220
+ value: (0, amounts_1.formatAmountForPayPal)(taxMinor, currency),
221
+ };
222
+ }
223
+ const discountValue = Math.max(0, discountMinor + giftCardMinor, adjustmentMinor);
224
+ if (discountValue > 0) {
225
+ breakdown.discount = {
226
+ currency_code: currency,
227
+ value: (0, amounts_1.formatAmountForPayPal)(discountValue, currency),
228
+ };
229
+ }
230
+ const { accessToken, base } = await getPayPalAccessToken({
231
+ environment: creds.environment,
232
+ client_id: creds.client_id,
233
+ client_secret: creds.client_secret,
234
+ });
235
+ const requestId = resolveIdempotencyKey(req, "create-order", `pp-create-${cart.id}`);
236
+ const ppResp = await fetch(`${base}/v2/checkout/orders`, {
237
+ method: "POST",
238
+ headers: {
239
+ Authorization: `Bearer ${accessToken}`,
240
+ "Content-Type": "application/json",
241
+ "PayPal-Request-Id": requestId,
242
+ },
243
+ body: JSON.stringify({
244
+ intent: paymentAction,
245
+ purchase_units: [
246
+ {
247
+ reference_id: cart.id,
248
+ invoice_id: invoiceId,
249
+ amount: {
250
+ currency_code: currency,
251
+ value,
252
+ ...(Object.keys(breakdown).length > 0 ? { breakdown } : {}),
253
+ },
254
+ },
255
+ ],
256
+ custom_id: cart.id,
257
+ ...(Object.keys(applicationContext).length > 0
258
+ ? { application_context: applicationContext }
259
+ : {}),
260
+ }),
261
+ });
262
+ const ppText = await ppResp.text();
263
+ debugId = ppResp.headers.get("paypal-debug-id");
264
+ if (!ppResp.ok) {
265
+ throw new Error(`PayPal create order error (${ppResp.status}): ${ppText}${debugId ? ` debug_id=${debugId}` : ""}`);
266
+ }
267
+ const order = JSON.parse(ppText);
268
+ await attachPayPalOrderToSession(req, cart.id, order.id);
269
+ console.info("[PayPal] create-order", {
270
+ cart_id: cart.id,
271
+ order_id: order.id,
272
+ request_id: requestId,
273
+ debug_id: ppResp.headers.get("paypal-debug-id"),
274
+ });
275
+ try {
276
+ await paypal.recordMetric("create_order_success");
277
+ }
278
+ catch {
279
+ // ignore metrics failures
280
+ }
281
+ return res.json({ id: order.id });
282
+ }
283
+ catch (e) {
284
+ try {
285
+ const body = (req.body || {});
286
+ await paypal.recordAuditEvent("create_order_failed", {
287
+ cart_id: body.cart_id,
288
+ debug_id: debugId,
289
+ message: e?.message || String(e),
290
+ });
291
+ await paypal.recordMetric("create_order_failed");
292
+ }
293
+ catch {
294
+ // ignore audit logging failures
295
+ }
296
+ const message = e?.message || "Failed to create PayPal order";
297
+ const status = message.includes("PayPal does not support currency")
298
+ ? 400
299
+ : message.includes("PayPal is configured for")
300
+ ? 400
301
+ : 500;
302
+ return res.status(status).json({ message });
303
+ }
304
+ }
305
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/create-order/route.ts"],"names":[],"mappings":";;AAoIA,oBAiPC;AApXD,mCAAmC;AACnC,sEAAgF;AAChF,4EAGoD;AAEpD,gFAAkF;AAMlF,KAAK,UAAU,gBAAgB,CAAC,WAAmB;IACjD,OAAO,WAAW,KAAK,MAAM;QAC3B,CAAC,CAAC,0BAA0B;QAC5B,CAAC,CAAC,kCAAkC,CAAA;AACxC,CAAC;AAED,KAA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C;YACP,0BAA0B;QAC5B,CAAC;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IACnC,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAS,CAAA;YACrC,MAAM,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,EAAE;gBACnD,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,CAAC,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC;aACjC,CAAC,CAAA;YACF,MAAM,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAA;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,gCAAgC;QAClC,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,+BAA+B,CAAA;QAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAC;YACjE,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC;gBAC5C,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,GAAG,CAAA;QACT,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
2
+ export declare function GET(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
3
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/store/paypal/disputes/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAqC7E,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BA6BhE"}