@stripe/stripe-js 1.28.0 → 1.31.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/pure.esm.js +1 -1
- package/dist/pure.js +1 -1
- package/dist/stripe.esm.js +1 -1
- package/dist/stripe.js +1 -1
- package/package.json +1 -1
- package/types/api/index.d.ts +1 -0
- package/types/api/orders.d.ts +122 -0
- package/types/api/payment-methods.d.ts +2 -0
- package/types/stripe-js/elements/payment.d.ts +17 -0
- package/types/stripe-js/elements/shipping-address.d.ts +0 -8
- package/types/stripe-js/elements-group.d.ts +21 -3
- package/types/stripe-js/orders.d.ts +9 -0
- package/types/stripe-js/payment-request.d.ts +5 -0
- package/types/stripe-js/stripe.d.ts +54 -1
package/dist/pure.esm.js
CHANGED
package/dist/pure.js
CHANGED
package/dist/stripe.esm.js
CHANGED
package/dist/stripe.js
CHANGED
package/package.json
CHANGED
package/types/api/index.d.ts
CHANGED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {Address} from './shared';
|
|
2
|
+
import {PaymentIntent} from './payment-intents';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Order object.
|
|
6
|
+
*/
|
|
7
|
+
export interface Order {
|
|
8
|
+
/**
|
|
9
|
+
* Unique identifier for the object.
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* String representing the object's type. Objects of the same type share the same value.
|
|
15
|
+
*/
|
|
16
|
+
object: 'order';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Total order cost after discounts and taxes are applied. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts).
|
|
20
|
+
*/
|
|
21
|
+
amount_total: number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Order cost before any discounts or taxes are applied. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
|
|
25
|
+
*/
|
|
26
|
+
amount_subtotal: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Customer billing details associated with the order.
|
|
30
|
+
*/
|
|
31
|
+
billing_details: Order.Billing | null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
|
|
35
|
+
*/
|
|
36
|
+
currency: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Time at which the object was created. Measured in seconds since the Unix epoch.
|
|
40
|
+
*/
|
|
41
|
+
created: number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
|
45
|
+
*/
|
|
46
|
+
livemode: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Customer shipping information associated with the order.
|
|
50
|
+
*/
|
|
51
|
+
shipping_details: Order.Shipping | null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Payment information associated with the order.
|
|
55
|
+
*/
|
|
56
|
+
payment: Order.Payment;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The overall status of the order.
|
|
60
|
+
*/
|
|
61
|
+
status: Order.Status;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export namespace Order {
|
|
65
|
+
export interface Billing {
|
|
66
|
+
/**
|
|
67
|
+
* Billing address for the order.
|
|
68
|
+
*/
|
|
69
|
+
address?: Address;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Email address for the order.
|
|
73
|
+
*/
|
|
74
|
+
email?: string | null;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Full name for the order.
|
|
78
|
+
*/
|
|
79
|
+
name?: string | null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Billing phone number for the order (including extension).
|
|
83
|
+
*/
|
|
84
|
+
phone?: string | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface Shipping {
|
|
88
|
+
/**
|
|
89
|
+
* Recipient shipping address. Required if the order includes products that are shippable.
|
|
90
|
+
*/
|
|
91
|
+
address?: Address;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Recipient name.
|
|
95
|
+
*/
|
|
96
|
+
name?: string | null;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Recipient phone (including extension).
|
|
100
|
+
*/
|
|
101
|
+
phone?: string | null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface Payment {
|
|
105
|
+
/**
|
|
106
|
+
* Payment intent associated with this order. Null when the order is `open`.
|
|
107
|
+
*/
|
|
108
|
+
payment_intent?: PaymentIntent | null;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The status of the underlying payment associated with this order, if any. Null when the order is `open`.
|
|
112
|
+
*/
|
|
113
|
+
status?: PaymentIntent.Status | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type Status =
|
|
117
|
+
| 'open'
|
|
118
|
+
| 'submitted'
|
|
119
|
+
| 'processing'
|
|
120
|
+
| 'complete'
|
|
121
|
+
| 'canceled';
|
|
122
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {StripeElementBase} from './base';
|
|
2
|
+
import {StripeError} from '../stripe';
|
|
2
3
|
|
|
3
4
|
export type StripePaymentElement = StripeElementBase & {
|
|
4
5
|
/**
|
|
@@ -81,6 +82,22 @@ export type StripePaymentElement = StripeElementBase & {
|
|
|
81
82
|
handler?: (event: {elementType: 'payment'}) => any
|
|
82
83
|
): StripePaymentElement;
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Triggered when the element fails to load.
|
|
87
|
+
*/
|
|
88
|
+
on(
|
|
89
|
+
eventType: 'loaderror',
|
|
90
|
+
handler: (event: {elementType: 'payment'; error: StripeError}) => any
|
|
91
|
+
): StripePaymentElement;
|
|
92
|
+
once(
|
|
93
|
+
eventType: 'loaderror',
|
|
94
|
+
handler: (event: {elementType: 'payment'; error: StripeError}) => any
|
|
95
|
+
): StripePaymentElement;
|
|
96
|
+
off(
|
|
97
|
+
eventType: 'loaderror',
|
|
98
|
+
handler?: (event: {elementType: 'payment'; error: StripeError}) => any
|
|
99
|
+
): StripePaymentElement;
|
|
100
|
+
|
|
84
101
|
/**
|
|
85
102
|
* Updates the options the `PaymentElement` was initialized with.
|
|
86
103
|
* Updates are merged into the existing configuration.
|
|
@@ -80,14 +80,6 @@ export type StripeShippingAddressElement = StripeElementBase & {
|
|
|
80
80
|
eventType: 'escape',
|
|
81
81
|
handler?: (event: {elementType: 'shippingAddress'}) => any
|
|
82
82
|
): StripeShippingAddressElement;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Updates the options the `ShippingAddressElement` was initialized with.
|
|
86
|
-
* Updates are merged into the existing configuration.
|
|
87
|
-
*/
|
|
88
|
-
update(
|
|
89
|
-
options: Partial<StripeShippingAddressElementOptions>
|
|
90
|
-
): StripeShippingAddressElement;
|
|
91
83
|
};
|
|
92
84
|
|
|
93
85
|
export interface StripeShippingAddressElementOptions {
|
|
@@ -471,6 +471,15 @@ export interface StripeElementsOptions {
|
|
|
471
471
|
* Default is `'auto'` (Stripe determines if a loader UI should be shown).
|
|
472
472
|
*/
|
|
473
473
|
loader?: 'auto' | 'always' | 'never';
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Requires beta access:
|
|
477
|
+
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
478
|
+
*
|
|
479
|
+
* Display saved PaymentMethods and Customer information.
|
|
480
|
+
* Supported for the `payment`, `shippingAddress`, and `linkAuthentication` Elements.
|
|
481
|
+
*/
|
|
482
|
+
customerOptions?: CustomerOptions;
|
|
474
483
|
}
|
|
475
484
|
|
|
476
485
|
/*
|
|
@@ -485,9 +494,6 @@ export interface StripeElementsUpdateOptions {
|
|
|
485
494
|
locale?: StripeElementLocale;
|
|
486
495
|
|
|
487
496
|
/**
|
|
488
|
-
* Used with the Payment Element, requires beta access:
|
|
489
|
-
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
490
|
-
*
|
|
491
497
|
* Match the design of your site with the appearance option.
|
|
492
498
|
* The layout of each Element stays consistent, but you can modify colors, fonts, borders, padding, and more.
|
|
493
499
|
*
|
|
@@ -638,3 +644,15 @@ export interface Appearance {
|
|
|
638
644
|
|
|
639
645
|
labels?: 'above' | 'floating';
|
|
640
646
|
}
|
|
647
|
+
|
|
648
|
+
export interface CustomerOptions {
|
|
649
|
+
/**
|
|
650
|
+
* The Customer id.
|
|
651
|
+
*/
|
|
652
|
+
customer: string;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* The ephemeral key for a Customer that grants temporary access to Customer data.
|
|
656
|
+
*/
|
|
657
|
+
ephemeralKey: string;
|
|
658
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters that will be passed on to the Stripe API to confirm payment for an Order's PaymentIntent.
|
|
3
|
+
*/
|
|
4
|
+
export interface ProcessOrderParams {
|
|
5
|
+
/**
|
|
6
|
+
* The url your customer will be directed to after they complete payment.
|
|
7
|
+
*/
|
|
8
|
+
return_url: string;
|
|
9
|
+
}
|
|
@@ -14,6 +14,11 @@ export interface PaymentRequest {
|
|
|
14
14
|
*/
|
|
15
15
|
show(): void;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Closes the browser’s payment interface.
|
|
19
|
+
*/
|
|
20
|
+
abort: () => void;
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* `true` if the browser’s payment interface is showing.
|
|
19
24
|
* When using the `PaymentRequestButtonElement`, this is called for you automatically.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as api from '../api';
|
|
2
2
|
import * as paymentIntents from './payment-intents';
|
|
3
3
|
import * as setupIntents from './setup-intents';
|
|
4
|
+
import * as orders from './orders';
|
|
4
5
|
import * as tokens from './token-and-sources';
|
|
5
6
|
import * as elements from './elements';
|
|
6
7
|
|
|
@@ -47,7 +48,7 @@ export interface Stripe {
|
|
|
47
48
|
* When called, `stripe.confirmPayment` will attempt to complete any [required actions](https://stripe.com/docs/payments/intents), such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
|
|
48
49
|
* Your user will be redirected to the return_url you pass once the confirmation is complete.
|
|
49
50
|
*
|
|
50
|
-
* By default, stripe
|
|
51
|
+
* By default, `stripe.confirmPayment` will always redirect to your return_url after a successful confirmation.
|
|
51
52
|
* If you set `redirect: "if_required"`, then `stripe.confirmPayment` will only redirect if your user chooses a redirect-based payment method.
|
|
52
53
|
* Setting `if_required` requires that you handle successful confirmations for redirect-based and non-redirect based payment methods separately.
|
|
53
54
|
*
|
|
@@ -795,6 +796,49 @@ export interface Stripe {
|
|
|
795
796
|
*/
|
|
796
797
|
retrieveSetupIntent(clientSecret: string): Promise<SetupIntentResult>;
|
|
797
798
|
|
|
799
|
+
/////////////////////////////
|
|
800
|
+
/// Orders
|
|
801
|
+
///
|
|
802
|
+
/// https://stripe.com/docs/js/orders
|
|
803
|
+
/////////////////////////////
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Use `stripe.processOrder` to submit and confirm payment for an [Order](https://stripe.com/docs/api/orders_v2) using data collected by the [Payment Element](https://stripe.com/docs/js/element/payment_element).
|
|
807
|
+
* When called, `stripe.processOrder` will attempt to complete any required actions, such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
|
|
808
|
+
* Your user will be redirected to the return_url you pass once the confirmation is complete.
|
|
809
|
+
*
|
|
810
|
+
* By default, `stripe.processOrder` will always redirect to your return_url after a successful confirmation.
|
|
811
|
+
* If you set `redirect: "if_required"`, then `stripe.processOrder` will only redirect if your user chooses a redirect-based method.
|
|
812
|
+
* Setting `if_required` requires that you handle successful confirmations for redirect-based and non-redirect based payment methods separately.
|
|
813
|
+
*
|
|
814
|
+
* @docs https://stripe.com/docs/js/orders/process_order
|
|
815
|
+
*/
|
|
816
|
+
processOrder(options: {
|
|
817
|
+
elements: StripeElements;
|
|
818
|
+
confirmParams?: Partial<orders.ProcessOrderParams>;
|
|
819
|
+
redirect: 'if_required';
|
|
820
|
+
}): Promise<ProcessOrderResult>;
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Use `stripe.processOrder` to submit and confirm payment for an [Order](https://stripe.com/docs/api/orders_v2) using data collected by the [Payment Element](https://stripe.com/docs/js/element/payment_element).
|
|
824
|
+
* When called, `stripe.processOrder` will attempt to complete any required actions, such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page.
|
|
825
|
+
* Your user will be redirected to the return_url you pass once the confirmation is complete.
|
|
826
|
+
*
|
|
827
|
+
* @docs https://stripe.com/docs/js/orders/process_order
|
|
828
|
+
*/
|
|
829
|
+
processOrder(options: {
|
|
830
|
+
elements: StripeElements;
|
|
831
|
+
confirmParams: orders.ProcessOrderParams;
|
|
832
|
+
redirect?: 'always';
|
|
833
|
+
}): Promise<never | {error: StripeError}>;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Retrieve an [Order](https://stripe.com/docs/api/orders_v2) using its [client secret](https://stripe.com/docs/api/orders_v2/object#order_v2_object-client_secret).
|
|
837
|
+
*
|
|
838
|
+
* @docs https://stripe.com/docs/js/orders/retrieve_order
|
|
839
|
+
*/
|
|
840
|
+
retrieveOrder(clientSecret: string): Promise<RetrieveOrderResult>;
|
|
841
|
+
|
|
798
842
|
/////////////////////////////
|
|
799
843
|
/// Payment Request
|
|
800
844
|
///
|
|
@@ -941,6 +985,15 @@ export type SetupIntentResult =
|
|
|
941
985
|
| {setupIntent: api.SetupIntent; error?: undefined}
|
|
942
986
|
| {setupIntent?: undefined; error: StripeError};
|
|
943
987
|
|
|
988
|
+
export type ProcessOrderResult =
|
|
989
|
+
| {paymentIntent: api.PaymentIntent; order: api.Order; error?: undefined}
|
|
990
|
+
| {paymentIntent?: undefined; order: api.Order; error?: undefined}
|
|
991
|
+
| {paymentIntent?: undefined; order?: undefined; error: StripeError};
|
|
992
|
+
|
|
993
|
+
export type RetrieveOrderResult =
|
|
994
|
+
| {order: api.Order; error?: undefined}
|
|
995
|
+
| {order?: undefined; error: StripeError};
|
|
996
|
+
|
|
944
997
|
export type PaymentMethodResult =
|
|
945
998
|
| {paymentMethod: api.PaymentMethod; error?: undefined}
|
|
946
999
|
| {paymentMethod?: undefined; error: StripeError};
|