@delopay/sdk 0.48.0 → 0.50.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/README.md CHANGED
@@ -146,6 +146,23 @@ for (const dispute of payment.disputes ?? []) {
146
146
  const open = await delopay.disputes.list({ dispute_status: 'dispute_opened' });
147
147
  ```
148
148
 
149
+ ### Inspect why a payment failed
150
+
151
+ ```typescript
152
+ // Every attempt on a payment — including retries across connectors — with its
153
+ // full failure detail (raw code + Delopay-unified, human-readable reason).
154
+ const { size, data } = await delopay.payments.listAttempts('pay_abc123');
155
+
156
+ for (const attempt of data) {
157
+ // e.g. "stripe failure — Insufficient funds (51)"
158
+ console.log(
159
+ `${attempt.connector ?? 'unknown'} ${attempt.status} — ` +
160
+ `${attempt.unified_message ?? attempt.error_message ?? 'no error'}` +
161
+ `${attempt.error_code ? ` (${attempt.error_code})` : ''}`,
162
+ );
163
+ }
164
+ ```
165
+
149
166
  ### Manage shops and gateways
150
167
 
151
168
  ```typescript
@@ -1060,6 +1060,37 @@ var Payments = class {
1060
1060
  if (Object.keys(query).length === 0) return this.request("GET", path);
1061
1061
  return this.request("GET", path, { query });
1062
1062
  }
1063
+ /**
1064
+ * List every attempt made on a payment, each with its full failure detail
1065
+ * (`error_code` / `error_message`, the Delopay-unified `unified_code` and
1066
+ * `unified_message`, and structured `error_details`).
1067
+ *
1068
+ * Useful for surfacing retries across connectors — e.g. "attempt 1 stripe →
1069
+ * insufficient_funds, attempt 2 adyen → success".
1070
+ *
1071
+ * `GET /payments/{paymentId}/attempts`
1072
+ *
1073
+ * @param paymentId - The payment intent ID whose attempts to list.
1074
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
1075
+ * override, and an `AbortSignal`.
1076
+ * @returns The attempt list — `size` plus a `data` array of attempts.
1077
+ * @throws If the payment does not exist or belongs to another merchant (404).
1078
+ *
1079
+ * @example
1080
+ * ```typescript
1081
+ * const { size, data } = await delopay.payments.listAttempts('pay_abc123');
1082
+ * for (const attempt of data) {
1083
+ * console.log(attempt.status, attempt.unified_message ?? attempt.error_message);
1084
+ * }
1085
+ * ```
1086
+ */
1087
+ async listAttempts(paymentId, options) {
1088
+ return this.request(
1089
+ "GET",
1090
+ `/payments/${encodeURIComponent(paymentId)}/attempts`,
1091
+ options
1092
+ );
1093
+ }
1063
1094
  /**
1064
1095
  * Update an existing payment intent before it is confirmed.
1065
1096
  *
@@ -3222,6 +3253,7 @@ function buildConditions(when = {}, raw = []) {
3222
3253
  if (when.connector != null) out.push(enumCondition("connector", when.connector));
3223
3254
  if (when.currency != null) out.push(enumCondition("currency", when.currency));
3224
3255
  if (when.cardNetwork != null) out.push(enumCondition("card_network", when.cardNetwork));
3256
+ if (when.billingCountry != null) out.push(enumCondition("billing_country", when.billingCountry));
3225
3257
  if (when.amountEquals != null) out.push(numberCondition("amount", "equal", when.amountEquals));
3226
3258
  if (when.amountGreaterThan != null) {
3227
3259
  out.push(numberCondition("amount", "greater_than", when.amountGreaterThan));
@@ -4023,4 +4055,4 @@ export {
4023
4055
  applyBrandingVariables,
4024
4056
  shadowFor
4025
4057
  };
4026
- //# sourceMappingURL=chunk-SX46W7E4.js.map
4058
+ //# sourceMappingURL=chunk-P45MMRTD.js.map