@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.
@@ -619,6 +619,42 @@ var Connectors = class {
619
619
  { body: params }
620
620
  );
621
621
  }
622
+ /**
623
+ * Share a connector with more shops of the same merchant (todos#320).
624
+ * `POST /account/{accountId}/connectors/{connectorId}/shops`
625
+ *
626
+ * Nothing is copied: every shop sends payments to the same account, on the
627
+ * same credentials and webhook, and the account's limits count them all.
628
+ */
629
+ async addShops(accountId, connectorId, params) {
630
+ return this.request(
631
+ "POST",
632
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops`,
633
+ { body: params }
634
+ );
635
+ }
636
+ /**
637
+ * Switch a connector off, or back on, in one shop it serves.
638
+ * `POST /account/{accountId}/connectors/{connectorId}/shops/{profileId}`
639
+ */
640
+ async setShopDisabled(accountId, connectorId, profileId, params) {
641
+ return this.request(
642
+ "POST",
643
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops/${encodeURIComponent(profileId)}`,
644
+ { body: params }
645
+ );
646
+ }
647
+ /**
648
+ * Stop a connector serving one shop it is shared with. The home shop is
649
+ * refused: it holds the connector's name, limits and webhook.
650
+ * `DELETE /account/{accountId}/connectors/{connectorId}/shops/{profileId}`
651
+ */
652
+ async removeShop(accountId, connectorId, profileId) {
653
+ return this.request(
654
+ "DELETE",
655
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/shops/${encodeURIComponent(profileId)}`
656
+ );
657
+ }
622
658
  // --- Advanced operations (Task 4.8) ---
623
659
  /**
624
660
  * Run the configuration checks for a vault (VGS) connector account:
@@ -804,6 +840,77 @@ var Connectors = class {
804
840
  `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/sync-events`
805
841
  );
806
842
  }
843
+ /**
844
+ * Read the callback addresses of a connector's payment provider.
845
+ * `GET /account/{merchantId}/connectors/webhooks/{connectorId}/address`
846
+ *
847
+ * One entry per environment: the saved mode and identifier, and for every
848
+ * credential group the URL the policy asks for (`desired_url`) beside the URL
849
+ * actually registered at the provider (`registered_url`) with its `status`.
850
+ * Only `registered` means the provider delivers to the desired URL.
851
+ *
852
+ * Available for providers whose webhooks Delopay manages (Stripe, PayPal,
853
+ * Airwallex, Whop) and for hand-configured ones (Creem, NomuPay,
854
+ * MicroPayment). Other connectors are refused with a 400.
855
+ */
856
+ async getWebhookAddress(merchantId, connectorId) {
857
+ return this.request(
858
+ "GET",
859
+ `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address`
860
+ );
861
+ }
862
+ /**
863
+ * Validate a proposed callback address without saving it.
864
+ * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/address/preview`
865
+ *
866
+ * Returns the validation errors as `{ field, code }` pairs, the URL every
867
+ * affected credential group would get, the connector accounts that share it,
868
+ * and whether saving needs `confirm_shared: true`. Needs the same permission
869
+ * as saving.
870
+ *
871
+ * @example
872
+ * ```typescript
873
+ * const preview = await delopay.connectors.previewWebhookAddress('mer_abc', 'mca_xyz', {
874
+ * environment: 'live',
875
+ * mode: 'anonymous',
876
+ * format: { prefix: 'wh-', style: 'alphanumeric', length: 16 },
877
+ * });
878
+ * if (!preview.valid) console.warn(preview.errors);
879
+ * ```
880
+ */
881
+ async previewWebhookAddress(merchantId, connectorId, params) {
882
+ return this.request(
883
+ "POST",
884
+ `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address/preview`,
885
+ { body: params }
886
+ );
887
+ }
888
+ /**
889
+ * Save the callback address of a connector's payment provider for one
890
+ * environment.
891
+ * `PUT /account/{merchantId}/connectors/webhooks/{connectorId}/address`
892
+ *
893
+ * The address applies to every connector account of that provider and
894
+ * environment, so `confirm_shared: true` is required when other accounts are
895
+ * affected. For a managed provider Delopay then registers the new URL and
896
+ * keeps the former one accepted; the response reports each credential
897
+ * group's outcome in `status`. A `pending` or `failed` group keeps receiving
898
+ * on its previous URL and is retried. For a hand-configured provider the
899
+ * merchant enters the new `desired_url` at the provider.
900
+ *
901
+ * A refused proposal answers 422 with error code `IR_06` and the message
902
+ * `Webhook address refused: field:code,…`. A save that lost to a concurrent
903
+ * change of the same address answers 422 with error code `HE_00` and can be
904
+ * repeated. A caller who may not edit every affected account answers 403.
905
+ * Address changes are limited per provider and environment (`rate_limit`).
906
+ */
907
+ async updateWebhookAddress(merchantId, connectorId, params) {
908
+ return this.request(
909
+ "PUT",
910
+ `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/address`,
911
+ { body: params }
912
+ );
913
+ }
807
914
  /** List available payment methods. `GET /account/payment-methods` */
808
915
  async listPaymentMethods() {
809
916
  return this.request("GET", "/account/payment-methods");
@@ -2963,6 +3070,44 @@ var Refunds = class {
2963
3070
  return this.request("POST", "/refunds/list", { body: params });
2964
3071
  }
2965
3072
  // --- OLAP extensions (Task 4.3) ---
3073
+ /**
3074
+ * Refund requests buyers raised from the customer portal, newest first.
3075
+ * Limited to the caller's shop when the caller is scoped to one.
3076
+ * `GET /refund-requests`
3077
+ */
3078
+ async listRequests(params) {
3079
+ return this.request("GET", "/refund-requests", {
3080
+ query: params
3081
+ });
3082
+ }
3083
+ /**
3084
+ * Approve a buyer's refund request with a refund of its payment that has
3085
+ * succeeded, made with `create()` after the buyer asked. Approving records
3086
+ * the decision and moves no money. A refund that is still `pending` or in
3087
+ * `review` is refused: check it again later with `retrieve()` under the same
3088
+ * refund ID and approve once it has succeeded, rather than creating another
3089
+ * refund. `POST /refund-requests/{id}/approve`
3090
+ *
3091
+ * @example
3092
+ * ```typescript
3093
+ * const refund = await delopay.refunds.create({ payment_id: request.payment_id, amount: request.amount });
3094
+ * if (refund.status === 'succeeded') {
3095
+ * await delopay.refunds.approveRequest(request.id, { refund_id: refund.refund_id });
3096
+ * }
3097
+ * // Otherwise keep refund.refund_id, check it with retrieve() and approve once it has succeeded.
3098
+ * ```
3099
+ */
3100
+ async approveRequest(requestId, params) {
3101
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/approve`, {
3102
+ body: params
3103
+ });
3104
+ }
3105
+ /** Decline a buyer's refund request. The buyer sees the reply. `POST /refund-requests/{id}/decline` */
3106
+ async declineRequest(requestId, params) {
3107
+ return this.request("POST", `/refund-requests/${encodeURIComponent(requestId)}/decline`, {
3108
+ body: params
3109
+ });
3110
+ }
2966
3111
  /** List refunds (profile-scoped). `POST /refunds/profile/list` */
2967
3112
  async listByProfile(params) {
2968
3113
  return this.request("POST", "/refunds/profile/list", { body: params });
@@ -6727,6 +6872,29 @@ var BuyerPortal = class {
6727
6872
  async getSession(options) {
6728
6873
  return this.request("GET", "/buyer-portal/session", { ...options });
6729
6874
  }
6875
+ /** The buyer's contact and billing details, and what they may change. */
6876
+ async getProfile(options) {
6877
+ return this.request("GET", "/buyer-portal/profile", { ...options });
6878
+ }
6879
+ /**
6880
+ * Change the buyer's contact and billing details. Fields left out stay as
6881
+ * they are; the merchant decides whether buyers may change them at all.
6882
+ */
6883
+ async updateProfile(params, options) {
6884
+ return this.request("POST", "/buyer-portal/profile", { body: params, ...options });
6885
+ }
6886
+ /**
6887
+ * Ask the shop for a refund of one of the buyer's purchases, named by its
6888
+ * `id` from `listPurchases()`. Nothing is refunded until the shop approves
6889
+ * the request with a refund.
6890
+ */
6891
+ async createRefundRequest(purchaseId, params, options) {
6892
+ return this.request(
6893
+ "POST",
6894
+ `/buyer-portal/purchases/${encodeURIComponent(purchaseId)}/refund-requests`,
6895
+ { body: params, ...options }
6896
+ );
6897
+ }
6730
6898
  async listInvoices(params, options) {
6731
6899
  return this.request("GET", "/buyer-portal/invoices", {
6732
6900
  query: params,
@@ -12645,4 +12813,4 @@ export {
12645
12813
  decodeNativePanes,
12646
12814
  encodeNativePanes
12647
12815
  };
12648
- //# sourceMappingURL=chunk-FRH5BWGL.js.map
12816
+ //# sourceMappingURL=chunk-K6P7MQ7K.js.map