@easypayment/medusa-payment-paypal 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.medusa/server/src/admin/index.js +7 -7
  2. package/.medusa/server/src/admin/index.mjs +7 -7
  3. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
  4. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js +6 -1
  5. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js.map +1 -1
  6. package/.medusa/server/src/api/store/paypal/create-order/route.d.ts.map +1 -1
  7. package/.medusa/server/src/api/store/paypal/create-order/route.js +26 -6
  8. package/.medusa/server/src/api/store/paypal/create-order/route.js.map +1 -1
  9. package/.medusa/server/src/api/store/paypal-complete/route.d.ts.map +1 -1
  10. package/.medusa/server/src/api/store/paypal-complete/route.js +22 -2
  11. package/.medusa/server/src/api/store/paypal-complete/route.js.map +1 -1
  12. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts +24 -1
  13. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts.map +1 -1
  14. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js +296 -0
  15. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.js.map +1 -1
  16. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts +1 -2
  17. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
  18. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +3 -184
  19. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
  20. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts +1 -2
  21. package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
  22. package/.medusa/server/src/modules/paypal/payment-provider/service.js +3 -182
  23. package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
  24. package/.medusa/server/src/modules/paypal/payment-provider/status-utils.d.ts +21 -0
  25. package/.medusa/server/src/modules/paypal/payment-provider/status-utils.d.ts.map +1 -1
  26. package/.medusa/server/src/modules/paypal/payment-provider/status-utils.js +54 -0
  27. package/.medusa/server/src/modules/paypal/payment-provider/status-utils.js.map +1 -1
  28. package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts +10 -0
  29. package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts.map +1 -1
  30. package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +42 -0
  31. package/.medusa/server/src/modules/paypal/utils/credential-resolver.js.map +1 -1
  32. package/CHANGELOG.md +54 -0
  33. package/package.json +1 -1
  34. package/src/api/store/payment-collections/[id]/payment-sessions/route.ts +7 -1
  35. package/src/api/store/paypal/create-order/route.ts +31 -6
  36. package/src/api/store/paypal-complete/route.ts +30 -3
  37. package/src/modules/paypal/payment-provider/base-provider.ts +417 -4
  38. package/src/modules/paypal/payment-provider/card-service.ts +4 -238
  39. package/src/modules/paypal/payment-provider/service.ts +4 -237
  40. package/src/modules/paypal/payment-provider/status-utils.ts +57 -0
  41. package/src/modules/paypal/utils/credential-resolver.ts +40 -0
@@ -10,6 +10,29 @@ const partner_1 = require("../utils/partner");
10
10
  const paypal_fetch_1 = require("../utils/paypal-fetch");
11
11
  const webhook_utils_1 = require("./webhook-utils");
12
12
  const status_utils_1 = require("./status-utils");
13
+ function toStoredCaptureEntry(capture) {
14
+ return {
15
+ id: capture?.id,
16
+ status: capture?.status,
17
+ amount: capture?.amount,
18
+ final_capture: capture?.final_capture,
19
+ raw: capture,
20
+ };
21
+ }
22
+ /** Merge capture entries by id — a later entry for the same id wins. */
23
+ function mergeCaptureEntries(...lists) {
24
+ const byId = new Map();
25
+ const anonymous = [];
26
+ for (const list of lists) {
27
+ for (const entry of list || []) {
28
+ if (entry?.id)
29
+ byId.set(String(entry.id), entry);
30
+ else if (entry)
31
+ anonymous.push(entry);
32
+ }
33
+ }
34
+ return [...byId.values(), ...anonymous];
35
+ }
13
36
  /**
14
37
  * Shared base for the two PayPal payment providers (wallet buttons and advanced
15
38
  * card fields). Both providers ran nearly identical credential/token handling,
@@ -208,6 +231,279 @@ class PayPalProviderBase extends utils_1.AbstractPaymentProvider {
208
231
  return "error";
209
232
  return "pending";
210
233
  }
234
+ /**
235
+ * Capture funds for a session — one PayPal capture per Medusa capture row.
236
+ *
237
+ * Medusa calls this once per admin capture (full or partial) with the
238
+ * requested amount living on the Medusa capture row (see
239
+ * `resolveRequestedCaptureAmount`). The decision to call PayPal is driven by
240
+ * what PayPal already holds for the order, NOT by whether the session happens
241
+ * to carry a `capture_id`: after a first partial capture the session always
242
+ * has one, and short-circuiting on it silently skipped every later capture
243
+ * (Medusa recorded the money, PayPal never took it).
244
+ *
245
+ * - Order already fully captured at PayPal → idempotent success with the
246
+ * latest COMPLETED capture (a retry after a crash between the PayPal call
247
+ * and the session write, or a storefront capture-order that Medusa never
248
+ * saw). If everything it holds is still PENDING, fail — funds in flight
249
+ * are not settled money.
250
+ * - Otherwise capture exactly the requested amount; refuse (rather than
251
+ * silently clamp) if more than what remains capturable is requested, since
252
+ * Medusa records the requested amount regardless of what is returned.
253
+ * - The last capture that exhausts the session amount closes the
254
+ * authorization (`final_capture`), unless the session says otherwise.
255
+ */
256
+ async capturePayment(input) {
257
+ const data = (input.data || {});
258
+ const paypalData = (data.paypal || {});
259
+ const orderId = String(paypalData.order_id || data.order_id || "");
260
+ let authorizationId = String(paypalData.authorization_id || data.authorization_id || "");
261
+ if (!orderId) {
262
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "PayPal order_id is required to capture payment");
263
+ }
264
+ const { amount: sessionAmount, currencyCode } = await this.normalizePaymentData(input);
265
+ const exponent = (0, amounts_1.getCurrencyExponent)(currencyCode);
266
+ const roundMoney = (value) => Number(value.toFixed(exponent));
267
+ // The requested (possibly partial) capture amount lives on the Medusa
268
+ // capture row, not in the provider input — resolve it so partial captures
269
+ // don't charge the full session total.
270
+ const amount = await this.resolveRequestedCaptureAmount(input, sessionAmount);
271
+ // Include the amount in the idempotency suffix: PayPal deduplicates by
272
+ // PayPal-Request-Id, so two sequential partial captures of the same order
273
+ // that share an upstream idempotency_key would otherwise collide and the
274
+ // second capture would silently return the first one's result.
275
+ const requestId = this.getIdempotencyKey(input, `capture-${orderId}-${amount}`);
276
+ let debugId = null;
277
+ const storedCaptures = Array.isArray(paypalData.captures)
278
+ ? paypalData.captures
279
+ : [];
280
+ const successResult = (capture, liveCaptures, newEntry) => {
281
+ const captureId = capture?.id || capture?.purchase_units?.[0]?.payments?.captures?.[0]?.id;
282
+ return {
283
+ data: {
284
+ ...(input.data || {}),
285
+ paypal: {
286
+ ...paypalData,
287
+ order_id: orderId,
288
+ capture_id: captureId,
289
+ capture,
290
+ authorization_id: authorizationId || paypalData.authorization_id,
291
+ captures: mergeCaptureEntries(storedCaptures, liveCaptures.map(toStoredCaptureEntry), newEntry ? [newEntry] : undefined),
292
+ },
293
+ captured_at: new Date().toISOString(),
294
+ },
295
+ };
296
+ };
297
+ try {
298
+ const { accessToken, base } = await this.getPayPalAccessToken();
299
+ const order = await this.getOrderDetails(orderId).catch(() => null);
300
+ const liveCaptures = order?.purchase_units?.[0]?.payments?.captures ?? [];
301
+ if (order) {
302
+ // What PayPal has already taken (or reserved) for this order, and how
303
+ // much of it is settled.
304
+ const alreadyCaptured = roundMoney((0, status_utils_1.sumCountedCaptureAmounts)(liveCaptures));
305
+ const settled = roundMoney((0, status_utils_1.sumSettledCaptureAmounts)(liveCaptures));
306
+ const remaining = roundMoney(sessionAmount - alreadyCaptured);
307
+ const requested = roundMoney(amount);
308
+ // Reconcile against Medusa's own ledger. Medusa creates the capture row
309
+ // BEFORE calling us and deletes it when the call (or its follow-up
310
+ // write) fails, so a retry arrives with a fresh row and a fresh
311
+ // PayPal-Request-Id. Whatever PayPal holds beyond the captures Medusa
312
+ // has booked on this payment is therefore a capture Medusa lost —
313
+ // that money IS this capture, and must not be taken from the buyer a
314
+ // second time. (Also covers a storefront capture-order the session
315
+ // never recorded.) Falls through to the amount-based checks below when
316
+ // the ledger can't be read.
317
+ const captureRowId = input?.context?.idempotency_key?.trim() || "";
318
+ const booked = captureRowId
319
+ ? await this.paypal.getBookedCaptureTotal(captureRowId)
320
+ : null;
321
+ const unbookedHeld = booked === null ? 0 : roundMoney(alreadyCaptured - booked);
322
+ const unbookedSettled = booked === null ? 0 : roundMoney(settled - booked);
323
+ const pickCompletedCapture = () => [...liveCaptures]
324
+ .reverse()
325
+ .find((c) => (0, status_utils_1.isCaptureCompleted)(c) &&
326
+ roundMoney(Number(c?.amount?.value)) === requested) ?? [...liveCaptures].reverse().find((c) => (0, status_utils_1.isCaptureCompleted)(c));
327
+ if (booked !== null && unbookedHeld >= requested && requested > 0) {
328
+ const completed = pickCompletedCapture();
329
+ if (!completed || unbookedSettled < requested) {
330
+ // The unbooked money is still PENDING (eCheck / review): not
331
+ // settled, so it can't be booked yet — the CAPTURE.COMPLETED
332
+ // webhook settles it later.
333
+ throw new Error(`PayPal already holds ${(0, amounts_1.formatAmountForPayPal)(unbookedHeld, currencyCode)} ${currencyCode} for order ${orderId} that Medusa has not booked, ` +
334
+ `but only ${(0, amounts_1.formatAmountForPayPal)(unbookedSettled, currencyCode)} of it has COMPLETED (statuses: ${liveCaptures.map((c) => c?.status).join(", ") || "none"}). The payment was not recorded as captured.`);
335
+ }
336
+ console.info(`[PayPal] capturePayment: order ${orderId} already holds ${unbookedHeld} ${currencyCode} not booked in Medusa (PayPal ${alreadyCaptured}, Medusa ${booked}); returning capture ${completed.id} instead of capturing again`);
337
+ return successResult(completed, liveCaptures);
338
+ }
339
+ if (remaining <= 0) {
340
+ // Nothing left to capture at PayPal. Only settled money may be
341
+ // booked: a PENDING capture that fills the remainder is not
342
+ // captured yet.
343
+ const completed = pickCompletedCapture();
344
+ if (!completed || settled < roundMoney(sessionAmount)) {
345
+ throw new Error(`PayPal already holds captures covering the full amount for order ${orderId}, ` +
346
+ `but only ${(0, amounts_1.formatAmountForPayPal)(settled, currencyCode)} ${currencyCode} has COMPLETED (statuses: ${liveCaptures.map((c) => c?.status).join(", ") || "none"}). The payment was not recorded as captured.`);
347
+ }
348
+ console.info(`[PayPal] capturePayment: order ${orderId} is already fully captured at PayPal (${alreadyCaptured} ${currencyCode}); returning capture ${completed.id}`);
349
+ return successResult(completed, liveCaptures);
350
+ }
351
+ if (requested > remaining) {
352
+ throw new Error(`PayPal can only capture ${(0, amounts_1.formatAmountForPayPal)(remaining, currencyCode)} ${currencyCode} more for order ${orderId} ` +
353
+ `(${(0, amounts_1.formatAmountForPayPal)(alreadyCaptured, currencyCode)} of ${(0, amounts_1.formatAmountForPayPal)(sessionAmount, currencyCode)} already captured); ` +
354
+ `${(0, amounts_1.formatAmountForPayPal)(amount, currencyCode)} was requested.`);
355
+ }
356
+ }
357
+ else {
358
+ // PayPal unreachable for the order lookup: the only safe short-circuit
359
+ // is a stored capture that demonstrably COMPLETED for the full session
360
+ // amount. Anything else proceeds to the capture call below, where the
361
+ // PayPal-Request-Id keeps a retry idempotent and PayPal itself rejects
362
+ // an over-capture.
363
+ const stored = paypalData.capture;
364
+ const storedAmount = Number(stored?.amount?.value ??
365
+ stored?.purchase_units?.[0]?.payments?.captures?.[0]?.amount?.value);
366
+ if (stored &&
367
+ (0, status_utils_1.isCaptureCompleted)(stored) &&
368
+ Number.isFinite(storedAmount) &&
369
+ roundMoney(storedAmount) >= roundMoney(sessionAmount)) {
370
+ return successResult(stored, []);
371
+ }
372
+ }
373
+ const resolvedIntent = String(order?.intent || paypalData.order?.intent || data.intent || "").toUpperCase();
374
+ if (!authorizationId && resolvedIntent === "AUTHORIZE") {
375
+ const liveAuthorizationId = order?.purchase_units?.[0]?.payments?.authorizations?.[0]?.id;
376
+ if (liveAuthorizationId) {
377
+ authorizationId = String(liveAuthorizationId);
378
+ }
379
+ else {
380
+ const authorizeResp = await (0, paypal_fetch_1.paypalFetch)(`${base}/v2/checkout/orders/${encodeURIComponent(orderId)}/authorize`, {
381
+ method: "POST",
382
+ headers: {
383
+ Authorization: `Bearer ${accessToken}`,
384
+ "Content-Type": "application/json",
385
+ "PayPal-Request-Id": `${requestId}-auth`,
386
+ "PayPal-Partner-Attribution-Id": partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID,
387
+ },
388
+ });
389
+ const authorizeText = await authorizeResp.text();
390
+ debugId = authorizeResp.headers.get("paypal-debug-id");
391
+ if (!authorizeResp.ok) {
392
+ throw new Error(`PayPal authorize order error (${authorizeResp.status}): ${authorizeText}${debugId ? ` debug_id=${debugId}` : ""}`);
393
+ }
394
+ const authorization = JSON.parse(authorizeText);
395
+ authorizationId =
396
+ authorization?.purchase_units?.[0]?.payments?.authorizations?.[0]
397
+ ?.id;
398
+ }
399
+ }
400
+ const explicitFinalCapture = paypalData.is_final_capture ??
401
+ data.is_final_capture ??
402
+ data.final_capture ??
403
+ undefined;
404
+ const captureValue = amount > 0 ? (0, amounts_1.formatAmountForPayPal)(amount, currencyCode) : null;
405
+ // `amount` and `final_capture` are only honored on the authorizations
406
+ // capture endpoint. The orders capture endpoint always captures the FULL
407
+ // order and silently ignores an `amount` body — so a partial amount there
408
+ // would over-capture while we record the smaller requested value. Route
409
+ // partial captures through the authorization, and fail closed if a
410
+ // partial capture is attempted against a capture-intent order.
411
+ let capturePayload;
412
+ let captureUrl;
413
+ if (authorizationId) {
414
+ captureUrl = `${base}/v2/payments/authorizations/${encodeURIComponent(authorizationId)}/capture`;
415
+ // Close the authorization once the session amount is exhausted, unless
416
+ // the session explicitly says otherwise.
417
+ const finalCapture = typeof explicitFinalCapture === "boolean"
418
+ ? explicitFinalCapture
419
+ : order
420
+ ? roundMoney((0, status_utils_1.sumCountedCaptureAmounts)(liveCaptures) + amount) >=
421
+ roundMoney(sessionAmount)
422
+ : undefined;
423
+ capturePayload = {
424
+ ...(captureValue
425
+ ? { amount: { currency_code: currencyCode, value: captureValue } }
426
+ : {}),
427
+ ...(typeof finalCapture === "boolean"
428
+ ? { final_capture: finalCapture }
429
+ : {}),
430
+ };
431
+ }
432
+ else {
433
+ captureUrl = `${base}/v2/checkout/orders/${encodeURIComponent(orderId)}/capture`;
434
+ capturePayload = {};
435
+ const orderTotal = order?.purchase_units?.[0]?.amount?.value;
436
+ if (captureValue && orderTotal && captureValue !== String(orderTotal)) {
437
+ throw new Error(`PayPal partial capture (${captureValue} ${currencyCode}) is not supported for ` +
438
+ `capture-intent orders (order total ${orderTotal}). Create the order with intent ` +
439
+ `AUTHORIZE to capture a partial amount.`);
440
+ }
441
+ }
442
+ // Retry transient 5xx/429/timeout: the PayPal-Request-Id makes the
443
+ // capture idempotent, so a retry after a network blip re-uses the same
444
+ // capture instead of double-charging. `Prefer: return=representation`
445
+ // asks for the full capture resource (amount, final_capture, …) instead
446
+ // of the default id/status/links stub, so the session keeps a usable
447
+ // record of every capture.
448
+ const ppResp = await (0, paypal_fetch_1.paypalFetchWithRetry)(captureUrl, {
449
+ method: "POST",
450
+ headers: {
451
+ Authorization: `Bearer ${accessToken}`,
452
+ "Content-Type": "application/json",
453
+ Prefer: "return=representation",
454
+ "PayPal-Request-Id": requestId,
455
+ "PayPal-Partner-Attribution-Id": partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID,
456
+ },
457
+ body: JSON.stringify(capturePayload),
458
+ });
459
+ const ppText = await ppResp.text();
460
+ debugId = ppResp.headers.get("paypal-debug-id");
461
+ if (!ppResp.ok) {
462
+ throw new Error(`PayPal capture error (${ppResp.status}): ${ppText}${debugId ? ` debug_id=${debugId}` : ""}`);
463
+ }
464
+ const capture = JSON.parse(ppText);
465
+ // A 2xx response does NOT mean the funds were captured. PayPal returns 201
466
+ // for captures that are PENDING (pending review / eCheck), DECLINED, or
467
+ // FAILED. Recording any of these as "captured" books money that never
468
+ // settled, so only a COMPLETED capture is treated as success.
469
+ const captureStatus = (0, status_utils_1.extractCaptureStatus)(capture);
470
+ if (captureStatus !== "COMPLETED") {
471
+ throw new Error(`PayPal capture did not complete (status=${captureStatus || "UNKNOWN"}). ` +
472
+ `The payment was not captured.${debugId ? ` debug_id=${debugId}` : ""}`);
473
+ }
474
+ const captureResource = authorizationId
475
+ ? capture
476
+ : (capture?.purchase_units?.[0]?.payments?.captures?.[0] ?? capture);
477
+ const captureId = captureResource?.id || capture?.id;
478
+ await this.recordSuccess("capture_success");
479
+ await this.recordPaymentEvent("capture", {
480
+ order_id: orderId,
481
+ capture_id: captureId,
482
+ authorization_id: authorizationId || undefined,
483
+ amount,
484
+ currency_code: currencyCode,
485
+ request_id: requestId,
486
+ });
487
+ return successResult(capture, liveCaptures, {
488
+ ...toStoredCaptureEntry(captureResource),
489
+ id: captureId,
490
+ raw: capture,
491
+ });
492
+ }
493
+ catch (error) {
494
+ await this.recordFailure("capture_failed", {
495
+ order_id: orderId,
496
+ request_id: requestId,
497
+ debug_id: debugId,
498
+ message: error?.message,
499
+ });
500
+ // Surface the real reason: Medusa masks non-MedusaErrors as a generic
501
+ // "unknown error" in production, hiding the PayPal failure.
502
+ throw error instanceof utils_1.MedusaError
503
+ ? error
504
+ : new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, error?.message || "PayPal capture failed.");
505
+ }
506
+ }
211
507
  async createAccountHolder(input) {
212
508
  const customerId = input.context?.customer?.id;
213
509
  const externalId = customerId
@@ -1 +1 @@
1
- {"version":3,"file":"base-provider.js","sourceRoot":"","sources":["../../../../../../src/modules/paypal/payment-provider/base-provider.ts"],"names":[],"mappings":";;;AAAA,qDAAmE;AACnE,mCAAmC;AASnC,8CAAwE;AACxE,oDAG4B;AAC5B,sEAAuE;AACvE,8CAAgE;AAChE,wDAAmD;AACnD,mDAA+D;AAC/D,iDAAuD;AAIvD;;;;;;;;GAQG;AACH,MAAsB,kBAAmB,SAAQ,+BAAgC;IAC5D,QAAQ,CAAS;IAC1B,MAAM,CAA0B;IAO1C,YAAY,MAA2B,EAAE,OAAgB;QACvD,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACtB,IAAI,C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I,EAAE,EAAE,EAAE,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,OAA0C;QAE1C,OAAO,IAAA,6CAA6B,EAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;CACF;AA9PD,gDA8PC"}
1
+ {"version":3,"file":"base-provider.js","sourceRoot":"","sources":["../../../../../../src/modules/paypal/payment-provider/base-provider.ts"],"names":[],"mappings":";;;AAAA,qDAAgF;AAChF,mCAAmC;AAWnC,8CAIyB;AACzB,oDAG4B;AAC5B,sEAAuE;AACvE,8CAAgE;AAChE,wDAAyE;AACzE,mDAA+D;AAC/D,iDAMuB;AAWvB,SAAS,oBAAoB,CAAC,OAAY;IACxC,OAAO;QACL,EAAE,EAAE,OAAO,EAAE,EAAE;QACf,MAAM,EAAE,OAAO,EAAE,MAAM;QACvB,MAAM,EAAE,OAAO,EAAE,MAAM;QACvB,aAAa,EAAE,OAAO,EAAE,aAAa;QACrC,GAAG,EAAE,OAAO;KACb,CAAA;AACH,CAAC;AAED,wEAAwE;AACxE,SAAS,mBAAmB,CAC1B,GAAG,KAA2C;IAE9C,MAAM,IAAI,GAAG,IAAI,GAAG,EAA8B,CAAA;IAClD,MAAM,SAAS,GAAyB,EAAE,CAAA;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;YAC/B,IAAI,KAAK,EAAE,EAAE;gBAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;iBAC3C,IAAI,KAAK;gBAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC,CAAA;AACzC,CAAC;AAID;;;;;;;;GAQG;AACH,MAAsB,kBAAmB,SAAQ,+BA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BAAwB,CAC3C,CAAA;QACP,CAAC;IACH,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,KAA+B;QAE/B,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAA;QAC9C,MAAM,UAAU,GAAG,UAAU;YAC3B,CAAC,CAAC,UAAU,UAAU,EAAE;YACxB,CAAC,CAAC,UAAU,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAA;QACxC,OAAO;YACL,EAAE,EAAE,UAAU;YACd,IAAI,EAAE;gBACJ,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI;gBAC7C,WAAW,EAAE,UAAU,IAAI,IAAI;aAChC;SACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,MAA0B;QAE1B,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,OAA0C;QAE1C,OAAO,IAAA,6CAA6B,EAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;CACF;AA7mBD,gDA6mBC"}
@@ -1,4 +1,4 @@
1
- import type { AuthorizePaymentInput, AuthorizePaymentOutput, CapturePaymentInput, CapturePaymentOutput, CancelPaymentInput, CancelPaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, InitiatePaymentInput, InitiatePaymentOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput } from "@medusajs/framework/types";
1
+ import type { AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, InitiatePaymentInput, InitiatePaymentOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput } from "@medusajs/framework/types";
2
2
  import { PayPalProviderBase } from "./base-provider";
3
3
  /**
4
4
  * PayPal Advanced (hosted) Card Fields payment provider —
@@ -15,7 +15,6 @@ declare class PayPalAdvancedCardProvider extends PayPalProviderBase {
15
15
  initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
16
16
  updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
17
17
  authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
18
- capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
19
18
  cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
20
19
  refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
21
20
  retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
@@ -1 +1 @@
1
- {"version":3,"file":"card-service.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/payment-provider/card-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAalC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD;;;;;;;GAOG;AACH,cAAM,0BAA2B,SAAQ,kBAAkB;IACzD,MAAM,CAAC,UAAU,SAAgB;IAEjC,SAAS,CAAC,QAAQ,CAAC,aAAa,aAAY;IAC5C,SAAS,CAAC,QAAQ,CAAC,iBAAiB,aAAY;IAE1C,eAAe,CACnB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IAoB3B,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyBtE,gBAAgB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;IAkQ5B,cAAc,CAClB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,oBAAoB,CAAC;IAqO1B,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAkJtE,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmItE,eAAe,CACnB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IA0B3B,gBAAgB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;CA+BnC;AAED,eAAe,0BAA0B,CAAA;AACzC,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
1
+ {"version":3,"file":"card-service.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/payment-provider/card-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AASlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD;;;;;;;GAOG;AACH,cAAM,0BAA2B,SAAQ,kBAAkB;IACzD,MAAM,CAAC,UAAU,SAAgB;IAEjC,SAAS,CAAC,QAAQ,CAAC,aAAa,aAAY;IAC5C,SAAS,CAAC,QAAQ,CAAC,iBAAiB,aAAY;IAE1C,eAAe,CACnB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IAoB3B,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyBtE,gBAAgB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;IAkQ5B,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAkJtE,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAsItE,eAAe,CACnB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IA0B3B,gBAAgB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;CA+BnC;AAED,eAAe,0BAA0B,CAAA;AACzC,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
@@ -271,190 +271,6 @@ class PayPalAdvancedCardProvider extends base_provider_1.PayPalProviderBase {
271
271
  });
272
272
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_ALLOWED, `PayPal order ${orderId} has not been approved by the buyer (status ${orderStatus || "UNKNOWN"}). The payment cannot be authorized.`);
273
273
  }
274
- async capturePayment(input) {
275
- const data = (input.data || {});
276
- const paypalData = (data.paypal || {});
277
- const orderId = String(paypalData.order_id || data.order_id || "");
278
- let authorizationId = String(paypalData.authorization_id || data.authorization_id || "");
279
- if (!orderId) {
280
- throw new Error("PayPal order_id is required to capture payment");
281
- }
282
- if (paypalData.capture_id || paypalData.capture) {
283
- return {
284
- data: {
285
- ...(data || {}),
286
- paypal: {
287
- ...paypalData,
288
- capture_id: paypalData.capture_id,
289
- capture: paypalData.capture,
290
- },
291
- captured_at: new Date().toISOString(),
292
- },
293
- };
294
- }
295
- const { amount: sessionAmount, currencyCode } = await this.normalizePaymentData(input);
296
- // The requested (possibly partial) capture amount lives on the Medusa
297
- // capture row, not in the provider input — resolve it so partial captures
298
- // don't charge the full session total.
299
- const amount = await this.resolveRequestedCaptureAmount(input, sessionAmount);
300
- // Include the amount in the idempotency suffix: PayPal deduplicates by
301
- // PayPal-Request-Id, so two sequential partial captures of the same order
302
- // that share an upstream idempotency_key would otherwise collide and the
303
- // second capture would silently return the first one's result.
304
- const requestId = this.getIdempotencyKey(input, `capture-${orderId}-${amount}`);
305
- let debugId = null;
306
- try {
307
- const { accessToken, base } = await this.getPayPalAccessToken();
308
- const order = await this.getOrderDetails(orderId).catch(() => null);
309
- const existingCapture = order?.purchase_units?.[0]?.payments?.captures?.[0];
310
- if (existingCapture?.id && (0, status_utils_1.isCaptureCompleted)(existingCapture)) {
311
- return {
312
- data: {
313
- ...(data || {}),
314
- paypal: {
315
- ...paypalData,
316
- capture_id: existingCapture.id,
317
- capture: existingCapture,
318
- },
319
- captured_at: new Date().toISOString(),
320
- },
321
- };
322
- }
323
- const resolvedIntent = String(order?.intent || paypalData.order?.intent || data.intent || "").toUpperCase();
324
- if (!authorizationId && resolvedIntent === "AUTHORIZE") {
325
- const authorizeResp = await (0, paypal_fetch_1.paypalFetch)(`${base}/v2/checkout/orders/${encodeURIComponent(orderId)}/authorize`, {
326
- method: "POST",
327
- headers: {
328
- Authorization: `Bearer ${accessToken}`,
329
- "Content-Type": "application/json",
330
- "PayPal-Request-Id": `${requestId}-auth`,
331
- "PayPal-Partner-Attribution-Id": partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID,
332
- },
333
- });
334
- const authorizeText = await authorizeResp.text();
335
- debugId = authorizeResp.headers.get("paypal-debug-id");
336
- if (!authorizeResp.ok) {
337
- throw new Error(`PayPal authorize order error (${authorizeResp.status}): ${authorizeText}${debugId ? ` debug_id=${debugId}` : ""}`);
338
- }
339
- const authorization = JSON.parse(authorizeText);
340
- authorizationId =
341
- authorization?.purchase_units?.[0]?.payments?.authorizations?.[0]?.id;
342
- }
343
- const isFinalCapture = paypalData.is_final_capture ??
344
- data.is_final_capture ??
345
- data.final_capture ??
346
- undefined;
347
- const captureValue = amount > 0 ? (0, amounts_1.formatAmountForPayPal)(amount, currencyCode || "EUR") : null;
348
- // `amount` and `is_final_capture` are only honored on the authorizations
349
- // capture endpoint. The orders capture endpoint always captures the FULL
350
- // order and silently ignores an `amount` body — so a partial amount there
351
- // would over-capture while we record the smaller requested value. Route
352
- // partial captures through the authorization, and fail closed if a partial
353
- // capture is attempted against a capture-intent order.
354
- let capturePayload;
355
- let captureUrl;
356
- if (authorizationId) {
357
- captureUrl = `${base}/v2/payments/authorizations/${encodeURIComponent(authorizationId)}/capture`;
358
- capturePayload = {
359
- ...(captureValue
360
- ? {
361
- amount: {
362
- currency_code: currencyCode || "EUR",
363
- value: captureValue,
364
- },
365
- }
366
- : {}),
367
- ...(typeof isFinalCapture === "boolean"
368
- ? { is_final_capture: isFinalCapture }
369
- : {}),
370
- };
371
- }
372
- else {
373
- captureUrl = `${base}/v2/checkout/orders/${encodeURIComponent(orderId)}/capture`;
374
- capturePayload = {};
375
- const orderTotal = order?.purchase_units?.[0]?.amount?.value;
376
- if (captureValue && orderTotal && captureValue !== String(orderTotal)) {
377
- throw new Error(`PayPal partial capture (${captureValue} ${currencyCode || "EUR"}) is not supported for ` +
378
- `capture-intent orders (order total ${orderTotal}). Create the order with intent ` +
379
- `AUTHORIZE to capture a partial amount.`);
380
- }
381
- }
382
- // Retry transient 5xx/429/timeout: the PayPal-Request-Id makes the capture
383
- // idempotent, so a retry after a network blip re-uses the same capture
384
- // instead of double-charging.
385
- const ppResp = await (0, paypal_fetch_1.paypalFetchWithRetry)(captureUrl, {
386
- method: "POST",
387
- headers: {
388
- Authorization: `Bearer ${accessToken}`,
389
- "Content-Type": "application/json",
390
- "PayPal-Request-Id": requestId,
391
- "PayPal-Partner-Attribution-Id": partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID,
392
- },
393
- body: JSON.stringify(capturePayload),
394
- });
395
- const ppText = await ppResp.text();
396
- debugId = ppResp.headers.get("paypal-debug-id");
397
- if (!ppResp.ok) {
398
- throw new Error(`PayPal capture error (${ppResp.status}): ${ppText}${debugId ? ` debug_id=${debugId}` : ""}`);
399
- }
400
- const capture = JSON.parse(ppText);
401
- // A 2xx response does NOT mean the funds were captured. PayPal returns 201
402
- // for captures that are PENDING (pending review / eCheck), DECLINED, or
403
- // FAILED. Recording any of these as "captured" books money that never
404
- // settled, so only a COMPLETED capture is treated as success.
405
- const captureStatus = (0, status_utils_1.extractCaptureStatus)(capture);
406
- if (captureStatus !== "COMPLETED") {
407
- throw new Error(`PayPal capture did not complete (status=${captureStatus || "UNKNOWN"}). ` +
408
- `The payment was not captured.${debugId ? ` debug_id=${debugId}` : ""}`);
409
- }
410
- const captureId = capture?.id || capture?.purchase_units?.[0]?.payments?.captures?.[0]?.id;
411
- const existingCaptures = Array.isArray(paypalData.captures)
412
- ? paypalData.captures
413
- : [];
414
- const captureEntry = {
415
- id: captureId,
416
- status: capture?.status,
417
- amount: capture?.amount,
418
- raw: capture,
419
- };
420
- await this.recordSuccess("capture_success");
421
- await this.recordPaymentEvent("capture", {
422
- order_id: orderId,
423
- capture_id: captureId,
424
- authorization_id: authorizationId || undefined,
425
- amount,
426
- currency_code: currencyCode,
427
- request_id: requestId,
428
- });
429
- return {
430
- data: {
431
- ...(data || {}),
432
- paypal: {
433
- ...paypalData,
434
- order_id: orderId,
435
- capture_id: captureId,
436
- capture,
437
- authorization_id: authorizationId || paypalData.authorization_id,
438
- captures: [...existingCaptures, captureEntry],
439
- },
440
- captured_at: new Date().toISOString(),
441
- },
442
- };
443
- }
444
- catch (error) {
445
- await this.recordFailure("capture_failed", {
446
- order_id: orderId,
447
- request_id: requestId,
448
- debug_id: debugId,
449
- message: error?.message,
450
- });
451
- // Surface the real reason: Medusa masks non-MedusaErrors as a generic
452
- // "unknown error" in production, hiding the PayPal failure.
453
- throw error instanceof utils_1.MedusaError
454
- ? error
455
- : new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, error?.message || "PayPal capture failed.");
456
- }
457
- }
458
274
  async cancelPayment(input) {
459
275
  const data = (input.data || {});
460
276
  const paypalData = (data.paypal || {});
@@ -598,6 +414,9 @@ class PayPalAdvancedCardProvider extends base_provider_1.PayPalProviderBase {
598
414
  headers: {
599
415
  Authorization: `Bearer ${accessToken}`,
600
416
  "Content-Type": "application/json",
417
+ // Full refund resource (amount, status, …) instead of the
418
+ // id/status/links stub, so the stored refund entry is usable.
419
+ Prefer: "return=representation",
601
420
  "PayPal-Request-Id": requestId,
602
421
  "PayPal-Partner-Attribution-Id": partner_1.PAYPAL_PARTNER_ATTRIBUTION_ID,
603
422
  },