@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/index.cjs CHANGED
@@ -883,6 +883,42 @@ var Connectors = class {
883
883
  { body: params }
884
884
  );
885
885
  }
886
+ /**
887
+ * Share a connector with more shops of the same merchant (todos#320).
888
+ * `POST /account/{accountId}/connectors/{connectorId}/shops`
889
+ *
890
+ * Nothing is copied: every shop sends payments to the same account, on the
891
+ * same credentials and webhook, and the account's limits count them all.
892
+ */
893
+ async addShops(accountId, connectorId, params) {
894
+ return this.request(
895
+ "POST",
896
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops`,
897
+ { body: params }
898
+ );
899
+ }
900
+ /**
901
+ * Switch a connector off, or back on, in one shop it serves.
902
+ * `POST /account/{accountId}/connectors/{connectorId}/shops/{profileId}`
903
+ */
904
+ async setShopDisabled(accountId, connectorId, profileId, params) {
905
+ return this.request(
906
+ "POST",
907
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops/${encodeURIComponent(profileId)}`,
908
+ { body: params }
909
+ );
910
+ }
911
+ /**
912
+ * Stop a connector serving one shop it is shared with. The home shop is
913
+ * refused: it holds the connector's name, limits and webhook.
914
+ * `DELETE /account/{accountId}/connectors/{connectorId}/shops/{profileId}`
915
+ */
916
+ async removeShop(accountId, connectorId, profileId) {
917
+ return this.request(
918
+ "DELETE",
919
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops/${encodeURIComponent(profileId)}`
920
+ );
921
+ }
886
922
  // --- Advanced operations (Task 4.8) ---
887
923
  /**
888
924
  * Run the configuration checks for a vault (VGS) connector account:
@@ -1068,6 +1104,77 @@ var Connectors = class {
1068
1104
  `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/sync-events`
1069
1105
  );
1070
1106
  }
1107
+ /**
1108
+ * Read the callback addresses of a connector's payment provider.
1109
+ * `GET /account/{merchantId}/connectors/webhooks/{connectorId}/address`
1110
+ *
1111
+ * One entry per environment: the saved mode and identifier, and for every
1112
+ * credential group the URL the policy asks for (`desired_url`) beside the URL
1113
+ * actually registered at the provider (`registered_url`) with its `status`.
1114
+ * Only `registered` means the provider delivers to the desired URL.
1115
+ *
1116
+ * Available for providers whose webhooks Delopay manages (Stripe, PayPal,
1117
+ * Airwallex, Whop) and for hand-configured ones (Creem, NomuPay,
1118
+ * MicroPayment). Other connectors are refused with a 400.
1119
+ */
1120
+ async getWebhookAddress(merchantId, connectorId) {
1121
+ return this.request(
1122
+ "GET",
1123
+ `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address`
1124
+ );
1125
+ }
1126
+ /**
1127
+ * Validate a proposed callback address without saving it.
1128
+ * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/address/preview`
1129
+ *
1130
+ * Returns the validation errors as `{ field, code }` pairs, the URL every
1131
+ * affected credential group would get, the connector accounts that share it,
1132
+ * and whether saving needs `confirm_shared: true`. Needs the same permission
1133
+ * as saving.
1134
+ *
1135
+ * @example
1136
+ * ```typescript
1137
+ * const preview = await delopay.connectors.previewWebhookAddress('mer_abc', 'mca_xyz', {
1138
+ * environment: 'live',
1139
+ * mode: 'anonymous',
1140
+ * format: { prefix: 'wh-', style: 'alphanumeric', length: 16 },
1141
+ * });
1142
+ * if (!preview.valid) console.warn(preview.errors);
1143
+ * ```
1144
+ */
1145
+ async previewWebhookAddress(merchantId, connectorId, params) {
1146
+ return this.request(
1147
+ "POST",
1148
+ `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address/preview`,
1149
+ { body: params }
1150
+ );
1151
+ }
1152
+ /**
1153
+ * Save the callback address of a connector's payment provider for one
1154
+ * environment.
1155
+ * `PUT /account/{merchantId}/connectors/webhooks/{connectorId}/address`
1156
+ *
1157
+ * The address applies to every connector account of that provider and
1158
+ * environment, so `confirm_shared: true` is required when other accounts are
1159
+ * affected. For a managed provider Delopay then registers the new URL and
1160
+ * keeps the former one accepted; the response reports each credential
1161
+ * group's outcome in `status`. A `pending` or `failed` group keeps receiving
1162
+ * on its previous URL and is retried. For a hand-configured provider the
1163
+ * merchant enters the new `desired_url` at the provider.
1164
+ *
1165
+ * A refused proposal answers 422 with error code `IR_06` and the message
1166
+ * `Webhook address refused: field:code,…`. A save that lost to a concurrent
1167
+ * change of the same address answers 422 with error code `HE_00` and can be
1168
+ * repeated. A caller who may not edit every affected account answers 403.
1169
+ * Address changes are limited per provider and environment (`rate_limit`).
1170
+ */
1171
+ async updateWebhookAddress(merchantId, connectorId, params) {
1172
+ return this.request(
1173
+ "PUT",
1174
+ `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address`,
1175
+ { body: params }
1176
+ );
1177
+ }
1071
1178
  /** List available payment methods. `GET /account/payment-methods` */
1072
1179
  async listPaymentMethods() {
1073
1180
  return this.request("GET", "/account/payment-methods");
@@ -3227,6 +3334,44 @@ var Refunds = class {
3227
3334
  return this.request("POST", "/refunds/list", { body: params });
3228
3335
  }
3229
3336
  // --- OLAP extensions (Task 4.3) ---
3337
+ /**
3338
+ * Refund requests buyers raised from the customer portal, newest first.
3339
+ * Limited to the caller's shop when the caller is scoped to one.
3340
+ * `GET /refund-requests`
3341
+ */
3342
+ async listRequests(params) {
3343
+ return this.request("GET", "/refund-requests", {
3344
+ query: params
3345
+ });
3346
+ }
3347
+ /**
3348
+ * Approve a buyer's refund request with a refund of its payment that has
3349
+ * succeeded, made with `create()` after the buyer asked. Approving records
3350
+ * the decision and moves no money. A refund that is still `pending` or in
3351
+ * `review` is refused: check it again later with `retrieve()` under the same
3352
+ * refund ID and approve once it has succeeded, rather than creating another
3353
+ * refund. `POST /refund-requests/{id}/approve`
3354
+ *
3355
+ * @example
3356
+ * ```typescript
3357
+ * const refund = await delopay.refunds.create({ payment_id: request.payment_id, amount: request.amount });
3358
+ * if (refund.status === 'succeeded') {
3359
+ * await delopay.refunds.approveRequest(request.id, { refund_id: refund.refund_id });
3360
+ * }
3361
+ * // Otherwise keep refund.refund_id, check it with retrieve() and approve once it has succeeded.
3362
+ * ```
3363
+ */
3364
+ async approveRequest(requestId, params) {
3365
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/approve`, {
3366
+ body: params
3367
+ });
3368
+ }
3369
+ /** Decline a buyer's refund request. The buyer sees the reply. `POST /refund-requests/{id}/decline` */
3370
+ async declineRequest(requestId, params) {
3371
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/decline`, {
3372
+ body: params
3373
+ });
3374
+ }
3230
3375
  /** List refunds (profile-scoped). `POST /refunds/profile/list` */
3231
3376
  async listByProfile(params) {
3232
3377
  return this.request("POST", "/refunds/profile/list", { body: params });
@@ -6991,6 +7136,29 @@ var BuyerPortal = class {
6991
7136
  async getSession(options) {
6992
7137
  return this.request("GET", "/buyer-portal/session", { ...options });
6993
7138
  }
7139
+ /** The buyer's contact and billing details, and what they may change. */
7140
+ async getProfile(options) {
7141
+ return this.request("GET", "/buyer-portal/profile", { ...options });
7142
+ }
7143
+ /**
7144
+ * Change the buyer's contact and billing details. Fields left out stay as
7145
+ * they are; the merchant decides whether buyers may change them at all.
7146
+ */
7147
+ async updateProfile(params, options) {
7148
+ return this.request("POST", "/buyer-portal/profile", { body: params, ...options });
7149
+ }
7150
+ /**
7151
+ * Ask the shop for a refund of one of the buyer's purchases, named by its
7152
+ * `id` from `listPurchases()`. Nothing is refunded until the shop approves
7153
+ * the request with a refund.
7154
+ */
7155
+ async createRefundRequest(purchaseId, params, options) {
7156
+ return this.request(
7157
+ "POST",
7158
+ `/buyer-portal/purchases/${encodeURIComponent(purchaseId)}/refund-requests`,
7159
+ { body: params, ...options }
7160
+ );
7161
+ }
6994
7162
  async listInvoices(params, options) {
6995
7163
  return this.request("GET", "/buyer-portal/invoices", {
6996
7164
  query: params,