@stripe/stripe-js 1.30.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/stripe-js/orders.d.ts +9 -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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};
|