@appweaver/payments 0.0.0-stage → 3.1.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/LICENSE +21 -0
- package/README.md +212 -2
- package/config.d.ts +77 -0
- package/config.js +118 -0
- package/gateway/fake-gateway.d.ts +144 -0
- package/gateway/fake-gateway.js +805 -0
- package/gateway/gateway-registry.d.ts +99 -0
- package/gateway/gateway-registry.js +275 -0
- package/gateway/payment-gateway.d.ts +68 -0
- package/gateway/payment-gateway.js +82 -0
- package/index.d.ts +16 -0
- package/index.js +51 -0
- package/locales/en.json +47 -0
- package/maintenance/payment-maintenance-jobs.d.ts +5 -0
- package/maintenance/payment-maintenance-jobs.js +38 -0
- package/module.d.ts +8 -0
- package/module.js +85 -0
- package/package.json +67 -3
- package/resources/model-util.d.ts +40 -0
- package/resources/model-util.js +30 -0
- package/resources/payment/model.d.ts +2 -0
- package/resources/payment/model.js +106 -0
- package/resources/payment-customer/model.d.ts +2 -0
- package/resources/payment-customer/model.js +53 -0
- package/resources/payment-event/model.d.ts +2 -0
- package/resources/payment-event/model.js +31 -0
- package/resources/payment-invoice/model.d.ts +2 -0
- package/resources/payment-invoice/model.js +55 -0
- package/resources/payment-method/model.d.ts +2 -0
- package/resources/payment-method/model.js +37 -0
- package/resources/payment-plan/model.d.ts +2 -0
- package/resources/payment-plan/model.js +37 -0
- package/resources/payment-subscription/model.d.ts +2 -0
- package/resources/payment-subscription/model.js +82 -0
- package/resources/payment-transaction/model.d.ts +2 -0
- package/resources/payment-transaction/model.js +43 -0
- package/resources/payment-webhook-event/model.d.ts +2 -0
- package/resources/payment-webhook-event/model.js +32 -0
- package/resources/policies.d.ts +15 -0
- package/resources/policies.js +36 -0
- package/resources/services.d.ts +6 -0
- package/resources/services.js +19 -0
- package/resources/subscriptions.d.ts +9 -0
- package/resources/subscriptions.js +30 -0
- package/resources.d.ts +8 -0
- package/resources.js +34 -0
- package/service/payment-emails.d.ts +12 -0
- package/service/payment-emails.js +145 -0
- package/service/payment-events.d.ts +90 -0
- package/service/payment-events.js +472 -0
- package/service/payment-handlers.d.ts +26 -0
- package/service/payment-handlers.js +42 -0
- package/service/payment-store.d.ts +50 -0
- package/service/payment-store.js +95 -0
- package/service/payment-sync.d.ts +113 -0
- package/service/payment-sync.js +745 -0
- package/service/payments-service.d.ts +307 -0
- package/service/payments-service.js +747 -0
- package/service/subscriptions-service.d.ts +178 -0
- package/service/subscriptions-service.js +433 -0
- package/tasks/payments-replay.d.ts +10 -0
- package/tasks/payments-replay.js +36 -0
- package/tasks/payments-sync-plans.d.ts +10 -0
- package/tasks/payments-sync-plans.js +24 -0
- package/templates/emails/payment-action-required.html.hbs +28 -0
- package/templates/emails/payment-action-required.subject.hbs +1 -0
- package/templates/emails/payment-failed.html.hbs +37 -0
- package/templates/emails/payment-failed.subject.hbs +1 -0
- package/templates/emails/payment-receipt.html.hbs +45 -0
- package/templates/emails/payment-receipt.subject.hbs +1 -0
- package/templates/emails/payment-refunded.html.hbs +37 -0
- package/templates/emails/payment-refunded.subject.hbs +1 -0
- package/templates/emails/subscription-canceled.html.hbs +24 -0
- package/templates/emails/subscription-canceled.subject.hbs +1 -0
- package/templates/emails/subscription-trial-ending.html.hbs +25 -0
- package/templates/emails/subscription-trial-ending.subject.hbs +1 -0
- package/templates/layouts/email.html.hbs +36 -0
- package/templates/partials/email-button.html.hbs +15 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types.d.ts +488 -0
- package/types.js +2 -0
- package/utils/money-util.d.ts +61 -0
- package/utils/money-util.js +124 -0
- package/utils/status-util.d.ts +29 -0
- package/utils/status-util.js +93 -0
- package/utils/telemetry.d.ts +16 -0
- package/utils/telemetry.js +69 -0
- package/web/payment-routes.d.ts +7 -0
- package/web/payment-routes.js +410 -0
- package/web/payment-schemas.d.ts +70 -0
- package/web/payment-schemas.js +101 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { HEALTH_CHECK, HealthCheckConfig, HealthCheckResult, IHealthCheck, LIFECYCLE, OnInit } from '@appweaver/common';
|
|
2
|
+
import { GatewaySelection } from '../gateway/gateway-registry';
|
|
3
|
+
import { PaymentGateway } from '../gateway/payment-gateway';
|
|
4
|
+
import { CaptureMethod, PaymentCapability, PaymentCustomerRecord, PaymentMetadata, PaymentMethodRecord, PaymentNextAction, PaymentRecord, PaymentTransactionRecord } from '../types';
|
|
5
|
+
/** Who pays: the user of the application, with what the gateway knows them by. */
|
|
6
|
+
export type PaymentCustomerInput = Omit<GatewaySelection, 'userId'> & {
|
|
7
|
+
/** The ID of the user, stored as text */
|
|
8
|
+
userId: string | number;
|
|
9
|
+
email?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
locale?: string;
|
|
12
|
+
};
|
|
13
|
+
export type CreatePaymentInput = Omit<GatewaySelection, 'userId'> & {
|
|
14
|
+
/** The amount in the minor units of the currency, i.e. `1999` for 19.99 USD */
|
|
15
|
+
amount: number;
|
|
16
|
+
/** The ISO 4217 code of the currency. Default: `payments.currency`. */
|
|
17
|
+
currency?: string;
|
|
18
|
+
/** The user paying, whose customer of the gateway is created on their first payment */
|
|
19
|
+
userId?: string | number;
|
|
20
|
+
email?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
locale?: string;
|
|
23
|
+
/** The ID of a saved payment method of the user to charge at once, without the client */
|
|
24
|
+
paymentMethodId?: string;
|
|
25
|
+
/** Charge the saved method while the user is away, i.e. from a job */
|
|
26
|
+
offSession?: boolean;
|
|
27
|
+
/** Save the payment method of the payment for later ones */
|
|
28
|
+
savePaymentMethod?: boolean;
|
|
29
|
+
/** `manual` only authorizes the amount, taken later with `capturePayment`. Default: `automatic`. */
|
|
30
|
+
captureMethod?: CaptureMethod;
|
|
31
|
+
description?: string;
|
|
32
|
+
/** The text on the statement of the customer */
|
|
33
|
+
statementDescriptor?: string;
|
|
34
|
+
/** What the payment is for in the application, i.e. the ID of an order */
|
|
35
|
+
reference?: string;
|
|
36
|
+
/** The kind of the reference, i.e. `order` */
|
|
37
|
+
referenceType?: string;
|
|
38
|
+
/** A key of the caller: a second call with it returns the payment of the first one */
|
|
39
|
+
idempotencyKey?: string;
|
|
40
|
+
/** Where the gateway sends the customer back after a redirect, i.e. of their bank */
|
|
41
|
+
returnUrl?: string;
|
|
42
|
+
metadata?: PaymentMetadata;
|
|
43
|
+
};
|
|
44
|
+
export type CreateCheckoutInput = Omit<CreatePaymentInput, 'paymentMethodId' | 'offSession' | 'savePaymentMethod' | 'returnUrl'> & {
|
|
45
|
+
/** Where the customer lands once they paid. Default: the return route, redirecting to `payments.successUrl`. */
|
|
46
|
+
successUrl?: string;
|
|
47
|
+
/** Where the customer lands when leaving the page unpaid. Default: `payments.cancelUrl`. */
|
|
48
|
+
cancelUrl?: string;
|
|
49
|
+
};
|
|
50
|
+
/** A payment with what its client does next: nothing, confirm it, or follow a redirect. */
|
|
51
|
+
export type PaymentResult = {
|
|
52
|
+
payment: PaymentRecord;
|
|
53
|
+
nextAction: PaymentNextAction;
|
|
54
|
+
};
|
|
55
|
+
export type RefundInput = {
|
|
56
|
+
/** The amount in minor units. Default: what is left of the payment. */
|
|
57
|
+
amount?: number;
|
|
58
|
+
reason?: string;
|
|
59
|
+
/** A key of the caller: a second call with it refunds nothing more */
|
|
60
|
+
idempotencyKey?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Takes the payments of the gateways of the `payments` config: one-time payments confirmed by the client or charged
|
|
64
|
+
* to a saved payment method, hosted checkout pages, authorizations captured later, cancellations and refunds. A
|
|
65
|
+
* card never reaches the application: the client confirms a payment with the library of the gateway, or on its page.
|
|
66
|
+
* The records only move with what the gateway reports, here and in its webhooks, and every change is announced to
|
|
67
|
+
* the handlers of `onPaymentEvent`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const payments = inject(PaymentsService);
|
|
71
|
+
* const { payment, nextAction } = await payments.createPayment({
|
|
72
|
+
* amount: 1999,
|
|
73
|
+
* currency: 'EUR',
|
|
74
|
+
* userId: user.id,
|
|
75
|
+
* email: user.email,
|
|
76
|
+
* reference: order.id
|
|
77
|
+
* });
|
|
78
|
+
*/
|
|
79
|
+
export declare class PaymentsService implements OnInit, IHealthCheck {
|
|
80
|
+
static [LIFECYCLE]: boolean;
|
|
81
|
+
static [HEALTH_CHECK]: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Checks the gateways of the config.
|
|
84
|
+
*
|
|
85
|
+
* @throws {ConfigurationError} `CONFIGURATION_INVALID` for a default gateway that is not configured.
|
|
86
|
+
*/
|
|
87
|
+
onInit(): void;
|
|
88
|
+
checkHealth(): Promise<HealthCheckResult>;
|
|
89
|
+
checkHealthConfig(): HealthCheckConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the names of the gateways.
|
|
92
|
+
*
|
|
93
|
+
* @return {string[]} The configured gateways, and the `fake` one outside of production.
|
|
94
|
+
*/
|
|
95
|
+
gateways(): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Selects the gateway of a payment: the one named, otherwise by the country and the currency.
|
|
98
|
+
*
|
|
99
|
+
* @param {GatewaySelection} [selection] - The name of the gateway, or the country and currency of the payment.
|
|
100
|
+
* @return {string} The name of the gateway.
|
|
101
|
+
* @throws {PaymentError} `PAYMENT_GATEWAY_UNKNOWN` for a gateway that is not configured.
|
|
102
|
+
*/
|
|
103
|
+
selectGateway(selection?: GatewaySelection): string;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the driver of a gateway, for the calls the service does not wrap.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} [name] - The name of the gateway. Default: the default one.
|
|
108
|
+
* @return {Promise<PaymentGateway>} The driver.
|
|
109
|
+
*/
|
|
110
|
+
gateway(name?: string): Promise<PaymentGateway>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns the public key the clients of a gateway confirm the payments with.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} [name] - The name of the gateway. Default: the default one.
|
|
115
|
+
* @return {string | undefined} The key, `undefined` when none is configured.
|
|
116
|
+
*/
|
|
117
|
+
publicKey(name?: string): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Finds the customer of a user at a gateway.
|
|
120
|
+
*
|
|
121
|
+
* @param {string | number} userId - The ID of the user.
|
|
122
|
+
* @param {string} [gateway] - The name of the gateway. Default: the default one.
|
|
123
|
+
* @return {Promise<PaymentCustomerRecord | null>} The customer, `null` before the first payment of the user.
|
|
124
|
+
*/
|
|
125
|
+
findCustomer(userId: string | number, gateway?: string): Promise<PaymentCustomerRecord | null>;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the customer of a user at a gateway, created there on the first call. A changed email, name or locale
|
|
128
|
+
* is sent to the gateway.
|
|
129
|
+
*
|
|
130
|
+
* @param {PaymentCustomerInput} input - The user, and the gateway or the country and currency selecting it.
|
|
131
|
+
* @return {Promise<PaymentCustomerRecord>} The customer.
|
|
132
|
+
*/
|
|
133
|
+
ensureCustomer(input: PaymentCustomerInput): Promise<PaymentCustomerRecord>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a payment. With a saved payment method it is charged at once; without one the client confirms it with
|
|
136
|
+
* the `clientSecret` of the next action, in the card form of the gateway. The result of a confirmation arrives in
|
|
137
|
+
* a webhook, announced as `payment.succeeded` or `payment.failed`.
|
|
138
|
+
*
|
|
139
|
+
* @param {CreatePaymentInput} input - The amount, who pays, and what for.
|
|
140
|
+
* @return {Promise<PaymentResult>} The payment and what its client does next.
|
|
141
|
+
* @throws {PaymentError} `PAYMENT_AMOUNT_INVALID`, `PAYMENT_CURRENCY_UNSUPPORTED`, `PAYMENT_METHOD_NOT_FOUND`,
|
|
142
|
+
* `PAYMENT_DECLINED` for a refused saved method, or the error of the gateway.
|
|
143
|
+
*/
|
|
144
|
+
createPayment(input: CreatePaymentInput): Promise<PaymentResult>;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a payment paid on a hosted page of the gateway, where the customer is sent with the `redirect` of the
|
|
147
|
+
* next action. They come back to the return route, which reads the payment from the gateway and redirects to
|
|
148
|
+
* `payments.successUrl` with its `paymentId` and `status`.
|
|
149
|
+
*
|
|
150
|
+
* @param {CreateCheckoutInput} input - The amount, who pays, and what for.
|
|
151
|
+
* @return {Promise<PaymentResult>} The payment and the redirect to its page.
|
|
152
|
+
* @throws {PaymentError} `PAYMENT_CAPABILITY_UNSUPPORTED` for a gateway without hosted pages, and the errors of
|
|
153
|
+
* {@link createPayment}.
|
|
154
|
+
*/
|
|
155
|
+
createCheckout(input: CreateCheckoutInput): Promise<PaymentResult>;
|
|
156
|
+
/**
|
|
157
|
+
* Returns a payment.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} id - The ID of the payment.
|
|
160
|
+
* @return {Promise<PaymentRecord>} The payment.
|
|
161
|
+
* @throws {PaymentError} `PAYMENT_NOT_FOUND` for an unknown payment.
|
|
162
|
+
*/
|
|
163
|
+
getPayment(id: string): Promise<PaymentRecord>;
|
|
164
|
+
/**
|
|
165
|
+
* Finds the payments of what the application sells, the newest first.
|
|
166
|
+
*
|
|
167
|
+
* @param {string} reference - The reference of the payments, i.e. the ID of an order.
|
|
168
|
+
* @param {string} [referenceType] - The kind of the reference.
|
|
169
|
+
* @return {Promise<PaymentRecord[]>} The payments.
|
|
170
|
+
*/
|
|
171
|
+
findPayments(reference: string, referenceType?: string): Promise<PaymentRecord[]>;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the ledger of a payment: its authorization, charge, capture, refunds and disputes, the oldest first.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} id - The ID of the payment.
|
|
176
|
+
* @return {Promise<PaymentTransactionRecord[]>} The entries.
|
|
177
|
+
*/
|
|
178
|
+
listTransactions(id: string): Promise<PaymentTransactionRecord[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Reads a payment from its gateway and applies its state, i.e. when the customer comes back from its page before
|
|
181
|
+
* the webhook arrives. A payment of a hosted page that is not paid yet is found through its checkout.
|
|
182
|
+
*
|
|
183
|
+
* @param {string} id - The ID of the payment.
|
|
184
|
+
* @return {Promise<PaymentResult>} The payment and what its client does next.
|
|
185
|
+
* @throws {PaymentError} `PAYMENT_NOT_FOUND` for an unknown payment.
|
|
186
|
+
*/
|
|
187
|
+
syncPayment(id: string): Promise<PaymentResult>;
|
|
188
|
+
/**
|
|
189
|
+
* Takes the money of an authorized payment.
|
|
190
|
+
*
|
|
191
|
+
* @param {string} id - The ID of the payment.
|
|
192
|
+
* @param {number} [amount] - A part of the authorized amount, in minor units, the rest released. Default: all.
|
|
193
|
+
* @return {Promise<PaymentRecord>} The payment.
|
|
194
|
+
* @throws {PaymentError} `PAYMENT_NOT_FOUND`, `PAYMENT_INVALID_STATE` for a payment that is not authorized,
|
|
195
|
+
* `PAYMENT_AMOUNT_INVALID` for an amount above the authorized one.
|
|
196
|
+
*/
|
|
197
|
+
capturePayment(id: string, amount?: number): Promise<PaymentRecord>;
|
|
198
|
+
/**
|
|
199
|
+
* Cancels a payment that is not paid, releasing its authorization. The hosted page of a payment is closed at the
|
|
200
|
+
* gateway first, so it cannot be paid once its payment is canceled.
|
|
201
|
+
*
|
|
202
|
+
* @param {string} id - The ID of the payment.
|
|
203
|
+
* @return {Promise<PaymentRecord>} The payment.
|
|
204
|
+
* @throws {PaymentError} `PAYMENT_NOT_FOUND`, `PAYMENT_INVALID_STATE` for a paid or canceled payment, also one
|
|
205
|
+
* paid on its hosted page in the meantime.
|
|
206
|
+
*/
|
|
207
|
+
cancelPayment(id: string): Promise<PaymentRecord>;
|
|
208
|
+
/**
|
|
209
|
+
* Refunds a paid payment, all of it or a part.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} id - The ID of the payment.
|
|
212
|
+
* @param {RefundInput} [input] - The amount, the reason and the idempotency key of the refund.
|
|
213
|
+
* @return {Promise<PaymentTransactionRecord>} The ledger entry of the refund.
|
|
214
|
+
* @throws {PaymentError} `PAYMENT_NOT_FOUND`, `PAYMENT_INVALID_STATE` for a payment that is not paid,
|
|
215
|
+
* `PAYMENT_REFUND_EXCEEDED` for an amount above what is left of it.
|
|
216
|
+
*/
|
|
217
|
+
refundPayment(id: string, input?: RefundInput): Promise<PaymentTransactionRecord>;
|
|
218
|
+
/**
|
|
219
|
+
* Starts saving a payment method of a user without a payment: the client confirms the `clientSecret` of the next
|
|
220
|
+
* action with the library of the gateway, and the method arrives in a webhook, announced as
|
|
221
|
+
* `paymentMethod.attached`.
|
|
222
|
+
*
|
|
223
|
+
* @param {PaymentCustomerInput} input - The user, and the gateway or the country and currency selecting it.
|
|
224
|
+
* @return {Promise<PaymentNextAction>} What the client does next.
|
|
225
|
+
* @throws {PaymentError} `PAYMENT_CAPABILITY_UNSUPPORTED` for a gateway saving no payment methods.
|
|
226
|
+
*/
|
|
227
|
+
createSetup(input: PaymentCustomerInput): Promise<PaymentNextAction>;
|
|
228
|
+
/**
|
|
229
|
+
* Lists the saved payment methods of a user, the default one first.
|
|
230
|
+
*
|
|
231
|
+
* @param {string | number} userId - The ID of the user.
|
|
232
|
+
* @param {string} [gateway] - The name of a gateway. Default: the methods of every gateway.
|
|
233
|
+
* @return {Promise<PaymentMethodRecord[]>} The payment methods.
|
|
234
|
+
*/
|
|
235
|
+
listPaymentMethods(userId: string | number, gateway?: string): Promise<PaymentMethodRecord[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Reads the payment methods of a customer from the gateway: the new ones are saved, the removed ones deleted.
|
|
238
|
+
*
|
|
239
|
+
* @param {PaymentCustomerRecord} customer - The customer.
|
|
240
|
+
* @return {Promise<PaymentMethodRecord[]>} The payment methods of the customer.
|
|
241
|
+
*/
|
|
242
|
+
syncPaymentMethods(customer: PaymentCustomerRecord): Promise<PaymentMethodRecord[]>;
|
|
243
|
+
/**
|
|
244
|
+
* Makes a saved payment method the one the subscriptions of its customer are charged to.
|
|
245
|
+
*
|
|
246
|
+
* @param {string} id - The ID of the payment method.
|
|
247
|
+
* @return {Promise<PaymentMethodRecord>} The payment method.
|
|
248
|
+
* @throws {PaymentError} `PAYMENT_METHOD_NOT_FOUND` for an unknown payment method.
|
|
249
|
+
*/
|
|
250
|
+
setDefaultPaymentMethod(id: string): Promise<PaymentMethodRecord>;
|
|
251
|
+
/**
|
|
252
|
+
* Removes a saved payment method, at the gateway too.
|
|
253
|
+
*
|
|
254
|
+
* @param {string} id - The ID of the payment method.
|
|
255
|
+
* @throws {PaymentError} `PAYMENT_METHOD_NOT_FOUND` for an unknown payment method.
|
|
256
|
+
*/
|
|
257
|
+
detachPaymentMethod(id: string): Promise<void>;
|
|
258
|
+
/**
|
|
259
|
+
* Returns a saved payment method.
|
|
260
|
+
*
|
|
261
|
+
* @param {string} id - The ID of the payment method.
|
|
262
|
+
* @return {Promise<PaymentMethodRecord>} The payment method.
|
|
263
|
+
* @throws {PaymentError} `PAYMENT_METHOD_NOT_FOUND` for an unknown payment method.
|
|
264
|
+
*/
|
|
265
|
+
getPaymentMethod(id: string): Promise<PaymentMethodRecord>;
|
|
266
|
+
/**
|
|
267
|
+
* Reads the payments in a state that is not final from their gateways again, catching the webhooks never
|
|
268
|
+
* received, and cancels the ones left unpaid longer than `payments.pendingTtl`.
|
|
269
|
+
*
|
|
270
|
+
* @param {Date} now - The current time.
|
|
271
|
+
* @param {number} limit - The most payments to read.
|
|
272
|
+
* @return {Promise<number>} The number of payments read or canceled.
|
|
273
|
+
*/
|
|
274
|
+
reconcile(now: Date, limit: number): Promise<number>;
|
|
275
|
+
/**
|
|
276
|
+
* Returns a next action with the public key of its gateway, which the client confirms it with.
|
|
277
|
+
*
|
|
278
|
+
* @param {string} provider - The name of the gateway.
|
|
279
|
+
* @param {PaymentNextAction} action - The next action.
|
|
280
|
+
* @return {PaymentNextAction} The action, a `confirm` one with the public key.
|
|
281
|
+
*/
|
|
282
|
+
withPublicKey(provider: string, action: PaymentNextAction): PaymentNextAction;
|
|
283
|
+
/**
|
|
284
|
+
* Returns the URL of the return route of a payment, where the gateway sends the customer back.
|
|
285
|
+
*
|
|
286
|
+
* @param {string} id - The ID of the payment.
|
|
287
|
+
* @return {string} The URL.
|
|
288
|
+
*/
|
|
289
|
+
returnUrl(id: string): string;
|
|
290
|
+
/**
|
|
291
|
+
* Runs a call of a gateway in its span.
|
|
292
|
+
*
|
|
293
|
+
* @param {string} provider - The name of the gateway.
|
|
294
|
+
* @param {string} operation - The method of the gateway, the name of the span.
|
|
295
|
+
* @param {Function} fn - The call.
|
|
296
|
+
* @return {Promise<Object>} The result of the call.
|
|
297
|
+
*/
|
|
298
|
+
call<T>(provider: string, operation: string, fn: (gateway: PaymentGateway) => Promise<T>): Promise<T>;
|
|
299
|
+
/**
|
|
300
|
+
* Checks that a gateway has a capability.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} provider - The name of the gateway.
|
|
303
|
+
* @param {PaymentCapability} capability - The capability.
|
|
304
|
+
* @throws {PaymentError} `PAYMENT_CAPABILITY_UNSUPPORTED` when the gateway has not.
|
|
305
|
+
*/
|
|
306
|
+
require(provider: string, capability: PaymentCapability): Promise<void>;
|
|
307
|
+
}
|