From 1a90baaee68e25c6915272cb623a3d11a7ffddb7 Mon Sep 17 00:00:00 2001 From: Jason Hoetger Date: Wed, 24 Jul 2019 12:54:01 -0700 Subject: [PATCH] Added additional properties for Payment Intents (#37054) --- types/stripe/index.d.ts | 103 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 9 deletions(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 923d8580bc..93620e5577 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1305,12 +1305,12 @@ declare namespace Stripe { /** * ID of the payment method used in this charge. */ - payment_method: string; + payment_method: string | null; /** * Details about the payment method at the time of the transaction. */ - payment_method_details: IPaymentMethodDetails; + payment_method_details: IPaymentMethodDetails | null; /** * This is the email address that the receipt for this charge was sent to. @@ -1353,8 +1353,9 @@ declare namespace Stripe { /** * For most Stripe users, the source of every charge is a credit or debit card. * This hash is then the card object describing that card. + * This value is null if this charge is associated with a Payment Intent instead of a Source. */ - source: IStripeSource; + source: IStripeSource | null; /** * The transfer ID which created this charge. Only present if the charge came @@ -1631,6 +1632,8 @@ declare namespace Stripe { | IStripeAccountPaymentMethodDetails | IWechatPaymentMethodDetails; + type IPaymentMethodType = IPaymentMethodDetails["type"]; + interface IAchCreditTransferPaymentMethodDetails { type: "ach_credit_transfer"; ach_credit_transfer: { @@ -1680,7 +1683,7 @@ declare namespace Stripe { /** * Card brand. Can be `amex`, `diners`, `discover`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. */ - brand: "amex" | "diner" | "discover" | "jcb" | "mastercard" | "unionpay" | "visa" | "unknown"; + brand: "amex" | "diners" | "discover" | "jcb" | "mastercard" | "unionpay" | "visa" | "unknown"; /** * Check results by Card networks on Card address and CVC at time of payment. @@ -1732,7 +1735,7 @@ declare namespace Stripe { /** * The last four digits of the card. */ - last4: number; + last4: string; /** * Populated if this transaction used 3D Secure authentication. @@ -4485,10 +4488,31 @@ declare namespace Stripe { */ on_behalf_of?: string | null; + /** + * ID of the payment method used in this PaymentIntent. [Expandable] + */ + payment_method?: string | null; + + /** + * Payment-method-specific configuration for this PaymentIntent. + */ + payment_method_options?: { + /** + * Configuration for any card payments attempted on this PaymentIntent. + */ + card?: { + /** + * We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and other requirements. However, if you wish to request 3D Secure based on + * logic from your own fraud engine, provide this option. Permitted values include: automatic, any, or challenge_only. If not provided, defaults to automatic. + */ + request_three_d_secure?: "automatic" | "challenge_only" | "any"; + } + }; + /** * The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. */ - payment_method_types: string[]; + payment_method_types: PaymentIntentPaymentMethodType[]; /** * Email address that the receipt for the resulting payment will be sent to. @@ -4515,7 +4539,8 @@ declare namespace Stripe { */ source: | string - | IStripeSource; + | IStripeSource + | null; /** * Extra information about a PaymentIntent. This will appear on your customer’s statement when this PaymentIntent succeeds in creating a charge. @@ -4572,6 +4597,9 @@ declare namespace Stripe { use_stripe_sdk: any; } + /** Payment methods supported by Payment Intents. This is a subsetset of all Payment Method types. See https://stripe.com/docs/api/payment_methods/create#create_payment_method-type */ + type PaymentIntentPaymentMethodType = 'card' | 'card_present'; + interface IPaymentIntentCreationOptions { /** * Amount intended to be collected by this PaymentIntent (in cents). @@ -4589,9 +4617,25 @@ declare namespace Stripe { payment_method?: string; /** - * The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. + * The list of payment method types that this PaymentIntent is allowed to use. If this is not provided, defaults to ["card"]. */ - payment_method_types: string[]; + payment_method_types?: PaymentIntentPaymentMethodType[]; + + /** + * Payment-method-specific configuration for this PaymentIntent. + */ + payment_method_options?: { + /** + * Configuration for any card payments attempted on this PaymentIntent. + */ + card?: { + /** + * We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and other requirements. However, if you wish to request 3D Secure based on + * logic from your own fraud engine, provide this option. Permitted values include: automatic, any, or challenge_only. If not provided, defaults to automatic. + */ + request_three_d_secure?: "automatic" | "challenge_only" | "any"; + } + }; /** * The amount of the application fee in cents (if any) that will be applied to the payment and transferred to the application owner’s Stripe account. To use an application fee, the request must be made on behalf of another account, using the `Stripe-Account` header or an OAuth key. @@ -4711,6 +4755,16 @@ declare namespace Stripe { */ metadata?: IOptionsMetadata; + /** + * ID of the payment method (a PaymentMethod, Card, BankAccount, or saved Source object) to attach to this PaymentIntent. + */ + payment_method?: string; + + /** + * The list of payment method types that this PaymentIntent is allowed to use. + */ + payment_method_types?: PaymentIntentPaymentMethodType[]; + /** * Email address that the receipt for the resulting payment will be sent to. */ @@ -4731,6 +4785,11 @@ declare namespace Stripe { */ shipping?: IShippingInformation; + /** + * Extra information about a PaymentIntent. This will appear on your customer’s statement when this PaymentIntent succeeds in creating a charge. + */ + statement_descriptor?: string; + /** * ID of the Source object to attach to this PaymentIntent. */ @@ -4748,11 +4807,37 @@ declare namespace Stripe { */ client_secret?: string; + /** + * Set to true to indicate that the customer is not in your checkout flow during this payment attempt, and therefore is unable to authenticate. This parameter is intended for scenarios where you collect card details and charge them later. + */ + off_session?: boolean; + /** * ID of the payment method (a PaymentMethod, Card, BankAccount, or saved Source object) to attach to this PaymentIntent. */ payment_method?: string; + /** + * Payment-method-specific configuration for this PaymentIntent. + */ + payment_method_options?: { + /** + * Configuration for any card payments attempted on this PaymentIntent. + */ + card?: { + /** + * We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and other requirements. However, if you wish to request 3D Secure based on + * logic from your own fraud engine, provide this option. Permitted values include: automatic, any, or challenge_only. If not provided, defaults to automatic. + */ + request_three_d_secure?: "automatic" | "challenge_only" | "any"; + } + }; + + /** + * The list of payment method types that this PaymentIntent is allowed to use. + */ + payment_method_types?: PaymentIntentPaymentMethodType[]; + /** * Email address that the receipt for the resulting payment will be sent to. */