@stripe/stripe-js 3.0.10 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/bank-accounts.d.mts +61 -0
- package/dist/api/bank-accounts.d.ts +61 -0
- package/dist/api/cards.d.mts +130 -0
- package/dist/api/cards.d.ts +130 -0
- package/dist/api/confirmation-tokens.d.mts +191 -0
- package/dist/api/confirmation-tokens.d.ts +191 -0
- package/dist/api/financial-connections.d.mts +232 -0
- package/dist/api/financial-connections.d.ts +232 -0
- package/dist/api/index.d.mts +12 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/orders.d.mts +122 -0
- package/dist/api/orders.d.ts +122 -0
- package/dist/api/payment-intents.d.mts +330 -0
- package/dist/api/payment-intents.d.ts +330 -0
- package/dist/api/payment-methods.d.mts +452 -0
- package/dist/api/payment-methods.d.ts +452 -0
- package/dist/api/setup-intents.d.mts +184 -0
- package/dist/api/setup-intents.d.ts +184 -0
- package/dist/api/shared.d.mts +125 -0
- package/dist/api/shared.d.ts +125 -0
- package/dist/api/sources.d.mts +1045 -0
- package/dist/api/sources.d.ts +1045 -0
- package/dist/api/tokens.d.mts +639 -0
- package/dist/api/tokens.d.ts +639 -0
- package/dist/api/verification-sessions.d.mts +9 -0
- package/dist/api/verification-sessions.d.ts +9 -0
- package/dist/index.d.mts +4 -12792
- package/dist/index.d.ts +4 -12792
- package/dist/{stripe.js → index.js} +1 -1
- package/dist/{stripe.mjs → index.mjs} +1 -1
- package/dist/pure.d.mts +5 -0
- package/dist/pure.d.ts +5 -0
- package/dist/pure.js +204 -0
- package/dist/pure.mjs +200 -0
- package/dist/shared.d.mts +6 -0
- package/dist/shared.d.ts +6 -0
- package/dist/stripe-js/checkout.d.mts +153 -0
- package/dist/stripe-js/checkout.d.ts +153 -0
- package/dist/stripe-js/confirmation-tokens.d.mts +1 -0
- package/dist/stripe-js/confirmation-tokens.d.ts +1 -0
- package/dist/stripe-js/custom-checkout.d.mts +402 -0
- package/dist/stripe-js/custom-checkout.d.ts +402 -0
- package/dist/stripe-js/elements/address.d.mts +261 -0
- package/dist/stripe-js/elements/address.d.ts +261 -0
- package/dist/stripe-js/elements/affirm-message.d.mts +65 -0
- package/dist/stripe-js/elements/affirm-message.d.ts +65 -0
- package/dist/stripe-js/elements/afterpay-clearpay-message.d.mts +119 -0
- package/dist/stripe-js/elements/afterpay-clearpay-message.d.ts +119 -0
- package/dist/stripe-js/elements/apple-pay.d.mts +156 -0
- package/dist/stripe-js/elements/apple-pay.d.ts +156 -0
- package/dist/stripe-js/elements/au-bank-account.d.mts +138 -0
- package/dist/stripe-js/elements/au-bank-account.d.ts +138 -0
- package/dist/stripe-js/elements/base.d.mts +264 -0
- package/dist/stripe-js/elements/base.d.ts +264 -0
- package/dist/stripe-js/elements/card-cvc.d.mts +119 -0
- package/dist/stripe-js/elements/card-cvc.d.ts +119 -0
- package/dist/stripe-js/elements/card-expiry.d.mts +119 -0
- package/dist/stripe-js/elements/card-expiry.d.ts +119 -0
- package/dist/stripe-js/elements/card-number.d.mts +200 -0
- package/dist/stripe-js/elements/card-number.d.ts +200 -0
- package/dist/stripe-js/elements/card.d.mts +226 -0
- package/dist/stripe-js/elements/card.d.ts +226 -0
- package/dist/stripe-js/elements/cart.d.mts +224 -0
- package/dist/stripe-js/elements/cart.d.ts +224 -0
- package/dist/stripe-js/elements/eps-bank.d.mts +140 -0
- package/dist/stripe-js/elements/eps-bank.d.ts +140 -0
- package/dist/stripe-js/elements/express-checkout.d.mts +446 -0
- package/dist/stripe-js/elements/express-checkout.d.ts +446 -0
- package/dist/stripe-js/elements/fpx-bank.d.mts +134 -0
- package/dist/stripe-js/elements/fpx-bank.d.ts +134 -0
- package/dist/stripe-js/elements/iban.d.mts +135 -0
- package/dist/stripe-js/elements/iban.d.ts +135 -0
- package/dist/stripe-js/elements/ideal-bank.d.mts +140 -0
- package/dist/stripe-js/elements/ideal-bank.d.ts +140 -0
- package/dist/stripe-js/elements/index.d.mts +22 -0
- package/dist/stripe-js/elements/index.d.ts +22 -0
- package/dist/stripe-js/elements/issuing/index.d.mts +5 -0
- package/dist/stripe-js/elements/issuing/index.d.ts +5 -0
- package/dist/stripe-js/elements/issuing/issuing-card-copy-button.d.mts +37 -0
- package/dist/stripe-js/elements/issuing/issuing-card-copy-button.d.ts +37 -0
- package/dist/stripe-js/elements/issuing/issuing-card-cvc-display.d.mts +32 -0
- package/dist/stripe-js/elements/issuing/issuing-card-cvc-display.d.ts +32 -0
- package/dist/stripe-js/elements/issuing/issuing-card-expiry-display.d.mts +32 -0
- package/dist/stripe-js/elements/issuing/issuing-card-expiry-display.d.ts +32 -0
- package/dist/stripe-js/elements/issuing/issuing-card-number-display.d.mts +40 -0
- package/dist/stripe-js/elements/issuing/issuing-card-number-display.d.ts +40 -0
- package/dist/stripe-js/elements/issuing/issuing-card-pin-display.d.mts +32 -0
- package/dist/stripe-js/elements/issuing/issuing-card-pin-display.d.ts +32 -0
- package/dist/stripe-js/elements/link-authentication.d.mts +158 -0
- package/dist/stripe-js/elements/link-authentication.d.ts +158 -0
- package/dist/stripe-js/elements/p24-bank.d.mts +140 -0
- package/dist/stripe-js/elements/p24-bank.d.ts +140 -0
- package/dist/stripe-js/elements/payment-method-messaging.d.mts +98 -0
- package/dist/stripe-js/elements/payment-method-messaging.d.ts +98 -0
- package/dist/stripe-js/elements/payment-request-button.d.mts +151 -0
- package/dist/stripe-js/elements/payment-request-button.d.ts +151 -0
- package/dist/stripe-js/elements/payment.d.mts +275 -0
- package/dist/stripe-js/elements/payment.d.ts +275 -0
- package/dist/stripe-js/elements/shipping-address.d.mts +215 -0
- package/dist/stripe-js/elements/shipping-address.d.ts +215 -0
- package/dist/stripe-js/elements-group.d.mts +1143 -0
- package/dist/stripe-js/elements-group.d.ts +1143 -0
- package/dist/stripe-js/embedded-checkout.d.mts +35 -0
- package/dist/stripe-js/embedded-checkout.d.ts +35 -0
- package/dist/stripe-js/ephemeral-keys.d.mts +3 -0
- package/dist/stripe-js/ephemeral-keys.d.ts +3 -0
- package/dist/stripe-js/financial-connections.d.mts +19 -0
- package/dist/stripe-js/financial-connections.d.ts +19 -0
- package/dist/stripe-js/index.d.mts +13 -0
- package/dist/stripe-js/index.d.ts +13 -0
- package/dist/stripe-js/orders.d.mts +9 -0
- package/dist/stripe-js/orders.d.ts +9 -0
- package/dist/stripe-js/payment-intents.d.mts +1473 -0
- package/dist/stripe-js/payment-intents.d.ts +1473 -0
- package/dist/stripe-js/payment-request.d.mts +529 -0
- package/dist/stripe-js/payment-request.d.ts +529 -0
- package/dist/stripe-js/setup-intents.d.mts +250 -0
- package/dist/stripe-js/setup-intents.d.ts +250 -0
- package/dist/stripe-js/stripe.d.mts +1486 -0
- package/dist/stripe-js/stripe.d.ts +1486 -0
- package/dist/stripe-js/token-and-sources.d.mts +110 -0
- package/dist/stripe-js/token-and-sources.d.ts +110 -0
- package/dist/utils.d.mts +2 -0
- package/dist/utils.d.ts +2 -0
- package/lib/index.d.mts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.mjs +1 -0
- package/package.json +11 -10
- package/pure/index.d.mts +1 -12771
- package/pure/index.d.ts +1 -12771
- package/pure/index.js +1 -204
- package/pure/index.mjs +1 -200
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import {Token, PaymentMethod, Source} from '../api';
|
|
2
|
+
import {ApplePayOption, ApplePayUpdateOption} from './elements/apple-pay';
|
|
3
|
+
|
|
4
|
+
export interface PaymentRequest {
|
|
5
|
+
/**
|
|
6
|
+
* Returns a `Promise` that resolves with a truthy value if an enabled wallet is ready to pay.
|
|
7
|
+
* If no wallet is available, it resolves with `null`.
|
|
8
|
+
*/
|
|
9
|
+
canMakePayment(): Promise<CanMakePaymentResult | null>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shows the browser’s payment interface.
|
|
13
|
+
* When using the `PaymentRequestButtonElement`, this is called for you automatically.
|
|
14
|
+
* This method must be called as the result of a user interaction (for example, in a click handler).
|
|
15
|
+
*/
|
|
16
|
+
show(): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Closes the browser’s payment interface.
|
|
20
|
+
*/
|
|
21
|
+
abort: () => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `true` if the browser’s payment interface is showing.
|
|
25
|
+
* When using the `PaymentRequestButtonElement`, this is called for you automatically.
|
|
26
|
+
*/
|
|
27
|
+
isShowing: () => boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `PaymentRequest` instances can be updated with an options object.
|
|
31
|
+
*
|
|
32
|
+
* `paymentRequest.update` can only be called when the browser payment interface is not showing.
|
|
33
|
+
* Listen to the [click](https://stripe.com/docs/js/element/events) and [cancel](https://stripe.com/docs/js/element/events) events to detect if the payment interface has been initiated.
|
|
34
|
+
* To update the `PaymentRequest` right before the payment interface is initiated, call `paymentRequest.update` in your click event handler.
|
|
35
|
+
*/
|
|
36
|
+
update(options: PaymentRequestUpdateOptions): void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stripe.js automatically creates a `Token` after the customer is done interacting with the browser’s payment interface.
|
|
40
|
+
* To access the created `Token`, listen for this event.
|
|
41
|
+
*/
|
|
42
|
+
on(
|
|
43
|
+
eventType: 'token',
|
|
44
|
+
handler: (event: PaymentRequestTokenEvent) => any
|
|
45
|
+
): this;
|
|
46
|
+
once(
|
|
47
|
+
eventType: 'token',
|
|
48
|
+
handler: (event: PaymentRequestTokenEvent) => any
|
|
49
|
+
): this;
|
|
50
|
+
off(
|
|
51
|
+
eventType: 'token',
|
|
52
|
+
handler?: (event: PaymentRequestTokenEvent) => any
|
|
53
|
+
): this;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Stripe.js automatically creates a `PaymentMethod` after the customer is done interacting with the browser’s payment interface.
|
|
57
|
+
* To access the created `PaymentMethod`, listen for this event.
|
|
58
|
+
*/
|
|
59
|
+
on(
|
|
60
|
+
eventType: 'paymentmethod',
|
|
61
|
+
handler: (event: PaymentRequestPaymentMethodEvent) => any
|
|
62
|
+
): this;
|
|
63
|
+
once(
|
|
64
|
+
eventType: 'paymentmethod',
|
|
65
|
+
handler: (event: PaymentRequestPaymentMethodEvent) => any
|
|
66
|
+
): this;
|
|
67
|
+
off(
|
|
68
|
+
eventType: 'paymentmethod',
|
|
69
|
+
handler?: (event: PaymentRequestPaymentMethodEvent) => any
|
|
70
|
+
): this;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Stripe.js automatically creates a `Source` after the customer is done interacting with the browser’s payment interface.
|
|
74
|
+
* To access the created `Source`, listen for this event.
|
|
75
|
+
*/
|
|
76
|
+
on(
|
|
77
|
+
eventType: 'source',
|
|
78
|
+
handler: (event: PaymentRequestSourceEvent) => any
|
|
79
|
+
): this;
|
|
80
|
+
once(
|
|
81
|
+
eventType: 'source',
|
|
82
|
+
handler: (event: PaymentRequestSourceEvent) => any
|
|
83
|
+
): this;
|
|
84
|
+
off(
|
|
85
|
+
eventType: 'source',
|
|
86
|
+
handler?: (event: PaymentRequestSourceEvent) => any
|
|
87
|
+
): this;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The cancel event is emitted from a `PaymentRequest` when the browser's payment interface is dismissed.
|
|
91
|
+
*
|
|
92
|
+
* Note that in some browsers, the payment interface may be dismissed by the customer even after they authorize the payment.
|
|
93
|
+
* This means that you may receive a cancel event on your `PaymentRequest` object after receiving a `token`, `paymentmethod`, or `source` event.
|
|
94
|
+
* If you’re using the cancel event as a hook for canceling the customer’s order, make sure you also refund the payment that you just created.
|
|
95
|
+
*/
|
|
96
|
+
on(eventType: 'cancel', handler: () => any): this;
|
|
97
|
+
once(eventType: 'cancel', handler: () => any): this;
|
|
98
|
+
off(eventType: 'cancel', handler?: () => any): this;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The `shippingaddresschange` event is emitted from a `PaymentRequest` whenever the customer selects a new address in the browser's payment interface.
|
|
102
|
+
*/
|
|
103
|
+
on(
|
|
104
|
+
eventType: 'shippingaddresschange',
|
|
105
|
+
handler: (event: PaymentRequestShippingAddressEvent) => any
|
|
106
|
+
): this;
|
|
107
|
+
once(
|
|
108
|
+
eventType: 'shippingaddresschange',
|
|
109
|
+
handler: (event: PaymentRequestShippingAddressEvent) => any
|
|
110
|
+
): this;
|
|
111
|
+
off(
|
|
112
|
+
eventType: 'shippingaddresschange',
|
|
113
|
+
handler?: (event: PaymentRequestShippingAddressEvent) => any
|
|
114
|
+
): this;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The `shippingoptionchange` event is emitted from a `PaymentRequest` whenever the customer selects a new shipping option in the browser's payment interface.
|
|
118
|
+
*/
|
|
119
|
+
on(
|
|
120
|
+
eventType: 'shippingoptionchange',
|
|
121
|
+
handler: (event: PaymentRequestShippingOptionEvent) => any
|
|
122
|
+
): this;
|
|
123
|
+
once(
|
|
124
|
+
eventType: 'shippingoptionchange',
|
|
125
|
+
handler: (event: PaymentRequestShippingOptionEvent) => any
|
|
126
|
+
): this;
|
|
127
|
+
off(
|
|
128
|
+
eventType: 'shippingoptionchange',
|
|
129
|
+
handler?: (event: PaymentRequestShippingOptionEvent) => any
|
|
130
|
+
): this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type CanMakePaymentResult = Record<string, boolean>;
|
|
134
|
+
|
|
135
|
+
export interface PaymentRequestUpdateOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Three character currency code (e.g., `usd`).
|
|
138
|
+
*/
|
|
139
|
+
currency?: string;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* This `PaymentRequestItem` is shown to the customer in the browser’s payment interface.
|
|
143
|
+
*/
|
|
144
|
+
total?: PaymentRequestItem;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* An array of PaymentRequestItem objects.
|
|
148
|
+
* These objects are shown as line items in the browser’s payment interface.
|
|
149
|
+
* Note that the sum of the line item amounts does not need to add up to the `total` amount above.
|
|
150
|
+
*/
|
|
151
|
+
displayItems?: PaymentRequestItem[];
|
|
152
|
+
/**
|
|
153
|
+
* An array of `ShippingOption` objects.
|
|
154
|
+
* The first shipping option listed appears in the browser payment interface as the default option.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
shippingOptions?: PaymentRequestShippingOption[];
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Specify the options to be used when the Apple Pay payment interface opens.
|
|
161
|
+
*/
|
|
162
|
+
applePay?: ApplePayOption;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* An set of options to create this `PaymentRequest` instance with.
|
|
167
|
+
* These options can be updated using `paymentRequest.update`.
|
|
168
|
+
*/
|
|
169
|
+
export interface PaymentRequestOptions {
|
|
170
|
+
/**
|
|
171
|
+
* The two-letter country code of your Stripe account (e.g., `US`).
|
|
172
|
+
*/
|
|
173
|
+
country: string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Three character currency code (e.g., `usd`).
|
|
177
|
+
*/
|
|
178
|
+
currency: string;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* This `PaymentRequestItem` is shown to the customer in the browser’s payment interface.
|
|
182
|
+
*/
|
|
183
|
+
total: PaymentRequestItem;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* An array of PaymentRequestItem objects.
|
|
187
|
+
* These objects are shown as line items in the browser’s payment interface.
|
|
188
|
+
* Note that the sum of the line item amounts does not need to add up to the `total` amount above.
|
|
189
|
+
*/
|
|
190
|
+
displayItems?: PaymentRequestItem[];
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* By default, the browser's payment interface only asks the customer for actual payment information.
|
|
194
|
+
* A customer name can be collected by setting this option to `true`.
|
|
195
|
+
* This collected name will appears in the `PaymentRequestEvent` object.
|
|
196
|
+
*
|
|
197
|
+
* We highly recommend you collect at least one of name, email, or phone as this also results in collection of billing address for Apple Pay.
|
|
198
|
+
* The billing address can be used to perform address verification and block fraudulent payments.
|
|
199
|
+
* For all other payment methods, the billing address is automatically collected when available.
|
|
200
|
+
*/
|
|
201
|
+
requestPayerName?: boolean;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* See the `requestPayerName` option.
|
|
205
|
+
*/
|
|
206
|
+
requestPayerPhone?: boolean;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* See the `requestPayerName` option.
|
|
210
|
+
*/
|
|
211
|
+
requestPayerEmail?: boolean;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Collect shipping address by setting this option to `true`.
|
|
215
|
+
* The address appears in the `PaymentRequestEvent`.
|
|
216
|
+
*
|
|
217
|
+
* You must also supply a valid `PaymentRequestShippingOption` to the `shippingOptions` property.
|
|
218
|
+
* This can be up front at the time `stripe.paymentRequest` is called, or in response to a `shippingaddresschange` event using the `updateWith` callback.
|
|
219
|
+
*/
|
|
220
|
+
requestShipping?: boolean;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* An array of `ShippingOption` objects.
|
|
224
|
+
* The first shipping option listed appears in the browser payment interface as the default option.
|
|
225
|
+
*/
|
|
226
|
+
shippingOptions?: PaymentRequestShippingOption[];
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* An array of wallet strings.
|
|
230
|
+
* Can be one or more of `applePay`, `googlePay`, `link` and `browserCard`.
|
|
231
|
+
* Use this option to disable Apple Pay, Google Pay, Link and/or browser-saved cards.
|
|
232
|
+
*/
|
|
233
|
+
disableWallets?: PaymentRequestWallet[];
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Specify the options to be used when the Apple Pay payment interface opens.
|
|
237
|
+
*/
|
|
238
|
+
applePay?: ApplePayOption;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @deprecated
|
|
242
|
+
* Use disableWallets instead.
|
|
243
|
+
*/
|
|
244
|
+
wallets?: PaymentRequestWallet[];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* A `PaymentRequestItem` object is used to configure a `PaymentRequest`.
|
|
249
|
+
*/
|
|
250
|
+
export interface PaymentRequestItem {
|
|
251
|
+
/**
|
|
252
|
+
* The amount in the currency's subunit (e.g. cents, yen, etc.)
|
|
253
|
+
*/
|
|
254
|
+
amount: number;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* A name that the browser shows the customer in the payment interface.
|
|
258
|
+
*/
|
|
259
|
+
label: string;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* If you might change this amount later (for example, after you have calcluated shipping costs), set this to `true`.
|
|
263
|
+
* Note that browsers treat this as a hint for how to display things, and not necessarily as something that will prevent submission.
|
|
264
|
+
*/
|
|
265
|
+
pending?: boolean;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The `ShippingOption` object describes a shipping method used with a `PaymentRequest`.
|
|
270
|
+
*/
|
|
271
|
+
export interface PaymentRequestShippingOption {
|
|
272
|
+
/**
|
|
273
|
+
* A unique ID you create to keep track of this shipping option.
|
|
274
|
+
* You’ll be told the ID of the selected option on changes and on completion.
|
|
275
|
+
*/
|
|
276
|
+
id: string;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* A short label for this shipping option.
|
|
280
|
+
*/
|
|
281
|
+
label: string;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* A longer description of this shipping option.
|
|
285
|
+
*/
|
|
286
|
+
detail: string;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* The amount to show for this shipping option.
|
|
290
|
+
* If the cost of this shipping option depends on the shipping address the customer enters, listen for the `shippingaddresschange` event.
|
|
291
|
+
*/
|
|
292
|
+
amount: number;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type PaymentRequestWallet =
|
|
296
|
+
| 'applePay'
|
|
297
|
+
| 'googlePay'
|
|
298
|
+
| 'link'
|
|
299
|
+
| 'browserCard';
|
|
300
|
+
|
|
301
|
+
export type PaymentRequestCompleteStatus =
|
|
302
|
+
/**
|
|
303
|
+
* Report to the browser that the payment was successful, and that it can close any active payment interface.
|
|
304
|
+
*/
|
|
305
|
+
| 'success'
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Report to the browser that you were unable to process the customer‘s payment.
|
|
309
|
+
* Browsers may re-show the payment interface, or simply show a message and close.
|
|
310
|
+
*/
|
|
311
|
+
| 'fail'
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
|
|
315
|
+
*/
|
|
316
|
+
| 'invalid_payer_name'
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
|
|
320
|
+
*/
|
|
321
|
+
| 'invalid_payer_phone'
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
|
|
325
|
+
*/
|
|
326
|
+
| 'invalid_payer_email'
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Equivalent to `fail`, except that the browser can choose to show a more-specific error message.
|
|
330
|
+
*/
|
|
331
|
+
| 'invalid_shipping_address';
|
|
332
|
+
|
|
333
|
+
export interface PaymentRequestEvent {
|
|
334
|
+
/**
|
|
335
|
+
* Call this function with a `CompleteStatus` when you have processed the token data provided by the API.
|
|
336
|
+
* Note that you must must call complete within 30 seconds.
|
|
337
|
+
*/
|
|
338
|
+
complete: (status: PaymentRequestCompleteStatus) => void;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The customer's name.
|
|
342
|
+
* Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
|
|
343
|
+
*/
|
|
344
|
+
payerName?: string;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The customer's email.
|
|
348
|
+
* Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
|
|
349
|
+
*/
|
|
350
|
+
payerEmail?: string;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The customer's phone.
|
|
354
|
+
* Only present if it was explicitly asked for [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create).
|
|
355
|
+
*/
|
|
356
|
+
payerPhone?: string;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* The final `ShippingAddress` the customer selected.
|
|
360
|
+
* Only present when `requestShipping` is `true` when [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create), and you've supplied at least one `ShippingOption`.
|
|
361
|
+
*/
|
|
362
|
+
shippingAddress?: PaymentRequestShippingAddress;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* The final `ShippingOption` the customer selected.
|
|
366
|
+
* Only present when `requestShipping` is `true` when [creating the PaymentRequest object](https://stripe.com/docs/js/payment_request/create), and you've supplied at least one `ShippingOption`.
|
|
367
|
+
*/
|
|
368
|
+
shippingOption?: PaymentRequestShippingOption;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* The unique name of the wallet the customer chose to authorize payment.
|
|
372
|
+
* For example, `browserCard`.
|
|
373
|
+
*/
|
|
374
|
+
walletName: PaymentRequestWallet | string;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @deprecated
|
|
378
|
+
* Use walletName instead.
|
|
379
|
+
*/
|
|
380
|
+
methodName: string;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Describes a shipping address collected with a `PaymentRequest`.
|
|
385
|
+
*/
|
|
386
|
+
export interface PaymentRequestShippingAddress {
|
|
387
|
+
/**
|
|
388
|
+
* Two-letter country code, capitalized.
|
|
389
|
+
* Valid two-letter country codes are specified by ISO3166 alpha-2.
|
|
390
|
+
*/
|
|
391
|
+
country?: string;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* An array of address line items.
|
|
395
|
+
* For example, `185 Berry St.`, `Suite 500`, `P.O. Box 12345`, etc.
|
|
396
|
+
*/
|
|
397
|
+
addressLine?: string[];
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* The most coarse subdivision of a country.
|
|
401
|
+
* Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines.
|
|
402
|
+
*/
|
|
403
|
+
region?: string;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* The name of a city, town, village, etc.
|
|
407
|
+
*/
|
|
408
|
+
city?: string;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* The postal code or ZIP code, also known as PIN code in India.
|
|
412
|
+
*/
|
|
413
|
+
postalCode?: string;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* The name of the recipient.
|
|
417
|
+
* This might be a person, a business name, or contain “care of” (c/o) instructions.
|
|
418
|
+
*/
|
|
419
|
+
recipient?: string;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* The phone number of the recipient.
|
|
423
|
+
* Note that this might be different from any phone number you collect with `requestPayerPhone`.
|
|
424
|
+
*/
|
|
425
|
+
phone?: string;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* The sorting code as used in, for example, France.
|
|
429
|
+
* Not present on Apple platforms.
|
|
430
|
+
*/
|
|
431
|
+
sortingCode?: string;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* A logical subdivision of a city.
|
|
435
|
+
* Can be used for things like neighborhoods, boroughs, districts, or UK dependent localities.
|
|
436
|
+
* Not present on Apple platforms.
|
|
437
|
+
*/
|
|
438
|
+
dependentLocality?: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface PaymentRequestTokenEvent extends PaymentRequestEvent {
|
|
442
|
+
token: Token;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface PaymentRequestPaymentMethodEvent extends PaymentRequestEvent {
|
|
446
|
+
paymentMethod: PaymentMethod;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export interface PaymentRequestSourceEvent extends PaymentRequestEvent {
|
|
450
|
+
source: Source;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export interface PaymentRequestShippingAddressEvent {
|
|
454
|
+
/**
|
|
455
|
+
* Call this with an `UpdateDetails` object to merge updates into the current `PaymentRequest` object.
|
|
456
|
+
* Note that if you subscribe to `shippingaddresschange` events, then you must call `updateWith` within 30 seconds.
|
|
457
|
+
*/
|
|
458
|
+
updateWith: (details: PaymentRequestUpdateDetails) => void;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* The customer's selected `ShippingAddress`.
|
|
462
|
+
* To maintain privacy, browsers may anonymize the shipping address by removing sensitive information that is not necessary to calculate shipping costs.
|
|
463
|
+
* Depending on the country, some fields can be missing or partially redacted.
|
|
464
|
+
* For example, the shipping address in the U.S. may only contain a city, state, and ZIP code.
|
|
465
|
+
* The full shipping address appears in the `PaymentRequestEvent` object after the purchase is confirmed in the browser’s payment interface
|
|
466
|
+
*/
|
|
467
|
+
shippingAddress: PaymentRequestShippingAddress;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export type PaymentRequestUpdateDetailsStatus =
|
|
471
|
+
/**
|
|
472
|
+
* Let the customer proceed.
|
|
473
|
+
*/
|
|
474
|
+
| 'success'
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Prevent the customer from making the change they just made.
|
|
478
|
+
*/
|
|
479
|
+
| 'fail'
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Equivalent to `fail`, except we show a more specific error message.
|
|
483
|
+
* Can only be used in a `shippingaddresschange` handler.
|
|
484
|
+
*/
|
|
485
|
+
| 'invalid_shipping_address';
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* An object to pass to the `updateWith` callback on `shippingaddresschange` and `shippingoptionchange` events.
|
|
489
|
+
*/
|
|
490
|
+
export interface PaymentRequestUpdateDetails {
|
|
491
|
+
/**
|
|
492
|
+
* The browser uses this value to show an error message to the customer if they've taken an action that invalidates the payment request.
|
|
493
|
+
*/
|
|
494
|
+
status?: PaymentRequestUpdateDetailsStatus;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* The new total amount, if applicable.
|
|
498
|
+
*/
|
|
499
|
+
total?: PaymentRequestItem;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* These `PaymentRequestItem`s are shown as line items in the browser's payment interface.
|
|
503
|
+
* Note that the sum of the line item amounts does not need to add up to the `total` amount.
|
|
504
|
+
*/
|
|
505
|
+
displayItems?: PaymentRequestItem[];
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* The first shipping option listed appears in the browser payment interface as the default option.
|
|
509
|
+
*/
|
|
510
|
+
shippingOptions?: PaymentRequestShippingOption[];
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Specify new options to refresh the Apple Pay payment interface.
|
|
514
|
+
*/
|
|
515
|
+
applePay?: ApplePayUpdateOption;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export interface PaymentRequestShippingOptionEvent {
|
|
519
|
+
/**
|
|
520
|
+
* Call this with an `UpdateDetails` object to merge updates into the current `PaymentRequest` object.
|
|
521
|
+
* Note that if you subscribe to `shippingaddresschange` events, then you must call `updateWith` within 30 seconds.
|
|
522
|
+
*/
|
|
523
|
+
updateWith: (details: PaymentRequestUpdateDetails) => void;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* The customer's selected `ShippingOption`.
|
|
527
|
+
*/
|
|
528
|
+
shippingOption: PaymentRequestShippingOption;
|
|
529
|
+
}
|