@delopay/sdk 0.235.0 → 0.240.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-FRH5BWGL.js → chunk-K6P7MQ7K.js} +169 -1
- package/dist/chunk-K6P7MQ7K.js.map +1 -0
- package/dist/index.cjs +168 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +623 -1
- package/dist/index.d.ts +623 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +168 -0
- 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-FRH5BWGL.js.map +0 -1
package/dist/index.js
CHANGED
package/dist/internal.cjs
CHANGED
|
@@ -899,6 +899,42 @@ var Connectors = class {
|
|
|
899
899
|
{ body: params }
|
|
900
900
|
);
|
|
901
901
|
}
|
|
902
|
+
/**
|
|
903
|
+
* Share a connector with more shops of the same merchant (todos#320).
|
|
904
|
+
* `POST /account/{accountId}/connectors/{connectorId}/shops`
|
|
905
|
+
*
|
|
906
|
+
* Nothing is copied: every shop sends payments to the same account, on the
|
|
907
|
+
* same credentials and webhook, and the account's limits count them all.
|
|
908
|
+
*/
|
|
909
|
+
async addShops(accountId, connectorId, params) {
|
|
910
|
+
return this.request(
|
|
911
|
+
"POST",
|
|
912
|
+
`/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops`,
|
|
913
|
+
{ body: params }
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Switch a connector off, or back on, in one shop it serves.
|
|
918
|
+
* `POST /account/{accountId}/connectors/{connectorId}/shops/{profileId}`
|
|
919
|
+
*/
|
|
920
|
+
async setShopDisabled(accountId, connectorId, profileId, params) {
|
|
921
|
+
return this.request(
|
|
922
|
+
"POST",
|
|
923
|
+
`/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops/${encodeURIComponent(profileId)}`,
|
|
924
|
+
{ body: params }
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Stop a connector serving one shop it is shared with. The home shop is
|
|
929
|
+
* refused: it holds the connector's name, limits and webhook.
|
|
930
|
+
* `DELETE /account/{accountId}/connectors/{connectorId}/shops/{profileId}`
|
|
931
|
+
*/
|
|
932
|
+
async removeShop(accountId, connectorId, profileId) {
|
|
933
|
+
return this.request(
|
|
934
|
+
"DELETE",
|
|
935
|
+
`/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops/${encodeURIComponent(profileId)}`
|
|
936
|
+
);
|
|
937
|
+
}
|
|
902
938
|
// --- Advanced operations (Task 4.8) ---
|
|
903
939
|
/**
|
|
904
940
|
* Run the configuration checks for a vault (VGS) connector account:
|
|
@@ -1084,6 +1120,77 @@ var Connectors = class {
|
|
|
1084
1120
|
`/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/sync-events`
|
|
1085
1121
|
);
|
|
1086
1122
|
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Read the callback addresses of a connector's payment provider.
|
|
1125
|
+
* `GET /account/{merchantId}/connectors/webhooks/{connectorId}/address`
|
|
1126
|
+
*
|
|
1127
|
+
* One entry per environment: the saved mode and identifier, and for every
|
|
1128
|
+
* credential group the URL the policy asks for (`desired_url`) beside the URL
|
|
1129
|
+
* actually registered at the provider (`registered_url`) with its `status`.
|
|
1130
|
+
* Only `registered` means the provider delivers to the desired URL.
|
|
1131
|
+
*
|
|
1132
|
+
* Available for providers whose webhooks Delopay manages (Stripe, PayPal,
|
|
1133
|
+
* Airwallex, Whop) and for hand-configured ones (Creem, NomuPay,
|
|
1134
|
+
* MicroPayment). Other connectors are refused with a 400.
|
|
1135
|
+
*/
|
|
1136
|
+
async getWebhookAddress(merchantId, connectorId) {
|
|
1137
|
+
return this.request(
|
|
1138
|
+
"GET",
|
|
1139
|
+
`/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address`
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Validate a proposed callback address without saving it.
|
|
1144
|
+
* `POST /account/{merchantId}/connectors/webhooks/{connectorId}/address/preview`
|
|
1145
|
+
*
|
|
1146
|
+
* Returns the validation errors as `{ field, code }` pairs, the URL every
|
|
1147
|
+
* affected credential group would get, the connector accounts that share it,
|
|
1148
|
+
* and whether saving needs `confirm_shared: true`. Needs the same permission
|
|
1149
|
+
* as saving.
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* ```typescript
|
|
1153
|
+
* const preview = await delopay.connectors.previewWebhookAddress('mer_abc', 'mca_xyz', {
|
|
1154
|
+
* environment: 'live',
|
|
1155
|
+
* mode: 'anonymous',
|
|
1156
|
+
* format: { prefix: 'wh-', style: 'alphanumeric', length: 16 },
|
|
1157
|
+
* });
|
|
1158
|
+
* if (!preview.valid) console.warn(preview.errors);
|
|
1159
|
+
* ```
|
|
1160
|
+
*/
|
|
1161
|
+
async previewWebhookAddress(merchantId, connectorId, params) {
|
|
1162
|
+
return this.request(
|
|
1163
|
+
"POST",
|
|
1164
|
+
`/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address/preview`,
|
|
1165
|
+
{ body: params }
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Save the callback address of a connector's payment provider for one
|
|
1170
|
+
* environment.
|
|
1171
|
+
* `PUT /account/{merchantId}/connectors/webhooks/{connectorId}/address`
|
|
1172
|
+
*
|
|
1173
|
+
* The address applies to every connector account of that provider and
|
|
1174
|
+
* environment, so `confirm_shared: true` is required when other accounts are
|
|
1175
|
+
* affected. For a managed provider Delopay then registers the new URL and
|
|
1176
|
+
* keeps the former one accepted; the response reports each credential
|
|
1177
|
+
* group's outcome in `status`. A `pending` or `failed` group keeps receiving
|
|
1178
|
+
* on its previous URL and is retried. For a hand-configured provider the
|
|
1179
|
+
* merchant enters the new `desired_url` at the provider.
|
|
1180
|
+
*
|
|
1181
|
+
* A refused proposal answers 422 with error code `IR_06` and the message
|
|
1182
|
+
* `Webhook address refused: field:code,…`. A save that lost to a concurrent
|
|
1183
|
+
* change of the same address answers 422 with error code `HE_00` and can be
|
|
1184
|
+
* repeated. A caller who may not edit every affected account answers 403.
|
|
1185
|
+
* Address changes are limited per provider and environment (`rate_limit`).
|
|
1186
|
+
*/
|
|
1187
|
+
async updateWebhookAddress(merchantId, connectorId, params) {
|
|
1188
|
+
return this.request(
|
|
1189
|
+
"PUT",
|
|
1190
|
+
`/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address`,
|
|
1191
|
+
{ body: params }
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1087
1194
|
/** List available payment methods. `GET /account/payment-methods` */
|
|
1088
1195
|
async listPaymentMethods() {
|
|
1089
1196
|
return this.request("GET", "/account/payment-methods");
|
|
@@ -3243,6 +3350,44 @@ var Refunds = class {
|
|
|
3243
3350
|
return this.request("POST", "/refunds/list", { body: params });
|
|
3244
3351
|
}
|
|
3245
3352
|
// --- OLAP extensions (Task 4.3) ---
|
|
3353
|
+
/**
|
|
3354
|
+
* Refund requests buyers raised from the customer portal, newest first.
|
|
3355
|
+
* Limited to the caller's shop when the caller is scoped to one.
|
|
3356
|
+
* `GET /refund-requests`
|
|
3357
|
+
*/
|
|
3358
|
+
async listRequests(params) {
|
|
3359
|
+
return this.request("GET", "/refund-requests", {
|
|
3360
|
+
query: params
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3363
|
+
/**
|
|
3364
|
+
* Approve a buyer's refund request with a refund of its payment that has
|
|
3365
|
+
* succeeded, made with `create()` after the buyer asked. Approving records
|
|
3366
|
+
* the decision and moves no money. A refund that is still `pending` or in
|
|
3367
|
+
* `review` is refused: check it again later with `retrieve()` under the same
|
|
3368
|
+
* refund ID and approve once it has succeeded, rather than creating another
|
|
3369
|
+
* refund. `POST /refund-requests/{id}/approve`
|
|
3370
|
+
*
|
|
3371
|
+
* @example
|
|
3372
|
+
* ```typescript
|
|
3373
|
+
* const refund = await delopay.refunds.create({ payment_id: request.payment_id, amount: request.amount });
|
|
3374
|
+
* if (refund.status === 'succeeded') {
|
|
3375
|
+
* await delopay.refunds.approveRequest(request.id, { refund_id: refund.refund_id });
|
|
3376
|
+
* }
|
|
3377
|
+
* // Otherwise keep refund.refund_id, check it with retrieve() and approve once it has succeeded.
|
|
3378
|
+
* ```
|
|
3379
|
+
*/
|
|
3380
|
+
async approveRequest(requestId, params) {
|
|
3381
|
+
return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/approve`, {
|
|
3382
|
+
body: params
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
/** Decline a buyer's refund request. The buyer sees the reply. `POST /refund-requests/{id}/decline` */
|
|
3386
|
+
async declineRequest(requestId, params) {
|
|
3387
|
+
return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/decline`, {
|
|
3388
|
+
body: params
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3246
3391
|
/** List refunds (profile-scoped). `POST /refunds/profile/list` */
|
|
3247
3392
|
async listByProfile(params) {
|
|
3248
3393
|
return this.request("POST", "/refunds/profile/list", { body: params });
|
|
@@ -7007,6 +7152,29 @@ var BuyerPortal = class {
|
|
|
7007
7152
|
async getSession(options) {
|
|
7008
7153
|
return this.request("GET", "/buyer-portal/session", { ...options });
|
|
7009
7154
|
}
|
|
7155
|
+
/** The buyer's contact and billing details, and what they may change. */
|
|
7156
|
+
async getProfile(options) {
|
|
7157
|
+
return this.request("GET", "/buyer-portal/profile", { ...options });
|
|
7158
|
+
}
|
|
7159
|
+
/**
|
|
7160
|
+
* Change the buyer's contact and billing details. Fields left out stay as
|
|
7161
|
+
* they are; the merchant decides whether buyers may change them at all.
|
|
7162
|
+
*/
|
|
7163
|
+
async updateProfile(params, options) {
|
|
7164
|
+
return this.request("POST", "/buyer-portal/profile", { body: params, ...options });
|
|
7165
|
+
}
|
|
7166
|
+
/**
|
|
7167
|
+
* Ask the shop for a refund of one of the buyer's purchases, named by its
|
|
7168
|
+
* `id` from `listPurchases()`. Nothing is refunded until the shop approves
|
|
7169
|
+
* the request with a refund.
|
|
7170
|
+
*/
|
|
7171
|
+
async createRefundRequest(purchaseId, params, options) {
|
|
7172
|
+
return this.request(
|
|
7173
|
+
"POST",
|
|
7174
|
+
`/buyer-portal/purchases/${encodeURIComponent(purchaseId)}/refund-requests`,
|
|
7175
|
+
{ body: params, ...options }
|
|
7176
|
+
);
|
|
7177
|
+
}
|
|
7010
7178
|
async listInvoices(params, options) {
|
|
7011
7179
|
return this.request("GET", "/buyer-portal/invoices", {
|
|
7012
7180
|
query: params,
|