@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/{chunk-D7DPAKI2.js → chunk-MX26LF5P.js} +50 -4
- package/dist/chunk-MX26LF5P.js.map +1 -0
- package/dist/index.cjs +49 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +276 -8
- package/dist/index.d.ts +276 -8
- package/dist/index.js +1 -1
- package/dist/internal.cjs +49 -3
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-D7DPAKI2.js.map +0 -1
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
|
|
1156
|
+
* List the payment methods available for a payment — the discovery endpoint a
|
|
1157
|
+
* custom checkout renders its tiles from.
|
|
1157
1158
|
*
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
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 });
|