@nomba/node-sdk 0.1.0 → 0.3.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.
Files changed (70) hide show
  1. package/README.md +31 -4
  2. package/dist/interfaces/v1/accounts/IAccountsService.d.ts +46 -8
  3. package/dist/interfaces/v1/betting/IBettingService.d.ts +11 -2
  4. package/dist/interfaces/v1/cable/ICableService.d.ts +12 -2
  5. package/dist/interfaces/v1/charge/IChargeService.d.ts +80 -19
  6. package/dist/interfaces/v1/checkout/ICheckoutService.d.ts +64 -15
  7. package/dist/interfaces/v1/data/IDataService.d.ts +6 -1
  8. package/dist/interfaces/v1/direct-debits/IDirectDebitsService.d.ts +37 -14
  9. package/dist/interfaces/v1/electricity/IElectricityService.d.ts +11 -2
  10. package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +20 -5
  11. package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +74 -13
  12. package/dist/interfaces/v1/requery/IRequeryService.d.ts +19 -5
  13. package/dist/interfaces/v1/terminals/ITerminalsService.d.ts +43 -10
  14. package/dist/interfaces/v1/transactions/ITransactionsService.d.ts +71 -12
  15. package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.d.ts +50 -12
  16. package/dist/interfaces/v1/webhooks/IWebhooksService.d.ts +29 -10
  17. package/dist/interfaces/v2/airtime/IAirtimeV2Service.d.ts +21 -2
  18. package/dist/interfaces/v2/betting/IBettingV2Service.d.ts +21 -2
  19. package/dist/interfaces/v2/cable/ICableV2Service.d.ts +21 -2
  20. package/dist/interfaces/v2/data/IDataV2Service.d.ts +21 -2
  21. package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +22 -2
  22. package/dist/interfaces/v2/transfers/ITransfersService.d.ts +57 -6
  23. package/dist/lib/outcome.d.ts +24 -5
  24. package/dist/lib/outcome.js +24 -5
  25. package/dist/lib/sdk-version.generated.d.ts +1 -1
  26. package/dist/lib/sdk-version.generated.js +1 -1
  27. package/dist/nomba.d.ts +38 -5
  28. package/dist/nomba.js +38 -5
  29. package/dist/services/http/http-client.service.d.ts +40 -6
  30. package/dist/services/http/http-client.service.js +40 -6
  31. package/dist/services/v1/accounts/accounts.service.d.ts +46 -8
  32. package/dist/services/v1/accounts/accounts.service.js +46 -8
  33. package/dist/services/v1/betting/betting.service.d.ts +11 -2
  34. package/dist/services/v1/betting/betting.service.js +11 -2
  35. package/dist/services/v1/cable/cable.service.d.ts +12 -2
  36. package/dist/services/v1/cable/cable.service.js +12 -2
  37. package/dist/services/v1/charge/charge.service.d.ts +80 -19
  38. package/dist/services/v1/charge/charge.service.js +88 -26
  39. package/dist/services/v1/checkout/checkout.service.d.ts +63 -15
  40. package/dist/services/v1/checkout/checkout.service.js +70 -24
  41. package/dist/services/v1/data/data.service.d.ts +7 -1
  42. package/dist/services/v1/data/data.service.js +7 -1
  43. package/dist/services/v1/direct-debits/direct-debits.service.d.ts +38 -14
  44. package/dist/services/v1/direct-debits/direct-debits.service.js +39 -17
  45. package/dist/services/v1/electricity/electricity.service.d.ts +12 -2
  46. package/dist/services/v1/electricity/electricity.service.js +12 -2
  47. package/dist/services/v1/globals/collections.service.d.ts +21 -5
  48. package/dist/services/v1/globals/collections.service.js +22 -5
  49. package/dist/services/v1/globals/payout.service.d.ts +73 -13
  50. package/dist/services/v1/globals/payout.service.js +74 -15
  51. package/dist/services/v1/terminals/terminals.service.d.ts +5 -5
  52. package/dist/services/v1/terminals/terminals.service.js +7 -18
  53. package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +4 -5
  54. package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +7 -8
  55. package/dist/services/v1/webhooks/webhooks.service.d.ts +3 -4
  56. package/dist/services/v1/webhooks/webhooks.service.js +7 -8
  57. package/dist/services/v2/airtime/airtime.service.d.ts +26 -2
  58. package/dist/services/v2/airtime/airtime.service.js +27 -7
  59. package/dist/services/v2/betting/betting.service.d.ts +27 -3
  60. package/dist/services/v2/betting/betting.service.js +28 -8
  61. package/dist/services/v2/cable/cable.service.d.ts +27 -3
  62. package/dist/services/v2/cable/cable.service.js +28 -8
  63. package/dist/services/v2/data/data.service.d.ts +26 -2
  64. package/dist/services/v2/data/data.service.js +27 -7
  65. package/dist/services/v2/electricity/electricity.service.d.ts +28 -3
  66. package/dist/services/v2/electricity/electricity.service.js +29 -8
  67. package/dist/services/v2/transfers/transfers.service.d.ts +51 -6
  68. package/dist/services/v2/transfers/transfers.service.js +55 -25
  69. package/dist/types/common/common.types.d.ts +9 -13
  70. package/package.json +1 -1
@@ -14,7 +14,6 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { IChargeService } from "../../../interfaces/v1/charge/IChargeService.js";
17
- import type { RequestOptions } from "../../../types/common/common.types.js";
18
17
  import type { CancelChargeTransactionParams, ChargeOrder, ChargeTransactionDetails, FlashAccount, SaveCardOtpRequest, SubmitCardDetailsParams, SubmitCardDetailsResult, SubmitCardOtpParams, SubmitCardOtpResult, SubmitSaveCardOtpParams } from "../../../types/v1/charge/charge.types.js";
19
18
  import type { CheckoutResult, TokenizedCardData } from "../../../types/v1/checkout/checkout.types.js";
20
19
  /**
@@ -25,28 +24,90 @@ import type { CheckoutResult, TokenizedCardData } from "../../../types/v1/checko
25
24
  export declare class ChargeService implements IChargeService {
26
25
  private readonly http;
27
26
  constructor(http: IHttpClient);
28
- /** GET /v1/checkout/order/{orderReference} */
27
+ /**
28
+ * `GET /v1/checkout/order/{orderReference}`.
29
+ * @param orderReference The order's reference, from `nomba.checkout.createOrder`.
30
+ * @returns The order's details.
31
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
32
+ */
29
33
  getOrder(orderReference: string): Promise<ChargeOrder>;
30
- /** POST /v1/checkout/checkout-card-detail */
31
- submitCardDetails(params: SubmitCardDetailsParams, options?: RequestOptions): Promise<SubmitCardDetailsResult>;
32
- /** POST /v1/checkout/checkout-card-otp */
33
- submitCardOtp(params: SubmitCardOtpParams, options?: RequestOptions): Promise<SubmitCardOtpResult>;
34
- /** POST /v1/checkout/resend-otp. Resends the payment OTP to the customer's phone. */
35
- resendOtp(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
36
- /** POST /v1/checkout/confirm-transaction-receipt. The status after the OTP is submitted or a transfer is made. */
34
+ /**
35
+ * `POST /v1/checkout/checkout-card-detail`.
36
+ * @param params The order reference and card details to charge.
37
+ * @returns The result of submitting the card; an OTP is typically sent next.
38
+ * @throws {NombaError} The call failed, e.g. the card was declined.
39
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
40
+ */
41
+ submitCardDetails(params: SubmitCardDetailsParams): Promise<SubmitCardDetailsResult>;
42
+ /**
43
+ * `POST /v1/checkout/checkout-card-otp`.
44
+ * @param params The order reference and OTP the customer received.
45
+ * @returns The result of submitting the OTP.
46
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
47
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
48
+ */
49
+ submitCardOtp(params: SubmitCardOtpParams): Promise<SubmitCardOtpResult>;
50
+ /**
51
+ * `POST /v1/checkout/resend-otp`. Resends the payment OTP to the customer's phone.
52
+ * @param orderReference The order's reference.
53
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
54
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
55
+ */
56
+ resendOtp(orderReference: string): Promise<CheckoutResult>;
57
+ /**
58
+ * `POST /v1/checkout/confirm-transaction-receipt`. The status after the OTP is submitted or a transfer
59
+ * is made.
60
+ * @param orderReference The order's reference.
61
+ * @returns The transaction's current status.
62
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
63
+ */
37
64
  fetchTransactionDetails(orderReference: string): Promise<ChargeTransactionDetails>;
38
- /** GET /v1/checkout/get-checkout-kta/{orderReference}. A Flash account number the customer can pay by transfer. */
65
+ /**
66
+ * `GET /v1/checkout/get-checkout-kta/{orderReference}`. A Flash account number the customer can pay by
67
+ * transfer.
68
+ * @param orderReference The order's reference.
69
+ * @returns The Flash account to transfer payment to.
70
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
71
+ */
39
72
  fetchFlashAccount(orderReference: string): Promise<FlashAccount>;
40
- /** POST /v1/checkout/transaction/cancel. Cancels an incomplete checkout transaction. */
41
- cancelTransaction(params: CancelChargeTransactionParams, options?: RequestOptions): Promise<CheckoutResult>;
42
- /** POST /v1/checkout/user-card/saved-card/auth. Sends an OTP; use when getOrder says the user has saved cards. */
43
- requestSavedCardsOtp(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
44
- /** GET /v1/checkout/user-card/{orderReference}. Needs the OTP from requestSavedCardsOtp. */
73
+ /**
74
+ * `POST /v1/checkout/transaction/cancel`. Cancels an incomplete checkout transaction.
75
+ * @param params The order reference to cancel.
76
+ * @throws {NombaError} The call failed, e.g. the transaction already completed.
77
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
78
+ */
79
+ cancelTransaction(params: CancelChargeTransactionParams): Promise<CheckoutResult>;
80
+ /**
81
+ * `POST /v1/checkout/user-card/saved-card/auth`. Sends an OTP; use when `getOrder` says the user has
82
+ * saved cards.
83
+ * @param orderReference The order's reference.
84
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
85
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
86
+ */
87
+ requestSavedCardsOtp(orderReference: string): Promise<CheckoutResult>;
88
+ /**
89
+ * `GET /v1/checkout/user-card/{orderReference}`. Needs the OTP from `requestSavedCardsOtp`.
90
+ * @param orderReference The order's reference.
91
+ * @param otp The OTP sent by `requestSavedCardsOtp`.
92
+ * @returns The customer's saved, tokenized cards.
93
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
94
+ */
45
95
  getSavedCards(orderReference: string, otp: string): Promise<{
46
96
  tokenizedCardData?: TokenizedCardData[];
47
97
  }>;
48
- /** POST /v1/checkout/user-card/auth. Sends an OTP before saving a card; call after a successful payment. */
49
- requestSaveCardOtp(params: SaveCardOtpRequest, options?: RequestOptions): Promise<CheckoutResult>;
50
- /** POST /v1/checkout/user-card. Submits the OTP, which saves the card for later use. */
51
- submitSaveCardOtp(params: SubmitSaveCardOtpParams, options?: RequestOptions): Promise<CheckoutResult>;
98
+ /**
99
+ * `POST /v1/checkout/user-card/auth`. Sends an OTP before saving a card; call after a successful
100
+ * payment.
101
+ * @param params The order reference and card to save.
102
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
103
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
104
+ */
105
+ requestSaveCardOtp(params: SaveCardOtpRequest): Promise<CheckoutResult>;
106
+ /**
107
+ * `POST /v1/checkout/user-card`. Submits the OTP, which saves the card for later use.
108
+ * @param params The order reference and OTP from `requestSaveCardOtp`.
109
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
110
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
111
+ */
112
+ submitSaveCardOtp(params: SubmitSaveCardOtpParams): Promise<CheckoutResult>;
52
113
  }
@@ -23,13 +23,24 @@ export class ChargeService {
23
23
  constructor(http) {
24
24
  this.http = http;
25
25
  }
26
- /** GET /v1/checkout/order/{orderReference} */
26
+ /**
27
+ * `GET /v1/checkout/order/{orderReference}`.
28
+ * @param orderReference The order's reference, from `nomba.checkout.createOrder`.
29
+ * @returns The order's details.
30
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
31
+ */
27
32
  async getOrder(orderReference) {
28
33
  return this.http.request("GET", `/v1/checkout/order/${pathId(orderReference)}`);
29
34
  }
30
- /** POST /v1/checkout/checkout-card-detail */
31
- async submitCardDetails(params, options = {}) {
32
- const { cardDetails } = params;
35
+ /**
36
+ * `POST /v1/checkout/checkout-card-detail`.
37
+ * @param params The order reference and card details to charge.
38
+ * @returns The result of submitting the card; an OTP is typically sent next.
39
+ * @throws {NombaError} The call failed, e.g. the card was declined.
40
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
41
+ */
42
+ async submitCardDetails(params) {
43
+ const { cardDetails, orderReference } = params;
33
44
  return this.http.request("POST", "/v1/checkout/checkout-card-detail", {
34
45
  body: {
35
46
  ...params,
@@ -37,63 +48,114 @@ export class ChargeService {
37
48
  cardDetails: JSON.stringify(cardDetails),
38
49
  }),
39
50
  },
40
- ...options,
51
+ ...(orderReference && { idempotencyKey: orderReference }),
41
52
  });
42
53
  }
43
- /** POST /v1/checkout/checkout-card-otp */
44
- submitCardOtp(params, options = {}) {
54
+ /**
55
+ * `POST /v1/checkout/checkout-card-otp`.
56
+ * @param params The order reference and OTP the customer received.
57
+ * @returns The result of submitting the OTP.
58
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
59
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
60
+ */
61
+ submitCardOtp(params) {
45
62
  return this.http.request("POST", "/v1/checkout/checkout-card-otp", {
46
63
  body: params,
47
- ...options,
64
+ idempotencyKey: params.transactionId,
48
65
  });
49
66
  }
50
- /** POST /v1/checkout/resend-otp. Resends the payment OTP to the customer's phone. */
51
- resendOtp(orderReference, options = {}) {
67
+ /**
68
+ * `POST /v1/checkout/resend-otp`. Resends the payment OTP to the customer's phone.
69
+ * @param orderReference The order's reference.
70
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
71
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
72
+ */
73
+ resendOtp(orderReference) {
52
74
  return this.http.request("POST", "/v1/checkout/resend-otp", {
53
75
  body: { orderReference },
54
- ...options,
76
+ idempotencyKey: orderReference,
55
77
  });
56
78
  }
57
- /** POST /v1/checkout/confirm-transaction-receipt. The status after the OTP is submitted or a transfer is made. */
79
+ /**
80
+ * `POST /v1/checkout/confirm-transaction-receipt`. The status after the OTP is submitted or a transfer
81
+ * is made.
82
+ * @param orderReference The order's reference.
83
+ * @returns The transaction's current status.
84
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
85
+ */
58
86
  fetchTransactionDetails(orderReference) {
59
87
  return this.http.request("POST", "/v1/checkout/confirm-transaction-receipt", {
60
88
  body: { orderReference },
61
89
  });
62
90
  }
63
- /** GET /v1/checkout/get-checkout-kta/{orderReference}. A Flash account number the customer can pay by transfer. */
91
+ /**
92
+ * `GET /v1/checkout/get-checkout-kta/{orderReference}`. A Flash account number the customer can pay by
93
+ * transfer.
94
+ * @param orderReference The order's reference.
95
+ * @returns The Flash account to transfer payment to.
96
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
97
+ */
64
98
  async fetchFlashAccount(orderReference) {
65
99
  return this.http.request("GET", `/v1/checkout/get-checkout-kta/${pathId(orderReference)}`);
66
100
  }
67
- /** POST /v1/checkout/transaction/cancel. Cancels an incomplete checkout transaction. */
68
- cancelTransaction(params, options = {}) {
101
+ /**
102
+ * `POST /v1/checkout/transaction/cancel`. Cancels an incomplete checkout transaction.
103
+ * @param params The order reference to cancel.
104
+ * @throws {NombaError} The call failed, e.g. the transaction already completed.
105
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
106
+ */
107
+ cancelTransaction(params) {
69
108
  return this.http.request("POST", "/v1/checkout/transaction/cancel", {
70
109
  body: params,
71
- ...options,
110
+ idempotencyKey: params.transactionId,
72
111
  });
73
112
  }
74
- /** POST /v1/checkout/user-card/saved-card/auth. Sends an OTP; use when getOrder says the user has saved cards. */
75
- requestSavedCardsOtp(orderReference, options = {}) {
113
+ /**
114
+ * `POST /v1/checkout/user-card/saved-card/auth`. Sends an OTP; use when `getOrder` says the user has
115
+ * saved cards.
116
+ * @param orderReference The order's reference.
117
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
118
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
119
+ */
120
+ requestSavedCardsOtp(orderReference) {
76
121
  return this.http.request("POST", "/v1/checkout/user-card/saved-card/auth", {
77
122
  body: { orderReference },
78
- ...options,
123
+ idempotencyKey: orderReference,
79
124
  });
80
125
  }
81
- /** GET /v1/checkout/user-card/{orderReference}. Needs the OTP from requestSavedCardsOtp. */
126
+ /**
127
+ * `GET /v1/checkout/user-card/{orderReference}`. Needs the OTP from `requestSavedCardsOtp`.
128
+ * @param orderReference The order's reference.
129
+ * @param otp The OTP sent by `requestSavedCardsOtp`.
130
+ * @returns The customer's saved, tokenized cards.
131
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
132
+ */
82
133
  async getSavedCards(orderReference, otp) {
83
134
  return this.http.request("GET", `/v1/checkout/user-card/${pathId(orderReference)}`, { query: { otp } });
84
135
  }
85
- /** POST /v1/checkout/user-card/auth. Sends an OTP before saving a card; call after a successful payment. */
86
- requestSaveCardOtp(params, options = {}) {
136
+ /**
137
+ * `POST /v1/checkout/user-card/auth`. Sends an OTP before saving a card; call after a successful
138
+ * payment.
139
+ * @param params The order reference and card to save.
140
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
141
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
142
+ */
143
+ requestSaveCardOtp(params) {
87
144
  return this.http.request("POST", "/v1/checkout/user-card/auth", {
88
145
  body: params,
89
- ...options,
146
+ idempotencyKey: params.orderReference,
90
147
  });
91
148
  }
92
- /** POST /v1/checkout/user-card. Submits the OTP, which saves the card for later use. */
93
- submitSaveCardOtp(params, options = {}) {
149
+ /**
150
+ * `POST /v1/checkout/user-card`. Submits the OTP, which saves the card for later use.
151
+ * @param params The order reference and OTP from `requestSaveCardOtp`.
152
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
153
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
154
+ */
155
+ submitSaveCardOtp(params) {
94
156
  return this.http.request("POST", "/v1/checkout/user-card", {
95
157
  body: params,
96
- ...options,
158
+ idempotencyKey: params.orderReference,
97
159
  });
98
160
  }
99
161
  }
@@ -14,31 +14,79 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { ICheckoutService } from "../../../interfaces/v1/checkout/ICheckoutService.js";
17
- import type { CallOptions, RequestOptions } from "../../../types/common/common.types.js";
17
+ import type { CallOptions } from "../../../types/common/common.types.js";
18
18
  import type { ChargeTokenizedCardParams, CheckoutOrderCreated, CheckoutResult, CheckoutTransaction, CreateCheckoutOrderParams, FetchCheckoutTransactionParams, ListTokenizedCardsParams, RefundCheckoutTransactionParams, TokenizedCardData, TokenizedCardList, TokenizedCardResult, UpdatedTokenizedCard, UpdateTokenizedCardParams } from "../../../types/v1/checkout/checkout.types.js";
19
19
  export declare class CheckoutService implements ICheckoutService {
20
20
  private readonly http;
21
21
  constructor(http: IHttpClient);
22
22
  /**
23
- * POST /v1/checkout/order. Send the customer to `checkoutLink` to pay.
23
+ * `POST /v1/checkout/order`. Send the customer to `checkoutLink` to pay.
24
24
  * Verified against a real sandbox call to use /v1/checkout/order, not /sandbox/checkout/order as the
25
25
  * sandbox-testing guide claims (that path 404s); sandbox and production share this path.
26
+ * @param params The order to create; `order.orderReference` is the idempotency key when provided.
27
+ * @returns The created order, including `checkoutLink`.
28
+ * @throws {NombaError} The call failed.
29
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
30
+ */
31
+ createOrder(params: CreateCheckoutOrderParams): Promise<CheckoutOrderCreated>;
32
+ /**
33
+ * `GET /v1/checkout/transaction`. Verified in sandbox; see the note on `createOrder`.
34
+ * @param params Which transaction to fetch, e.g. by `orderReference`.
35
+ * @returns The matching transaction.
36
+ * @throws {NombaError} The call failed, e.g. no transaction matches.
26
37
  */
27
- createOrder(params: CreateCheckoutOrderParams, options?: RequestOptions): Promise<CheckoutOrderCreated>;
28
- /** GET /v1/checkout/transaction. Verified in sandbox; see the note on createOrder. */
29
38
  fetchTransaction(params?: FetchCheckoutTransactionParams): Promise<CheckoutTransaction>;
30
- /** POST /v1/checkout/order/cancel. Only for orders not yet paid; use `refund` after payment. */
31
- cancelOrder(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
32
- /** POST /v1/checkout/refund. Verified in sandbox; see the note on createOrder. */
39
+ /**
40
+ * `POST /v1/checkout/order/cancel`. Only for orders not yet paid; use `refund` after payment.
41
+ * @param orderReference The order's reference (used as idempotency key).
42
+ * @throws {NombaError} The call failed, e.g. the order was already paid.
43
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
44
+ */
45
+ cancelOrder(orderReference: string): Promise<CheckoutResult>;
46
+ /**
47
+ * `POST /v1/checkout/refund`. Verified in sandbox; see the note on `createOrder`.
48
+ * @param params The transaction to refund; `transactionId` is the idempotency key.
49
+ * @param options Outcome polling/mapping and other per-call overrides.
50
+ * @returns The refund result, or the outcome `options` maps it to.
51
+ * @throws {NombaError} The call failed and is not retryable.
52
+ * @throws {UnconfirmedOutcomeError} The outcome stayed pending after polling ran out.
53
+ */
33
54
  refund<R = CheckoutResult>(params: RefundCheckoutTransactionParams, options?: CallOptions<CheckoutResult, R>): Promise<CheckoutResult | R>;
34
- /** POST /v1/checkout/tokenized-card-payment. Check `status` on the result: it says whether the charge went through. */
35
- chargeTokenizedCard(params: ChargeTokenizedCardParams, options?: RequestOptions): Promise<TokenizedCardResult>;
36
- /** GET /v1/checkout/tokenized-card-data */
55
+ /**
56
+ * `POST /v1/checkout/tokenized-card-payment`. Check `status` on the result: it says whether the charge
57
+ * went through.
58
+ * @param params The tokenized card and amount to charge; `order.orderReference` is the idempotency key when provided.
59
+ * @returns The charge result.
60
+ * @throws {NombaError} The call failed, e.g. the token is invalid or expired.
61
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
62
+ */
63
+ chargeTokenizedCard(params: ChargeTokenizedCardParams): Promise<TokenizedCardResult>;
64
+ /**
65
+ * `GET /v1/checkout/tokenized-card-data`.
66
+ * @param params Pagination (`page`) and other list filters.
67
+ * @returns One page of the customer's saved, tokenized cards.
68
+ * @throws {NombaError} The call failed.
69
+ */
37
70
  listTokenizedCards(params?: ListTokenizedCardsParams): Promise<TokenizedCardList>;
38
- /** Every tokenized card matching the filters, across all pages. Starts at `params.page` if given. */
71
+ /**
72
+ * Every tokenized card matching the filters, across all pages. Starts at `params.page` if given.
73
+ * @param params Starting page and other list filters.
74
+ * @throws {NombaError} A page request failed.
75
+ */
39
76
  iterateTokenizedCards(params?: ListTokenizedCardsParams): AsyncGenerator<TokenizedCardData>;
40
- /** POST /v1/checkout/tokenized-card-data */
41
- updateTokenizedCard(params: UpdateTokenizedCardParams, options?: RequestOptions): Promise<UpdatedTokenizedCard>;
42
- /** DELETE /v1/checkout/tokenized-card-data */
43
- deleteTokenizedCard(tokenKey: string, options?: RequestOptions): Promise<TokenizedCardResult>;
77
+ /**
78
+ * `POST /v1/checkout/tokenized-card-data`.
79
+ * @param params The tokenized card's key and the fields to update; `tokenKey` is the idempotency key.
80
+ * @returns The updated tokenized card.
81
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
82
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
83
+ */
84
+ updateTokenizedCard(params: UpdateTokenizedCardParams): Promise<UpdatedTokenizedCard>;
85
+ /**
86
+ * `DELETE /v1/checkout/tokenized-card-data`.
87
+ * @param tokenKey The tokenized card's key (used as idempotency key).
88
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
89
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
90
+ */
91
+ deleteTokenizedCard(tokenKey: string): Promise<TokenizedCardResult>;
44
92
  }
@@ -30,51 +30,86 @@ export class CheckoutService {
30
30
  this.http = http;
31
31
  }
32
32
  /**
33
- * POST /v1/checkout/order. Send the customer to `checkoutLink` to pay.
33
+ * `POST /v1/checkout/order`. Send the customer to `checkoutLink` to pay.
34
34
  * Verified against a real sandbox call to use /v1/checkout/order, not /sandbox/checkout/order as the
35
35
  * sandbox-testing guide claims (that path 404s); sandbox and production share this path.
36
+ * @param params The order to create; `order.orderReference` is the idempotency key when provided.
37
+ * @returns The created order, including `checkoutLink`.
38
+ * @throws {NombaError} The call failed.
39
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
36
40
  */
37
- createOrder(params, options = {}) {
38
- // Your own orderReference is the natural idempotency key for an order; if neither it nor an
39
- // explicit option is set, the client falls back to a generated UUID.
40
- const idempotencyKey = options.idempotencyKey ?? params.order.orderReference;
41
+ createOrder(params) {
42
+ const ref = params.order.orderReference;
41
43
  return this.http.request("POST", "/v1/checkout/order", {
42
44
  body: params,
43
- ...options,
44
- ...(idempotencyKey !== undefined && { idempotencyKey }),
45
+ ...(ref ? { idempotencyKey: ref } : {}),
45
46
  });
46
47
  }
47
- /** GET /v1/checkout/transaction. Verified in sandbox; see the note on createOrder. */
48
+ /**
49
+ * `GET /v1/checkout/transaction`. Verified in sandbox; see the note on `createOrder`.
50
+ * @param params Which transaction to fetch, e.g. by `orderReference`.
51
+ * @returns The matching transaction.
52
+ * @throws {NombaError} The call failed, e.g. no transaction matches.
53
+ */
48
54
  fetchTransaction(params = {}) {
49
55
  return this.http.request("GET", "/v1/checkout/transaction", {
50
56
  query: params,
51
57
  });
52
58
  }
53
- /** POST /v1/checkout/order/cancel. Only for orders not yet paid; use `refund` after payment. */
54
- cancelOrder(orderReference, options = {}) {
59
+ /**
60
+ * `POST /v1/checkout/order/cancel`. Only for orders not yet paid; use `refund` after payment.
61
+ * @param orderReference The order's reference (used as idempotency key).
62
+ * @throws {NombaError} The call failed, e.g. the order was already paid.
63
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
64
+ */
65
+ cancelOrder(orderReference) {
55
66
  return this.http.request("POST", "/v1/checkout/order/cancel", {
56
67
  body: { orderReference },
57
- ...options,
68
+ idempotencyKey: orderReference,
58
69
  });
59
70
  }
60
- /** POST /v1/checkout/refund. Verified in sandbox; see the note on createOrder. */
71
+ /**
72
+ * `POST /v1/checkout/refund`. Verified in sandbox; see the note on `createOrder`.
73
+ * @param params The transaction to refund; `transactionId` is the idempotency key.
74
+ * @param options Outcome polling/mapping and other per-call overrides.
75
+ * @returns The refund result, or the outcome `options` maps it to.
76
+ * @throws {NombaError} The call failed and is not retryable.
77
+ * @throws {UnconfirmedOutcomeError} The outcome stayed pending after polling ran out.
78
+ */
61
79
  async refund(params, options = {}) {
62
- return settle(this.http, "POST", "/v1/checkout/refund", { body: params }, REFUND_OUTCOMES, options);
80
+ return settle(this.http, "POST", "/v1/checkout/refund", { body: params }, REFUND_OUTCOMES, params.transactionId, options);
63
81
  }
64
- /** POST /v1/checkout/tokenized-card-payment. Check `status` on the result: it says whether the charge went through. */
65
- chargeTokenizedCard(params, options = {}) {
82
+ /**
83
+ * `POST /v1/checkout/tokenized-card-payment`. Check `status` on the result: it says whether the charge
84
+ * went through.
85
+ * @param params The tokenized card and amount to charge; `order.orderReference` is the idempotency key when provided.
86
+ * @returns The charge result.
87
+ * @throws {NombaError} The call failed, e.g. the token is invalid or expired.
88
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
89
+ */
90
+ chargeTokenizedCard(params) {
91
+ const ref = params.order?.orderReference;
66
92
  return this.http.request("POST", "/v1/checkout/tokenized-card-payment", {
67
93
  body: params,
68
- ...options,
94
+ ...(ref ? { idempotencyKey: ref } : {}),
69
95
  });
70
96
  }
71
- /** GET /v1/checkout/tokenized-card-data */
97
+ /**
98
+ * `GET /v1/checkout/tokenized-card-data`.
99
+ * @param params Pagination (`page`) and other list filters.
100
+ * @returns One page of the customer's saved, tokenized cards.
101
+ * @throws {NombaError} The call failed.
102
+ */
72
103
  listTokenizedCards(params = {}) {
73
104
  return this.http.request("GET", "/v1/checkout/tokenized-card-data", {
74
105
  query: params,
75
106
  });
76
107
  }
77
- /** Every tokenized card matching the filters, across all pages. Starts at `params.page` if given. */
108
+ /**
109
+ * Every tokenized card matching the filters, across all pages. Starts at `params.page` if given.
110
+ * @param params Starting page and other list filters.
111
+ * @throws {NombaError} A page request failed.
112
+ */
78
113
  iterateTokenizedCards(params = {}) {
79
114
  return paginate(async (cursor) => {
80
115
  const r = await this.listTokenizedCards(cursor ? { ...params, page: Number(cursor) } : params);
@@ -83,18 +118,29 @@ export class CheckoutService {
83
118
  return { results: r.tokenizedCardDataList ?? [], cursor: next };
84
119
  });
85
120
  }
86
- /** POST /v1/checkout/tokenized-card-data */
87
- updateTokenizedCard(params, options = {}) {
121
+ /**
122
+ * `POST /v1/checkout/tokenized-card-data`.
123
+ * @param params The tokenized card's key and the fields to update; `tokenKey` is the idempotency key.
124
+ * @returns The updated tokenized card.
125
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
126
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
127
+ */
128
+ updateTokenizedCard(params) {
88
129
  return this.http.request("POST", "/v1/checkout/tokenized-card-data", {
89
130
  body: params,
90
- ...options,
131
+ idempotencyKey: params.tokenKey,
91
132
  });
92
133
  }
93
- /** DELETE /v1/checkout/tokenized-card-data */
94
- deleteTokenizedCard(tokenKey, options = {}) {
134
+ /**
135
+ * `DELETE /v1/checkout/tokenized-card-data`.
136
+ * @param tokenKey The tokenized card's key (used as idempotency key).
137
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
138
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
139
+ */
140
+ deleteTokenizedCard(tokenKey) {
95
141
  return this.http.request("DELETE", "/v1/checkout/tokenized-card-data", {
96
142
  body: { tokenKey },
97
- ...options,
143
+ idempotencyKey: tokenKey,
98
144
  });
99
145
  }
100
146
  }
@@ -6,9 +6,15 @@
6
6
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IDataService } from "../../../interfaces/v1/data/index.js";
8
8
  import type { DataPlansResult } from "../../../types/v1/data/data.types.js";
9
+ /** Data bundle plans (v1): lookup only, no purchase endpoint. */
9
10
  export declare class DataService implements IDataService {
10
11
  private readonly http;
11
12
  constructor(http: IHttpClient);
12
- /** GET /v1/bill/data-plan/{telco} */
13
+ /**
14
+ * `GET /v1/bill/data-plan/{telco}`.
15
+ * @param telco The telco network to list data plans for.
16
+ * @returns The available data plans for that telco.
17
+ * @throws {NombaError} `telco` is not a recognized network, or the request failed.
18
+ */
13
19
  getDataPlans(telco: string): Promise<DataPlansResult>;
14
20
  }
@@ -4,12 +4,18 @@
4
4
  * @see https://developer.nomba.com/docs/api-reference/bills
5
5
  */
6
6
  import { pathId } from "../../../lib/util.js";
7
+ /** Data bundle plans (v1): lookup only, no purchase endpoint. */
7
8
  export class DataService {
8
9
  http;
9
10
  constructor(http) {
10
11
  this.http = http;
11
12
  }
12
- /** GET /v1/bill/data-plan/{telco} */
13
+ /**
14
+ * `GET /v1/bill/data-plan/{telco}`.
15
+ * @param telco The telco network to list data plans for.
16
+ * @returns The available data plans for that telco.
17
+ * @throws {NombaError} `telco` is not a recognized network, or the request failed.
18
+ */
13
19
  getDataPlans(telco) {
14
20
  return this.http.request("GET", `/v1/bill/data-plan/${pathId(telco)}`);
15
21
  }
@@ -14,32 +14,56 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { IDirectDebitsService } from "../../../interfaces/v1/direct-debits/IDirectDebitsService.js";
17
- import type { RequestOptions } from "../../../types/common/common.types.js";
18
17
  import type { CreatedMandate, CreateMandateParams, DebitMandateParams, ListMandatesParams, MandateDebitResult, MandatePage, MandateStatus, UpdatedMandateStatus, UpdateMandateStatusParams } from "../../../types/v1/direct-debits/direct-debits.types.js";
18
+ /** Direct debit mandates (v1): create, inspect, debit, and update recurring mandates. */
19
19
  export declare class DirectDebitsService implements IDirectDebitsService {
20
20
  private readonly http;
21
21
  constructor(http: IHttpClient);
22
22
  /**
23
- * POST /v1/direct-debits.
23
+ * `POST /v1/direct-debits`.
24
24
  * ponytail: this endpoint's response envelope is `{ responseCode, responseMessage, data }`, unlike every
25
25
  * other endpoint's `{ code, description, data }` — confirmed from the spec's own example, not guessed.
26
+ * @param params The mandate to create; `merchantReference` is the idempotency key.
27
+ * @returns The created mandate.
28
+ * @throws {NombaError} The mandate params were rejected.
29
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
30
+ * check the mandate status before retrying.
31
+ */
32
+ createMandate(params: CreateMandateParams): Promise<CreatedMandate>;
33
+ /**
34
+ * `GET /v1/direct-debits/status?mandateId={mandateId}`.
35
+ * @param mandateId The mandate to look up.
36
+ * @returns The mandate's current status.
37
+ * @throws {NombaError} `mandateId` is not found, or the request failed.
26
38
  */
27
- createMandate(params: CreateMandateParams, options?: RequestOptions): Promise<CreatedMandate>;
28
- /** GET /v1/direct-debits/status?mandateId={mandateId} */
29
39
  getMandateStatus(mandateId: string): Promise<MandateStatus>;
30
40
  /**
31
- * POST /v1/direct-debits/debit-mandate. Unlike createMandate, there is no per-transaction reference
32
- * field to default the idempotency key to (mandateId is stable across every debit on that mandate, so
33
- * defaulting to it would give every recurring debit the same key). Pass your own idempotencyKey if you
34
- * need retries deduplicated; otherwise the client generates a fresh one per call.
41
+ * `POST /v1/direct-debits/debit-mandate`. No per-transaction reference field exists in params, so a
42
+ * random idempotency key is generated for error tracking. If the outcome is unknown, requery the mandate
43
+ * before retrying.
44
+ * @param params The mandate to debit and the amount.
45
+ * @returns The debit result.
46
+ * @throws {NombaError} The mandate is not active, or the debit was rejected.
47
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
48
+ * check the mandate status before retrying.
49
+ */
50
+ debitMandate(params: DebitMandateParams): Promise<MandateDebitResult>;
51
+ /**
52
+ * `GET /v1/direct-debits/mandates`.
53
+ * @param params Pagination and filter params.
54
+ * @returns A page of mandates.
55
+ * @throws {NombaError} The request failed.
35
56
  */
36
- debitMandate(params: DebitMandateParams, options?: RequestOptions): Promise<MandateDebitResult>;
37
- /** GET /v1/direct-debits/mandates */
38
57
  listMandates(params: ListMandatesParams): Promise<MandatePage>;
39
58
  /**
40
- * PUT /v1/direct-debits/update-status. Same reasoning as debitMandate: mandateId is stable across every
41
- * status change on that mandate (SUSPEND, then ACTIVE, then SUSPEND again), so it is not a safe default
42
- * idempotency key. Pass your own if you need a retry deduplicated.
59
+ * `PUT /v1/direct-debits/update-status`. No per-change reference field exists in params, so a random
60
+ * idempotency key is generated for error tracking. If the outcome is unknown, check the mandate status
61
+ * before retrying.
62
+ * @param params The mandate and the new status.
63
+ * @returns The mandate's updated status.
64
+ * @throws {NombaError} The status transition is invalid, or the request failed.
65
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
66
+ * check the mandate status before retrying.
43
67
  */
44
- updateMandateStatus(params: UpdateMandateStatusParams, options?: RequestOptions): Promise<UpdatedMandateStatus>;
68
+ updateMandateStatus(params: UpdateMandateStatusParams): Promise<UpdatedMandateStatus>;
45
69
  }