@antelopejs/interface-payment 0.0.0-stage → 0.0.2
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 +190 -0
- package/README.md +127 -2
- package/dist/antelope.test.d.ts +2 -0
- package/dist/antelope.test.js +10 -0
- package/dist/antelope.test.js.map +1 -0
- package/dist/errors.d.ts +78 -0
- package/dist/errors.js +101 -0
- package/dist/errors.js.map +1 -0
- package/dist/functions.d.ts +228 -0
- package/dist/functions.js +232 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/tests/payment-charges.test.d.ts +1 -0
- package/dist/tests/payment-charges.test.js +188 -0
- package/dist/tests/payment-charges.test.js.map +1 -0
- package/dist/tests/payment.test.d.ts +1 -0
- package/dist/tests/payment.test.js +115 -0
- package/dist/tests/payment.test.js.map +1 -0
- package/dist/tests/support.d.ts +63 -0
- package/dist/tests/support.js +149 -0
- package/dist/tests/support.js.map +1 -0
- package/dist/types.d.ts +388 -0
- package/dist/types.js +87 -0
- package/dist/types.js.map +1 -0
- package/docs/1.introduction.md +91 -0
- package/docs/2.payments.md +233 -0
- package/docs/3.customers-and-methods.md +133 -0
- package/docs/4.webhooks.md +170 -0
- package/docs/5.provider-capability-matrix.md +147 -0
- package/docs/tsconfig.json +14 -0
- package/package.json +79 -4
- package/skills/taking-payments/SKILL.md +232 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { Amount, CheckoutSession, CheckoutSessionRequest, Customer, CustomerRequest, Payment, PaymentEvent, PaymentMethod, PaymentRequest, Refund, RefundRequest, WebhookRequest } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a hosted checkout session: an externally hosted page that collects
|
|
4
|
+
* the payment method and takes the payment.
|
|
5
|
+
*
|
|
6
|
+
* Send the payer to {@link CheckoutSession.redirectUrl}. Their return to
|
|
7
|
+
* `successUrl` or `cancelUrl` is not proof of the outcome: treat it as a prompt
|
|
8
|
+
* to call {@link GetCheckoutSession}, and take the {@link PaymentEvent} as the
|
|
9
|
+
* record.
|
|
10
|
+
*
|
|
11
|
+
* Implementations must document their replay window. After expiration,
|
|
12
|
+
* applications must reconcile uncertain payments before retrying; reusing a
|
|
13
|
+
* key may create a new charge.
|
|
14
|
+
*
|
|
15
|
+
* @param request - Amount, reference and the URLs to return the payer to
|
|
16
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
17
|
+
* replay window, replaying it returns the
|
|
18
|
+
* original session rather than creating a second one
|
|
19
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
20
|
+
* @returns The session, including the URL to redirect to
|
|
21
|
+
*/
|
|
22
|
+
export declare const CreateCheckoutSession: (request: CheckoutSessionRequest, idempotencyKey: string, provider?: string | undefined) => Promise<CheckoutSession>;
|
|
23
|
+
/**
|
|
24
|
+
* Reads a checkout session.
|
|
25
|
+
*
|
|
26
|
+
* Call this when the payer returns, to find out what actually happened.
|
|
27
|
+
* {@link CheckoutSession.payment} is set once a payment exists behind the
|
|
28
|
+
* session.
|
|
29
|
+
*
|
|
30
|
+
* @param id - Opaque session identifier
|
|
31
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
32
|
+
* @returns The session's current state
|
|
33
|
+
* @throws PaymentNotFoundError if no session has that identifier
|
|
34
|
+
*/
|
|
35
|
+
export declare const GetCheckoutSession: (id: string, provider?: string | undefined) => Promise<CheckoutSession>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a payment directly, without a hosted page.
|
|
38
|
+
*
|
|
39
|
+
* Two uses: charging a saved method off-session (set `paymentMethod` and
|
|
40
|
+
* `offSession`), and taking a payment through a payment form you host yourself.
|
|
41
|
+
*
|
|
42
|
+
* `savePaymentMethod` and `offSession` are mutually exclusive — a mandate can
|
|
43
|
+
* only be taken from a payer who is present. See
|
|
44
|
+
* {@link PaymentRequest.savePaymentMethod}.
|
|
45
|
+
*
|
|
46
|
+
* A declined payment is a result, not an error: this resolves with a
|
|
47
|
+
* {@link Payment} whose status is `failed` and whose {@link Payment.failure}
|
|
48
|
+
* says why. It rejects only when the call itself could not be made.
|
|
49
|
+
*
|
|
50
|
+
* A status of `requires_action` means the payer must be sent to
|
|
51
|
+
* {@link Payment.redirectUrl}. That redirect is the only mechanism for 3DS and
|
|
52
|
+
* SCA in this interface.
|
|
53
|
+
*
|
|
54
|
+
* Implementations must document their replay window. After expiration,
|
|
55
|
+
* applications must reconcile uncertain payments before retrying; reusing a
|
|
56
|
+
* key may create a new charge.
|
|
57
|
+
*
|
|
58
|
+
* @param request - Amount, reference and how to charge it
|
|
59
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
60
|
+
* replay window, replaying it returns the
|
|
61
|
+
* original payment rather than charging twice
|
|
62
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
63
|
+
* @returns The payment, in whatever state the call left it
|
|
64
|
+
*/
|
|
65
|
+
export declare const CreatePayment: (request: PaymentRequest, idempotencyKey: string, provider?: string | undefined) => Promise<Payment>;
|
|
66
|
+
/**
|
|
67
|
+
* Reads a payment's current state.
|
|
68
|
+
*
|
|
69
|
+
* @param id - Opaque payment identifier
|
|
70
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
71
|
+
* @returns The payment
|
|
72
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
73
|
+
*/
|
|
74
|
+
export declare const GetPayment: (id: string, provider?: string | undefined) => Promise<Payment>;
|
|
75
|
+
/**
|
|
76
|
+
* Captures an authorized payment.
|
|
77
|
+
*
|
|
78
|
+
* Omit `amount` to capture the full authorized amount. Capturing less releases
|
|
79
|
+
* the remainder: one capture per authorization, so authorize per instalment if
|
|
80
|
+
* you need to capture in stages.
|
|
81
|
+
*
|
|
82
|
+
* @param id - Opaque payment identifier, in status `authorized`
|
|
83
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
84
|
+
* replay window, replaying it returns the result
|
|
85
|
+
* of the original capture rather than capturing again
|
|
86
|
+
* @param amount - How much to capture, at most the authorized amount
|
|
87
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
88
|
+
* @returns The payment, with `amountCaptured` updated
|
|
89
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
90
|
+
* @throws InvalidPaymentStateError if the payment is not `authorized`, or the
|
|
91
|
+
* amount exceeds what was authorized
|
|
92
|
+
*/
|
|
93
|
+
export declare const CapturePayment: (id: string, idempotencyKey: string, amount?: Amount | undefined, provider?: string | undefined) => Promise<Payment>;
|
|
94
|
+
/**
|
|
95
|
+
* Cancels a payment that has not been captured, releasing any held funds.
|
|
96
|
+
*
|
|
97
|
+
* @param id - Opaque payment identifier, in a non-terminal status
|
|
98
|
+
* @param idempotencyKey - Caller-generated key; replay is safe within the
|
|
99
|
+
* provider-defined replay window
|
|
100
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
101
|
+
* @returns The payment, with status `canceled`
|
|
102
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
103
|
+
* @throws InvalidPaymentStateError if the payment has already been captured or
|
|
104
|
+
* has otherwise reached a terminal status
|
|
105
|
+
*/
|
|
106
|
+
export declare const CancelPayment: (id: string, idempotencyKey: string, provider?: string | undefined) => Promise<Payment>;
|
|
107
|
+
/**
|
|
108
|
+
* Refunds a captured payment, in full or in part.
|
|
109
|
+
*
|
|
110
|
+
* The usual result is a {@link Refund} with status `pending`; the terminal
|
|
111
|
+
* state arrives as a `refund.succeeded` or `refund.failed`
|
|
112
|
+
* {@link PaymentEvent}. Several partial refunds against one payment are
|
|
113
|
+
* allowed, up to the captured amount.
|
|
114
|
+
*
|
|
115
|
+
* @param request - Which payment, and how much
|
|
116
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
117
|
+
* replay window, replaying it returns the
|
|
118
|
+
* original refund rather than refunding twice
|
|
119
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
120
|
+
* @returns The refund, usually still `pending`
|
|
121
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
122
|
+
* @throws InvalidPaymentStateError if the payment is not captured, or the amount
|
|
123
|
+
* exceeds what remains refundable
|
|
124
|
+
*/
|
|
125
|
+
export declare const RefundPayment: (request: RefundRequest, idempotencyKey: string, provider?: string | undefined) => Promise<Refund>;
|
|
126
|
+
/**
|
|
127
|
+
* Reads a refund's current state.
|
|
128
|
+
*
|
|
129
|
+
* @param id - Opaque refund identifier
|
|
130
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
131
|
+
* @returns The refund
|
|
132
|
+
* @throws PaymentNotFoundError if no refund has that identifier
|
|
133
|
+
*/
|
|
134
|
+
export declare const GetRefund: (id: string, provider?: string | undefined) => Promise<Refund>;
|
|
135
|
+
/**
|
|
136
|
+
* Creates a customer to save payment methods against.
|
|
137
|
+
*
|
|
138
|
+
* The returned id is the only field guaranteed to survive a round trip. Store
|
|
139
|
+
* it against your own user record.
|
|
140
|
+
*
|
|
141
|
+
* @param request - Details to store where supported
|
|
142
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
143
|
+
* replay window, replaying it returns the
|
|
144
|
+
* original customer rather than creating a second one
|
|
145
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
146
|
+
* @returns The customer
|
|
147
|
+
*/
|
|
148
|
+
export declare const CreateCustomer: (request: CustomerRequest, idempotencyKey: string, provider?: string | undefined) => Promise<Customer>;
|
|
149
|
+
/**
|
|
150
|
+
* Reads a customer.
|
|
151
|
+
*
|
|
152
|
+
* May return the id and nothing else. Do not rely on `email` or `name` being
|
|
153
|
+
* populated; see {@link Customer}.
|
|
154
|
+
*
|
|
155
|
+
* @param id - Opaque customer identifier
|
|
156
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
157
|
+
* @returns The customer
|
|
158
|
+
* @throws CustomerNotFoundError if no customer has that identifier
|
|
159
|
+
*/
|
|
160
|
+
export declare const GetCustomer: (id: string, provider?: string | undefined) => Promise<Customer>;
|
|
161
|
+
/**
|
|
162
|
+
* Deletes a customer and detaches every payment method saved against it.
|
|
163
|
+
*
|
|
164
|
+
* Payments already taken are unaffected and remain readable.
|
|
165
|
+
*
|
|
166
|
+
* @param id - Opaque customer identifier
|
|
167
|
+
* @param idempotencyKey - Caller-generated key; replay is safe within the
|
|
168
|
+
* provider-defined replay window
|
|
169
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
170
|
+
* @throws CustomerNotFoundError if no customer has that identifier
|
|
171
|
+
*/
|
|
172
|
+
export declare const DeleteCustomer: (id: string, idempotencyKey: string, provider?: string | undefined) => Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Lists the payment methods saved against a customer and chargeable
|
|
175
|
+
* off-session.
|
|
176
|
+
*
|
|
177
|
+
* @param customer - Opaque customer identifier
|
|
178
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
179
|
+
* @returns The saved methods, newest first. Empty when none are saved.
|
|
180
|
+
* @throws CustomerNotFoundError if no customer has that identifier
|
|
181
|
+
*/
|
|
182
|
+
export declare const ListPaymentMethods: (customer: string, provider?: string | undefined) => Promise<PaymentMethod[]>;
|
|
183
|
+
/**
|
|
184
|
+
* Detaches a saved payment method, leaving the customer in place.
|
|
185
|
+
*
|
|
186
|
+
* @param id - Opaque payment method identifier
|
|
187
|
+
* @param idempotencyKey - Caller-generated key; replay is safe within the
|
|
188
|
+
* provider-defined replay window
|
|
189
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
190
|
+
* @throws CustomerNotFoundError if no payment method has that identifier
|
|
191
|
+
*/
|
|
192
|
+
export declare const DetachPaymentMethod: (id: string, idempotencyKey: string, provider?: string | undefined) => Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Establishes that a webhook delivery is genuine and normalises it into a
|
|
195
|
+
* {@link PaymentEvent}.
|
|
196
|
+
*
|
|
197
|
+
* This is the only way a backend learns that a payment reached a terminal
|
|
198
|
+
* state. The payer's return from a redirect is not a substitute.
|
|
199
|
+
*
|
|
200
|
+
* Three outcomes:
|
|
201
|
+
*
|
|
202
|
+
* - A {@link PaymentEvent}, for a delivery this interface models.
|
|
203
|
+
* - `undefined`, for a genuine delivery that is not one of
|
|
204
|
+
* {@link PAYMENT_EVENT_TYPES}. Respond 200; this is a normal result, and
|
|
205
|
+
* rejecting it causes redelivery.
|
|
206
|
+
* - A rejection with {@link WebhookVerificationError}. Respond 403 and act on
|
|
207
|
+
* nothing.
|
|
208
|
+
*
|
|
209
|
+
* Deliveries repeat and arrive out of order. De-duplicate on
|
|
210
|
+
* {@link PaymentEvent.id}, and do not assume an event describes a newer state
|
|
211
|
+
* than the one you hold.
|
|
212
|
+
*
|
|
213
|
+
* Implementations must populate every field of the returned event from data
|
|
214
|
+
* they have authenticated. Where a delivery is established by reading the named
|
|
215
|
+
* record back rather than by a signature over the body, that read authenticates
|
|
216
|
+
* the record alone: `type`, the kind of record, and every field of `payment`,
|
|
217
|
+
* `refund` or `dispute` come from the record, and the body is treated as a
|
|
218
|
+
* pointer and nothing else. `docs/4.webhooks.md` covers what goes wrong
|
|
219
|
+
* otherwise.
|
|
220
|
+
*
|
|
221
|
+
* @param request - The raw body and headers, unmodified
|
|
222
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
223
|
+
* @returns The normalised event, or undefined if it is not one this interface
|
|
224
|
+
* models
|
|
225
|
+
* @throws WebhookVerificationError if the delivery cannot be established as
|
|
226
|
+
* genuine
|
|
227
|
+
*/
|
|
228
|
+
export declare const VerifyWebhook: (request: WebhookRequest, provider?: string | undefined) => Promise<PaymentEvent | undefined>;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerifyWebhook = exports.DetachPaymentMethod = exports.ListPaymentMethods = exports.DeleteCustomer = exports.GetCustomer = exports.CreateCustomer = exports.GetRefund = exports.RefundPayment = exports.CancelPayment = exports.CapturePayment = exports.GetPayment = exports.CreatePayment = exports.GetCheckoutSession = exports.CreateCheckoutSession = void 0;
|
|
4
|
+
const interface_core_1 = require("@antelopejs/interface-core");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a hosted checkout session: an externally hosted page that collects
|
|
7
|
+
* the payment method and takes the payment.
|
|
8
|
+
*
|
|
9
|
+
* Send the payer to {@link CheckoutSession.redirectUrl}. Their return to
|
|
10
|
+
* `successUrl` or `cancelUrl` is not proof of the outcome: treat it as a prompt
|
|
11
|
+
* to call {@link GetCheckoutSession}, and take the {@link PaymentEvent} as the
|
|
12
|
+
* record.
|
|
13
|
+
*
|
|
14
|
+
* Implementations must document their replay window. After expiration,
|
|
15
|
+
* applications must reconcile uncertain payments before retrying; reusing a
|
|
16
|
+
* key may create a new charge.
|
|
17
|
+
*
|
|
18
|
+
* @param request - Amount, reference and the URLs to return the payer to
|
|
19
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
20
|
+
* replay window, replaying it returns the
|
|
21
|
+
* original session rather than creating a second one
|
|
22
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
23
|
+
* @returns The session, including the URL to redirect to
|
|
24
|
+
*/
|
|
25
|
+
exports.CreateCheckoutSession = (0, interface_core_1.InterfaceFunction)();
|
|
26
|
+
/**
|
|
27
|
+
* Reads a checkout session.
|
|
28
|
+
*
|
|
29
|
+
* Call this when the payer returns, to find out what actually happened.
|
|
30
|
+
* {@link CheckoutSession.payment} is set once a payment exists behind the
|
|
31
|
+
* session.
|
|
32
|
+
*
|
|
33
|
+
* @param id - Opaque session identifier
|
|
34
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
35
|
+
* @returns The session's current state
|
|
36
|
+
* @throws PaymentNotFoundError if no session has that identifier
|
|
37
|
+
*/
|
|
38
|
+
exports.GetCheckoutSession = (0, interface_core_1.InterfaceFunction)();
|
|
39
|
+
/**
|
|
40
|
+
* Creates a payment directly, without a hosted page.
|
|
41
|
+
*
|
|
42
|
+
* Two uses: charging a saved method off-session (set `paymentMethod` and
|
|
43
|
+
* `offSession`), and taking a payment through a payment form you host yourself.
|
|
44
|
+
*
|
|
45
|
+
* `savePaymentMethod` and `offSession` are mutually exclusive — a mandate can
|
|
46
|
+
* only be taken from a payer who is present. See
|
|
47
|
+
* {@link PaymentRequest.savePaymentMethod}.
|
|
48
|
+
*
|
|
49
|
+
* A declined payment is a result, not an error: this resolves with a
|
|
50
|
+
* {@link Payment} whose status is `failed` and whose {@link Payment.failure}
|
|
51
|
+
* says why. It rejects only when the call itself could not be made.
|
|
52
|
+
*
|
|
53
|
+
* A status of `requires_action` means the payer must be sent to
|
|
54
|
+
* {@link Payment.redirectUrl}. That redirect is the only mechanism for 3DS and
|
|
55
|
+
* SCA in this interface.
|
|
56
|
+
*
|
|
57
|
+
* Implementations must document their replay window. After expiration,
|
|
58
|
+
* applications must reconcile uncertain payments before retrying; reusing a
|
|
59
|
+
* key may create a new charge.
|
|
60
|
+
*
|
|
61
|
+
* @param request - Amount, reference and how to charge it
|
|
62
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
63
|
+
* replay window, replaying it returns the
|
|
64
|
+
* original payment rather than charging twice
|
|
65
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
66
|
+
* @returns The payment, in whatever state the call left it
|
|
67
|
+
*/
|
|
68
|
+
exports.CreatePayment = (0, interface_core_1.InterfaceFunction)();
|
|
69
|
+
/**
|
|
70
|
+
* Reads a payment's current state.
|
|
71
|
+
*
|
|
72
|
+
* @param id - Opaque payment identifier
|
|
73
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
74
|
+
* @returns The payment
|
|
75
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
76
|
+
*/
|
|
77
|
+
exports.GetPayment = (0, interface_core_1.InterfaceFunction)();
|
|
78
|
+
/**
|
|
79
|
+
* Captures an authorized payment.
|
|
80
|
+
*
|
|
81
|
+
* Omit `amount` to capture the full authorized amount. Capturing less releases
|
|
82
|
+
* the remainder: one capture per authorization, so authorize per instalment if
|
|
83
|
+
* you need to capture in stages.
|
|
84
|
+
*
|
|
85
|
+
* @param id - Opaque payment identifier, in status `authorized`
|
|
86
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
87
|
+
* replay window, replaying it returns the result
|
|
88
|
+
* of the original capture rather than capturing again
|
|
89
|
+
* @param amount - How much to capture, at most the authorized amount
|
|
90
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
91
|
+
* @returns The payment, with `amountCaptured` updated
|
|
92
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
93
|
+
* @throws InvalidPaymentStateError if the payment is not `authorized`, or the
|
|
94
|
+
* amount exceeds what was authorized
|
|
95
|
+
*/
|
|
96
|
+
exports.CapturePayment = (0, interface_core_1.InterfaceFunction)();
|
|
97
|
+
/**
|
|
98
|
+
* Cancels a payment that has not been captured, releasing any held funds.
|
|
99
|
+
*
|
|
100
|
+
* @param id - Opaque payment identifier, in a non-terminal status
|
|
101
|
+
* @param idempotencyKey - Caller-generated key; replay is safe within the
|
|
102
|
+
* provider-defined replay window
|
|
103
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
104
|
+
* @returns The payment, with status `canceled`
|
|
105
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
106
|
+
* @throws InvalidPaymentStateError if the payment has already been captured or
|
|
107
|
+
* has otherwise reached a terminal status
|
|
108
|
+
*/
|
|
109
|
+
exports.CancelPayment = (0, interface_core_1.InterfaceFunction)();
|
|
110
|
+
/**
|
|
111
|
+
* Refunds a captured payment, in full or in part.
|
|
112
|
+
*
|
|
113
|
+
* The usual result is a {@link Refund} with status `pending`; the terminal
|
|
114
|
+
* state arrives as a `refund.succeeded` or `refund.failed`
|
|
115
|
+
* {@link PaymentEvent}. Several partial refunds against one payment are
|
|
116
|
+
* allowed, up to the captured amount.
|
|
117
|
+
*
|
|
118
|
+
* @param request - Which payment, and how much
|
|
119
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
120
|
+
* replay window, replaying it returns the
|
|
121
|
+
* original refund rather than refunding twice
|
|
122
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
123
|
+
* @returns The refund, usually still `pending`
|
|
124
|
+
* @throws PaymentNotFoundError if no payment has that identifier
|
|
125
|
+
* @throws InvalidPaymentStateError if the payment is not captured, or the amount
|
|
126
|
+
* exceeds what remains refundable
|
|
127
|
+
*/
|
|
128
|
+
exports.RefundPayment = (0, interface_core_1.InterfaceFunction)();
|
|
129
|
+
/**
|
|
130
|
+
* Reads a refund's current state.
|
|
131
|
+
*
|
|
132
|
+
* @param id - Opaque refund identifier
|
|
133
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
134
|
+
* @returns The refund
|
|
135
|
+
* @throws PaymentNotFoundError if no refund has that identifier
|
|
136
|
+
*/
|
|
137
|
+
exports.GetRefund = (0, interface_core_1.InterfaceFunction)();
|
|
138
|
+
/**
|
|
139
|
+
* Creates a customer to save payment methods against.
|
|
140
|
+
*
|
|
141
|
+
* The returned id is the only field guaranteed to survive a round trip. Store
|
|
142
|
+
* it against your own user record.
|
|
143
|
+
*
|
|
144
|
+
* @param request - Details to store where supported
|
|
145
|
+
* @param idempotencyKey - Caller-generated key; within the provider-defined
|
|
146
|
+
* replay window, replaying it returns the
|
|
147
|
+
* original customer rather than creating a second one
|
|
148
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
149
|
+
* @returns The customer
|
|
150
|
+
*/
|
|
151
|
+
exports.CreateCustomer = (0, interface_core_1.InterfaceFunction)();
|
|
152
|
+
/**
|
|
153
|
+
* Reads a customer.
|
|
154
|
+
*
|
|
155
|
+
* May return the id and nothing else. Do not rely on `email` or `name` being
|
|
156
|
+
* populated; see {@link Customer}.
|
|
157
|
+
*
|
|
158
|
+
* @param id - Opaque customer identifier
|
|
159
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
160
|
+
* @returns The customer
|
|
161
|
+
* @throws CustomerNotFoundError if no customer has that identifier
|
|
162
|
+
*/
|
|
163
|
+
exports.GetCustomer = (0, interface_core_1.InterfaceFunction)();
|
|
164
|
+
/**
|
|
165
|
+
* Deletes a customer and detaches every payment method saved against it.
|
|
166
|
+
*
|
|
167
|
+
* Payments already taken are unaffected and remain readable.
|
|
168
|
+
*
|
|
169
|
+
* @param id - Opaque customer identifier
|
|
170
|
+
* @param idempotencyKey - Caller-generated key; replay is safe within the
|
|
171
|
+
* provider-defined replay window
|
|
172
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
173
|
+
* @throws CustomerNotFoundError if no customer has that identifier
|
|
174
|
+
*/
|
|
175
|
+
exports.DeleteCustomer = (0, interface_core_1.InterfaceFunction)();
|
|
176
|
+
/**
|
|
177
|
+
* Lists the payment methods saved against a customer and chargeable
|
|
178
|
+
* off-session.
|
|
179
|
+
*
|
|
180
|
+
* @param customer - Opaque customer identifier
|
|
181
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
182
|
+
* @returns The saved methods, newest first. Empty when none are saved.
|
|
183
|
+
* @throws CustomerNotFoundError if no customer has that identifier
|
|
184
|
+
*/
|
|
185
|
+
exports.ListPaymentMethods = (0, interface_core_1.InterfaceFunction)();
|
|
186
|
+
/**
|
|
187
|
+
* Detaches a saved payment method, leaving the customer in place.
|
|
188
|
+
*
|
|
189
|
+
* @param id - Opaque payment method identifier
|
|
190
|
+
* @param idempotencyKey - Caller-generated key; replay is safe within the
|
|
191
|
+
* provider-defined replay window
|
|
192
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
193
|
+
* @throws CustomerNotFoundError if no payment method has that identifier
|
|
194
|
+
*/
|
|
195
|
+
exports.DetachPaymentMethod = (0, interface_core_1.InterfaceFunction)();
|
|
196
|
+
/**
|
|
197
|
+
* Establishes that a webhook delivery is genuine and normalises it into a
|
|
198
|
+
* {@link PaymentEvent}.
|
|
199
|
+
*
|
|
200
|
+
* This is the only way a backend learns that a payment reached a terminal
|
|
201
|
+
* state. The payer's return from a redirect is not a substitute.
|
|
202
|
+
*
|
|
203
|
+
* Three outcomes:
|
|
204
|
+
*
|
|
205
|
+
* - A {@link PaymentEvent}, for a delivery this interface models.
|
|
206
|
+
* - `undefined`, for a genuine delivery that is not one of
|
|
207
|
+
* {@link PAYMENT_EVENT_TYPES}. Respond 200; this is a normal result, and
|
|
208
|
+
* rejecting it causes redelivery.
|
|
209
|
+
* - A rejection with {@link WebhookVerificationError}. Respond 403 and act on
|
|
210
|
+
* nothing.
|
|
211
|
+
*
|
|
212
|
+
* Deliveries repeat and arrive out of order. De-duplicate on
|
|
213
|
+
* {@link PaymentEvent.id}, and do not assume an event describes a newer state
|
|
214
|
+
* than the one you hold.
|
|
215
|
+
*
|
|
216
|
+
* Implementations must populate every field of the returned event from data
|
|
217
|
+
* they have authenticated. Where a delivery is established by reading the named
|
|
218
|
+
* record back rather than by a signature over the body, that read authenticates
|
|
219
|
+
* the record alone: `type`, the kind of record, and every field of `payment`,
|
|
220
|
+
* `refund` or `dispute` come from the record, and the body is treated as a
|
|
221
|
+
* pointer and nothing else. `docs/4.webhooks.md` covers what goes wrong
|
|
222
|
+
* otherwise.
|
|
223
|
+
*
|
|
224
|
+
* @param request - The raw body and headers, unmodified
|
|
225
|
+
* @param provider - Optional provider identifier for multi-account setups
|
|
226
|
+
* @returns The normalised event, or undefined if it is not one this interface
|
|
227
|
+
* models
|
|
228
|
+
* @throws WebhookVerificationError if the delivery cannot be established as
|
|
229
|
+
* genuine
|
|
230
|
+
*/
|
|
231
|
+
exports.VerifyWebhook = (0, interface_core_1.InterfaceFunction)();
|
|
232
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAiB/D;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,qBAAqB,GAChC,IAAA,kCAAiB,GAMd,CAAC;AAEN;;;;;;;;;;;GAWG;AACU,QAAA,kBAAkB,GAC7B,IAAA,kCAAiB,GAEd,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACU,QAAA,aAAa,GACxB,IAAA,kCAAiB,GAMd,CAAC;AAEN;;;;;;;GAOG;AACU,QAAA,UAAU,GACrB,IAAA,kCAAiB,GAAuD,CAAC;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,cAAc,GACzB,IAAA,kCAAiB,GAOd,CAAC;AAEN;;;;;;;;;;;GAWG;AACU,QAAA,aAAa,GACxB,IAAA,kCAAiB,GAEd,CAAC;AAEN;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,aAAa,GACxB,IAAA,kCAAiB,GAMd,CAAC;AAEN;;;;;;;GAOG;AACU,QAAA,SAAS,GACpB,IAAA,kCAAiB,GAAsD,CAAC;AAE1E;;;;;;;;;;;;GAYG;AACU,QAAA,cAAc,GACzB,IAAA,kCAAiB,GAMd,CAAC;AAEN;;;;;;;;;;GAUG;AACU,QAAA,WAAW,GACtB,IAAA,kCAAiB,GAAwD,CAAC;AAE5E;;;;;;;;;;GAUG;AACU,QAAA,cAAc,GACzB,IAAA,kCAAiB,GAEd,CAAC;AAEN;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAC7B,IAAA,kCAAiB,GAEd,CAAC;AAEN;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAC9B,IAAA,kCAAiB,GAEd,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACU,QAAA,aAAa,GACxB,IAAA,kCAAiB,GAKd,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./errors"), exports);
|
|
18
|
+
__exportStar(require("./functions"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|