@delopay/sdk 0.133.0 → 0.136.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
@@ -1045,10 +1045,68 @@ var Customers = class {
1045
1045
  query: toQuery(params)
1046
1046
  });
1047
1047
  }
1048
+ /**
1049
+ * Retrieve one customer, scoped to the authenticated dashboard user's shop
1050
+ * (business profile). The shop-scoped counterpart of {@link retrieve}, and
1051
+ * what makes a shop's own customer list clickable: the list is
1052
+ * `ProfileCustomerRead` while {@link retrieve} is merchant-level, so a shop
1053
+ * member could see a customer they could not open.
1054
+ *
1055
+ * A customer belonging to a sibling shop answers `CustomerNotFound` — the
1056
+ * same answer as a customer that does not exist, deliberately, so one shop
1057
+ * cannot enumerate another's customer ids.
1058
+ *
1059
+ * `GET /customers/profile/{customerId}`
1060
+ *
1061
+ * @param customerId - The unique customer ID.
1062
+ * @returns The customer, with `profile_ids` narrowed to the caller's own shop.
1063
+ */
1064
+ async retrieveByProfile(customerId) {
1065
+ return this.request("GET", `/customers/profile/${encodeURIComponent(customerId)}`);
1066
+ }
1067
+ /**
1068
+ * Create a customer from a shop, recording that it belongs to that shop so
1069
+ * the shop can see the customer it just created. The shop is taken from the
1070
+ * credential; a caller-chosen `customer_id` is rejected.
1071
+ *
1072
+ * `POST /customers/profile`
1073
+ *
1074
+ * @param params - The customer to create.
1075
+ * @returns The created customer.
1076
+ */
1077
+ async createByProfile(params) {
1078
+ return this.request("POST", "/customers/profile", { body: params });
1079
+ }
1080
+ /**
1081
+ * Update a customer from a shop, if the customer belongs to that shop.
1082
+ * A sibling shop's customer answers `CustomerNotFound`, as with
1083
+ * {@link retrieveByProfile}.
1084
+ *
1085
+ * `POST /customers/profile/{customerId}`
1086
+ *
1087
+ * @param customerId - The customer ID to update.
1088
+ * @param params - Fields to update.
1089
+ * @returns The updated customer.
1090
+ */
1091
+ async updateByProfile(customerId, params) {
1092
+ return this.request("POST", `/customers/profile/${encodeURIComponent(customerId)}`, {
1093
+ body: params
1094
+ });
1095
+ }
1048
1096
  /** List mandates for a customer. `GET /customers/{customerId}/mandates` */
1049
1097
  async listMandates(customerId) {
1050
1098
  return this.request("GET", `/customers/${encodeURIComponent(customerId)}/mandates`);
1051
1099
  }
1100
+ /**
1101
+ * List one customer's mandates, scoped to the caller's shop. Same membership
1102
+ * rule as {@link retrieveByProfile}: a sibling shop's customer answers
1103
+ * `CustomerNotFound` before any mandate is read.
1104
+ *
1105
+ * `GET /customers/profile/{customerId}/mandates`
1106
+ */
1107
+ async listMandatesByProfile(customerId) {
1108
+ return this.request("GET", `/customers/profile/${encodeURIComponent(customerId)}/mandates`);
1109
+ }
1052
1110
  };
1053
1111
 
1054
1112
  // src/resources/disputes.ts
@@ -1218,11 +1276,39 @@ var Events = class {
1218
1276
  `/events/${encodeURIComponent(merchantId)}/${encodeURIComponent(eventId)}/retry`
1219
1277
  );
1220
1278
  }
1279
+ /**
1280
+ * Fire an outgoing webhook event by hand for one object.
1281
+ * `POST /events/{merchant_id}/trigger` (be#318)
1282
+ *
1283
+ * Not a replay — see {@link EventManualTriggerRequest}. Needs the
1284
+ * `WebhookEventTrigger` permission, which is separate from the one that
1285
+ * authorizes {@link retryDelivery}, and is JWT-only: a forged payload must
1286
+ * be attributable to a person.
1287
+ */
1288
+ async trigger(merchantId, body) {
1289
+ return this.request("POST", `/events/${encodeURIComponent(merchantId)}/trigger`, { body });
1290
+ }
1221
1291
  // --- Profile-scoped listing (Task 4.12) ---
1222
- /** List events (profile-scoped). `POST /events/profile/list` */
1292
+ /**
1293
+ * List events (profile-scoped). `POST /events/profile/list`
1294
+ *
1295
+ * Takes the same constraints as {@link list} — it is the same endpoint
1296
+ * narrowed to the caller's own shop, so `profile_id` is redundant and
1297
+ * ignored there.
1298
+ */
1223
1299
  async listByProfile(params) {
1224
1300
  return this.request("POST", "/events/profile/list", { body: params });
1225
1301
  }
1302
+ /**
1303
+ * Fire an outgoing webhook event by hand (profile-scoped).
1304
+ * `POST /events/profile/trigger` (be#318)
1305
+ *
1306
+ * The shop-user twin of {@link trigger}; the shop is taken from the auth
1307
+ * context, so `profile_id` on the body is ignored.
1308
+ */
1309
+ async triggerByProfile(body) {
1310
+ return this.request("POST", "/events/profile/trigger", { body });
1311
+ }
1226
1312
  };
1227
1313
 
1228
1314
  // src/resources/fees.ts
@@ -1752,6 +1838,43 @@ var Payments = class {
1752
1838
  options
1753
1839
  );
1754
1840
  }
1841
+ /**
1842
+ * What the payment's rail says about settling each attempt: whether the
1843
+ * money is still `pending` in the rail's hands, `available` in its balance
1844
+ * (**not** paid out), `paid_out` to a bank — with the payout's date and
1845
+ * reference — or came back as `payout_failed`; and, for the rest, which
1846
+ * kind of not-knowing applies (`unavailable`, `unknown`, `not_recorded`).
1847
+ * See {@link ConnectorSettlementStatus} for the seven values. The same
1848
+ * status for the active attempt rides on every list row and retrieve as
1849
+ * `connector_settlement_status`, and the list filters on it.
1850
+ *
1851
+ * Not the hosted-shop settlement API under `settlement.*`, which is host →
1852
+ * shop owner and manual; this is acquirer → merchant bank, per payment.
1853
+ *
1854
+ * `GET /payments/{paymentId}/settlement`
1855
+ *
1856
+ * @param paymentId - The payment intent ID.
1857
+ * @param options - Optional per-call extras: extra `headers`, a `timeout`
1858
+ * override, and an `AbortSignal`.
1859
+ * @returns The attempts this caller may see, oldest first, each with its
1860
+ * settlement status.
1861
+ * @throws If the payment does not exist (404), or the caller is a
1862
+ * profile-scoped (shop) role, who is refused rather than shown a redacted
1863
+ * body (403).
1864
+ *
1865
+ * @example
1866
+ * ```typescript
1867
+ * const { attempts } = await delopay.payments.settlement('pay_abc123');
1868
+ * for (const attempt of attempts) {
1869
+ * if (attempt.status === 'paid_out') {
1870
+ * console.log(attempt.paid_out_at, attempt.payout_reference);
1871
+ * }
1872
+ * }
1873
+ * ```
1874
+ */
1875
+ async settlement(paymentId, options) {
1876
+ return this.request("GET", `/payments/${encodeURIComponent(paymentId)}/settlement`, options);
1877
+ }
1755
1878
  /**
1756
1879
  * Update an existing payment intent before it is confirmed.
1757
1880
  *
@@ -1923,7 +2046,10 @@ var Payments = class {
1923
2046
  /**
1924
2047
  * List payments by filter, scoped to the caller's profile (the shop-user
1925
2048
  * twin of `listByFilter`). The backend narrows to the profile from the
1926
- * auth context, so `profile_id` / `project_id` must not be sent.
2049
+ * auth context, so `profile_id` / `project_id` must not be sent — and
2050
+ * neither may `connector_settlement_status`, which this route refuses
2051
+ * (403): a shop-scoped viewer is not shown the settlement state, and the
2052
+ * type leaves the key out so it cannot be probed through `total_count`.
1927
2053
  *
1928
2054
  * Not to be confused with {@link Payments.listByProfile}, which is the GET
1929
2055
  * cursor variant and rejects this body.