@delopay/sdk 0.76.0 → 0.78.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/dist/index.cjs CHANGED
@@ -1153,10 +1153,45 @@ var PaymentMethods = class {
1153
1153
  return this.request("DELETE", `/payment-methods/${encodeURIComponent(methodId)}`);
1154
1154
  }
1155
1155
  /**
1156
- * List payment methods using a client secret.
1156
+ * List the payment methods available for a payment — the discovery endpoint a
1157
+ * custom checkout renders its tiles from.
1157
1158
  *
1158
- * @param params - Filter by `client_secret`.
1159
- * @returns Array of payment methods.
1159
+ * Callable with a publishable key plus the payment's `client_secret`, so it
1160
+ * runs from the browser. The returned set is already filtered by country,
1161
+ * order value and the merchant's availability rules, and each entry carries
1162
+ * `display` (name + icon slug) and `amount_limits` (the order values it stays
1163
+ * available for) so you do not have to maintain either alongside.
1164
+ *
1165
+ * This is *not* the customer's saved methods — see {@link listForCustomer}.
1166
+ *
1167
+ * @param params - `client_secret`, plus optional `country`, `amount` and filters.
1168
+ * @returns The methods available for the payment, grouped by payment method.
1169
+ *
1170
+ * @example
1171
+ * ```typescript
1172
+ * const { payment_methods } = await delopay.paymentMethods.list({
1173
+ * client_secret: 'pay_abc_secret_xyz',
1174
+ * country: 'DE',
1175
+ * amount: 25000,
1176
+ * });
1177
+ *
1178
+ * for (const group of payment_methods) {
1179
+ * for (const method of group.payment_method_types) {
1180
+ * // Re-check availability yourself as the cart total changes, instead of
1181
+ * // re-listing on every keystroke.
1182
+ * const limits = method.amount_limits;
1183
+ * const available =
1184
+ * !limits ||
1185
+ * ((limits.min_amount == null || cartTotal >= limits.min_amount) &&
1186
+ * (limits.max_amount == null || cartTotal <= limits.max_amount) &&
1187
+ * !limits.excluded_ranges.some(
1188
+ * (band) => cartTotal >= band.min_amount && cartTotal <= band.max_amount,
1189
+ * ));
1190
+ *
1191
+ * if (available) render(method.display?.display_name, method.display?.icon_slug);
1192
+ * }
1193
+ * }
1194
+ * ```
1160
1195
  */
1161
1196
  async list(params) {
1162
1197
  return this.request("GET", "/payment-methods", {
@@ -1269,6 +1304,17 @@ var Payments = class {
1269
1304
  * { headers: { 'Idempotency-Key': 'order_1001' } },
1270
1305
  * );
1271
1306
  * ```
1307
+ *
1308
+ * @example Send `test_mode` to pick the environment per payment, so a staging
1309
+ * deploy cannot charge real cards and a forgotten processor toggle cannot
1310
+ * swallow production traffic:
1311
+ * ```typescript
1312
+ * const payment = await delopay.payments.create({
1313
+ * amount: 5000,
1314
+ * currency: 'EUR',
1315
+ * test_mode: process.env.NODE_ENV !== 'production',
1316
+ * });
1317
+ * ```
1272
1318
  */
1273
1319
  async create(params, options) {
1274
1320
  return this.request("POST", "/payments", { body: params, ...options });