@delopay/sdk 0.29.0 → 0.31.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 +10 -4
- package/dist/{chunk-4Q3E7XLP.js → chunk-5C42YTV2.js} +79 -47
- package/dist/chunk-5C42YTV2.js.map +1 -0
- package/dist/index.cjs +78 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -27
- package/dist/index.d.ts +66 -27
- package/dist/index.js +1 -1
- package/dist/internal.cjs +92 -60
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +4 -4
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +15 -15
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4Q3E7XLP.js.map +0 -1
package/README.md
CHANGED
|
@@ -118,14 +118,16 @@ const customer = await delopay.customers.create({
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
// List saved payment methods
|
|
121
|
-
const
|
|
121
|
+
const { customer_payment_methods } = await delopay.paymentMethods.listForCustomer(
|
|
122
|
+
customer.customer_id,
|
|
123
|
+
);
|
|
122
124
|
|
|
123
125
|
// Use a saved method on a new payment
|
|
124
126
|
const payment = await delopay.payments.create({
|
|
125
127
|
amount: 1000,
|
|
126
128
|
currency: 'EUR',
|
|
127
129
|
customer_id: customer.customer_id,
|
|
128
|
-
payment_token:
|
|
130
|
+
payment_token: customer_payment_methods[0]?.payment_token,
|
|
129
131
|
confirm: true,
|
|
130
132
|
});
|
|
131
133
|
```
|
|
@@ -133,11 +135,15 @@ const payment = await delopay.payments.create({
|
|
|
133
135
|
### Handle disputes
|
|
134
136
|
|
|
135
137
|
```typescript
|
|
136
|
-
|
|
138
|
+
// Disputes for one payment come from the payment object:
|
|
139
|
+
const payment = await delopay.payments.retrieve('pay_abc123');
|
|
137
140
|
|
|
138
|
-
for (const dispute of disputes) {
|
|
141
|
+
for (const dispute of payment.disputes ?? []) {
|
|
139
142
|
console.log(dispute.dispute_id, dispute.dispute_stage, dispute.dispute_status);
|
|
140
143
|
}
|
|
144
|
+
|
|
145
|
+
// Or list disputes across the account, filtered by status:
|
|
146
|
+
const open = await delopay.disputes.list({ dispute_status: 'dispute_opened' });
|
|
141
147
|
```
|
|
142
148
|
|
|
143
149
|
### Manage shops and gateways
|
|
@@ -118,16 +118,21 @@ var Authentication = class {
|
|
|
118
118
|
body: params
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
/** Sync authentication status. `POST /authentication/{merchantId}/{authId}/sync` */
|
|
122
|
+
async sync(merchantId, authId, params) {
|
|
123
|
+
return this.request(
|
|
124
|
+
"POST",
|
|
125
|
+
`/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/sync`,
|
|
126
|
+
{ body: params }
|
|
127
|
+
);
|
|
125
128
|
}
|
|
126
|
-
/** Redirect after authentication. `POST /authentication/{authId}/redirect` */
|
|
127
|
-
async redirect(authId, params) {
|
|
128
|
-
return this.request(
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
/** Redirect after authentication. `POST /authentication/{merchantId}/{authId}/redirect` */
|
|
130
|
+
async redirect(merchantId, authId, params) {
|
|
131
|
+
return this.request(
|
|
132
|
+
"POST",
|
|
133
|
+
`/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/redirect`,
|
|
134
|
+
{ body: params }
|
|
135
|
+
);
|
|
131
136
|
}
|
|
132
137
|
/** Enable authn methods token. `POST /authentication/{authId}/enabled-authn-methods-token` */
|
|
133
138
|
async enabledAuthnMethodsToken(authId, params) {
|
|
@@ -764,11 +769,11 @@ var PaymentLinks = class {
|
|
|
764
769
|
`/payment-link/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`
|
|
765
770
|
);
|
|
766
771
|
}
|
|
767
|
-
/** Get payment link status. `GET /payment-
|
|
772
|
+
/** Get payment link status. `GET /payment-link/status/{merchantId}/{paymentId}` */
|
|
768
773
|
async status(merchantId, paymentId) {
|
|
769
774
|
return this.request(
|
|
770
775
|
"GET",
|
|
771
|
-
`/payment-
|
|
776
|
+
`/payment-link/status/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`
|
|
772
777
|
);
|
|
773
778
|
}
|
|
774
779
|
};
|
|
@@ -931,19 +936,21 @@ var Payments = class {
|
|
|
931
936
|
* Create a new payment intent.
|
|
932
937
|
*
|
|
933
938
|
* @param params - Payment creation parameters including amount and currency.
|
|
939
|
+
* @param options - Optional per-call extras: extra `headers` (e.g. an
|
|
940
|
+
* `Idempotency-Key` to make the create safe to retry), a `timeout` override,
|
|
941
|
+
* and an `AbortSignal`.
|
|
934
942
|
* @returns The created payment intent.
|
|
935
943
|
*
|
|
936
944
|
* @example
|
|
937
945
|
* ```typescript
|
|
938
|
-
* const payment = await delopay.payments.create(
|
|
939
|
-
* amount: 5000,
|
|
940
|
-
*
|
|
941
|
-
*
|
|
942
|
-
* });
|
|
946
|
+
* const payment = await delopay.payments.create(
|
|
947
|
+
* { amount: 5000, currency: 'EUR', customer_id: 'cus_123' },
|
|
948
|
+
* { headers: { 'Idempotency-Key': 'order_1001' } },
|
|
949
|
+
* );
|
|
943
950
|
* ```
|
|
944
951
|
*/
|
|
945
|
-
async create(params) {
|
|
946
|
-
return this.request("POST", "/payments", { body: params });
|
|
952
|
+
async create(params, options) {
|
|
953
|
+
return this.request("POST", "/payments", { body: params, ...options });
|
|
947
954
|
}
|
|
948
955
|
/**
|
|
949
956
|
* Retrieve a payment by its ID.
|
|
@@ -1027,6 +1034,8 @@ var Payments = class {
|
|
|
1027
1034
|
* List payment intents, optionally filtered by customer or date range.
|
|
1028
1035
|
*
|
|
1029
1036
|
* @param params - Optional filter and pagination parameters.
|
|
1037
|
+
* @param options - Optional per-call extras: extra `headers`, a `timeout`
|
|
1038
|
+
* override, and an `AbortSignal` for cancellation.
|
|
1030
1039
|
* @returns Paginated list of payment intents.
|
|
1031
1040
|
*
|
|
1032
1041
|
* @example
|
|
@@ -1034,9 +1043,10 @@ var Payments = class {
|
|
|
1034
1043
|
* const { data } = await delopay.payments.list({ customer_id: 'cus_123', limit: 25 });
|
|
1035
1044
|
* ```
|
|
1036
1045
|
*/
|
|
1037
|
-
async list(params) {
|
|
1046
|
+
async list(params, options) {
|
|
1038
1047
|
return this.request("GET", "/payments/list", {
|
|
1039
|
-
query: params
|
|
1048
|
+
query: params,
|
|
1049
|
+
...options
|
|
1040
1050
|
});
|
|
1041
1051
|
}
|
|
1042
1052
|
// --- Advanced operations (Task 3.2) ---
|
|
@@ -1241,13 +1251,13 @@ var Payouts = class {
|
|
|
1241
1251
|
async listByFilter(params) {
|
|
1242
1252
|
return this.request("POST", "/payouts/list", { body: params });
|
|
1243
1253
|
}
|
|
1244
|
-
/** Get payout filter options. `
|
|
1254
|
+
/** Get payout filter options. `GET /payouts/filter` */
|
|
1245
1255
|
async getFilters(params) {
|
|
1246
|
-
return this.request("
|
|
1256
|
+
return this.request("GET", "/payouts/filter", { query: params });
|
|
1247
1257
|
}
|
|
1248
|
-
/** Get payout filters (profile-scoped). `
|
|
1258
|
+
/** Get payout filters (profile-scoped). `GET /payouts/profile/filter` */
|
|
1249
1259
|
async getFiltersByProfile(params) {
|
|
1250
|
-
return this.request("
|
|
1260
|
+
return this.request("GET", "/payouts/profile/filter", { query: params });
|
|
1251
1261
|
}
|
|
1252
1262
|
/** Get payout aggregates. `GET /payouts/aggregate` */
|
|
1253
1263
|
async aggregate(params) {
|
|
@@ -1757,7 +1767,7 @@ var Shops = class {
|
|
|
1757
1767
|
*
|
|
1758
1768
|
* @example
|
|
1759
1769
|
* ```typescript
|
|
1760
|
-
* const shop = await delopay.shops.create('merch_123', {
|
|
1770
|
+
* const shop = await delopay.shops.create('merch_123', { shop_name: 'EU Store' });
|
|
1761
1771
|
* ```
|
|
1762
1772
|
*/
|
|
1763
1773
|
async create(merchantId, params) {
|
|
@@ -2021,7 +2031,7 @@ var Users = class {
|
|
|
2021
2031
|
return this.request("POST", "/user/employees/invite", { body: params });
|
|
2022
2032
|
}
|
|
2023
2033
|
async acceptInvitation(params) {
|
|
2024
|
-
return this.request("POST", "/user/invite/accept", { body: params });
|
|
2034
|
+
return this.request("POST", "/user/employees/invite/accept", { body: params });
|
|
2025
2035
|
}
|
|
2026
2036
|
/**
|
|
2027
2037
|
* Accept an invitation via the email-link flow.
|
|
@@ -2150,9 +2160,9 @@ var Users = class {
|
|
|
2150
2160
|
query: params
|
|
2151
2161
|
});
|
|
2152
2162
|
}
|
|
2153
|
-
/** Resend invite. `POST /user/
|
|
2163
|
+
/** Resend invite. `POST /user/resend-invite` */
|
|
2154
2164
|
async resendInvite(params) {
|
|
2155
|
-
return this.request("POST", "/user/
|
|
2165
|
+
return this.request("POST", "/user/resend-invite", { body: params });
|
|
2156
2166
|
}
|
|
2157
2167
|
/**
|
|
2158
2168
|
* Get the caller's parent permission groups + scopes.
|
|
@@ -2181,14 +2191,6 @@ var Users = class {
|
|
|
2181
2191
|
async listUpdatableRoles() {
|
|
2182
2192
|
return this.request("GET", "/user/role/list/update");
|
|
2183
2193
|
}
|
|
2184
|
-
/** Get permission info. `GET /user/permission-info` */
|
|
2185
|
-
async getPermissionInfo() {
|
|
2186
|
-
return this.request("GET", "/user/permission-info");
|
|
2187
|
-
}
|
|
2188
|
-
/** Get module list. `GET /user/module/list` */
|
|
2189
|
-
async getModuleList() {
|
|
2190
|
-
return this.request("GET", "/user/module/list");
|
|
2191
|
-
}
|
|
2192
2194
|
/** Get parent list. `GET /user/parent/list` */
|
|
2193
2195
|
async getParentList() {
|
|
2194
2196
|
return this.request("GET", "/user/parent/list");
|
|
@@ -2658,7 +2660,7 @@ var Delopay = class {
|
|
|
2658
2660
|
/**
|
|
2659
2661
|
* Create a new Delopay client.
|
|
2660
2662
|
*
|
|
2661
|
-
* @param apiKey - Your Delopay API key (e.g. `
|
|
2663
|
+
* @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).
|
|
2662
2664
|
* Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).
|
|
2663
2665
|
* @param options - Optional configuration (sandbox mode, base URL override, timeout).
|
|
2664
2666
|
*/
|
|
@@ -2915,34 +2917,64 @@ var Delopay = class {
|
|
|
2915
2917
|
* Auto-paginate a list endpoint. Yields items one by one, fetching
|
|
2916
2918
|
* the next page automatically when the current one is exhausted.
|
|
2917
2919
|
*
|
|
2918
|
-
*
|
|
2920
|
+
* Delopay list endpoints use one of two pagination styles, so this helper
|
|
2921
|
+
* supports both:
|
|
2922
|
+
* - **Offset** (default) — for endpoints like `customers.list` that accept
|
|
2923
|
+
* `offset`/`limit`. Each page advances `offset` by the number of items returned.
|
|
2924
|
+
* - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page
|
|
2925
|
+
* with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor
|
|
2926
|
+
* that returns the id of an item; the next page is requested with
|
|
2927
|
+
* `starting_after` set to the last item's id.
|
|
2928
|
+
*
|
|
2929
|
+
* @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.
|
|
2919
2930
|
* @param params - Additional parameters to pass to every page request.
|
|
2920
|
-
* @param
|
|
2931
|
+
* @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.
|
|
2932
|
+
* Provide `cursor` to switch to cursor pagination.
|
|
2921
2933
|
*
|
|
2922
2934
|
* @example
|
|
2923
2935
|
* ```typescript
|
|
2936
|
+
* // Offset endpoint (customers):
|
|
2937
|
+
* for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {
|
|
2938
|
+
* console.log(c.customer_id);
|
|
2939
|
+
* }
|
|
2940
|
+
*
|
|
2941
|
+
* // Cursor endpoint (payments): extract the id used as the next cursor.
|
|
2924
2942
|
* for await (const payment of delopay.paginate(
|
|
2925
2943
|
* (p) => delopay.payments.list(p),
|
|
2944
|
+
* undefined,
|
|
2945
|
+
* { cursor: (p) => p.payment_id },
|
|
2926
2946
|
* )) {
|
|
2927
2947
|
* console.log(payment.payment_id);
|
|
2928
2948
|
* }
|
|
2929
2949
|
* ```
|
|
2930
2950
|
*/
|
|
2931
|
-
async *paginate(listFn, params,
|
|
2951
|
+
async *paginate(listFn, params, options) {
|
|
2952
|
+
const pageSize = typeof options === "number" ? options : options?.pageSize ?? 50;
|
|
2953
|
+
const cursorOf = typeof options === "object" ? options.cursor : void 0;
|
|
2932
2954
|
let offset = 0;
|
|
2955
|
+
let after;
|
|
2933
2956
|
while (true) {
|
|
2934
|
-
const
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2957
|
+
const page = { ...params ?? {}, limit: pageSize };
|
|
2958
|
+
if (cursorOf) {
|
|
2959
|
+
if (after !== void 0) page.starting_after = after;
|
|
2960
|
+
} else {
|
|
2961
|
+
page.offset = offset;
|
|
2962
|
+
}
|
|
2963
|
+
const result = await listFn(page);
|
|
2939
2964
|
const items = Array.isArray(result) ? result : result.data;
|
|
2940
2965
|
if (items.length === 0) break;
|
|
2941
2966
|
for (const item of items) {
|
|
2942
2967
|
yield item;
|
|
2943
2968
|
}
|
|
2944
2969
|
if (items.length < pageSize) break;
|
|
2945
|
-
|
|
2970
|
+
if (cursorOf) {
|
|
2971
|
+
const last = items[items.length - 1];
|
|
2972
|
+
if (last === void 0) break;
|
|
2973
|
+
after = cursorOf(last);
|
|
2974
|
+
if (after === void 0) break;
|
|
2975
|
+
} else {
|
|
2976
|
+
offset += items.length;
|
|
2977
|
+
}
|
|
2946
2978
|
}
|
|
2947
2979
|
}
|
|
2948
2980
|
};
|
|
@@ -3624,4 +3656,4 @@ export {
|
|
|
3624
3656
|
applyBrandingVariables,
|
|
3625
3657
|
shadowFor
|
|
3626
3658
|
};
|
|
3627
|
-
//# sourceMappingURL=chunk-
|
|
3659
|
+
//# sourceMappingURL=chunk-5C42YTV2.js.map
|