@delopay/sdk 0.238.0 → 0.241.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");