Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added type declarations for BLIK payment. #411

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,28 @@ stripe
.confirmBancontactPayment('')
.then((result: {paymentIntent?: PaymentIntent; error?: StripeError}) => null);

stripe
.confirmBlikPayment(
'',
{
payment_method: {
blik: {},
billing_details: {
email: '[email protected]',
},
},
payment_method_options: {
blik: {
code: '123456',
},
},
},
{
handleActions: false,
}
)
.then((result: {paymentIntent?: PaymentIntent; error?: StripeError}) => null);

stripe
.confirmBoletoPayment(
'',
Expand Down
49 changes: 49 additions & 0 deletions types/stripe-js/payment-intents.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type CreatePaymentMethodData =
| CreatePaymentMethodAuBecsDebitData
| CreatePaymentMethodBacsDebitData
| CreatePaymentMethodBancontactData
| CreatePaymentMethodBlikData
| CreatePaymentMethodBoletoData
| CreatePaymentMethodCardData
| CreatePaymentMethodCustomerBalanceData
Expand Down Expand Up @@ -89,6 +90,15 @@ export interface CreatePaymentMethodBancontactData
};
}

export interface CreatePaymentMethodBlikData extends PaymentMethodCreateParams {
type: 'blik';

/**
* Details about the BLIK pament method. Currently there are no supported child attributes for this field.
*/
blik?: {}; // eslint-disable-line @typescript-eslint/ban-types
}

export interface CreatePaymentMethodBoletoData
extends PaymentMethodCreateParams {
type: 'boleto';
Expand Down Expand Up @@ -531,6 +541,35 @@ export interface ConfirmBancontactPaymentData
return_url?: string;
}

/**
* Data to be sent with a `stripe.ConfirmBlikPayment` request.
* Refer to the [Payment Intents API](https://stripe.com/docs/api/payment_intents/confirm) for a full list of parameters.
*/
export interface ConfirmBlikPaymentData extends PaymentIntentConfirmParams {
/**
* Either the `id` of an existing [PaymentMethod](https://stripe.com/docs/api/payment_methods), or an object containing data to create a `PaymentMethod` with.
* This field is optional if a `PaymentMethod` has already been attached to this `PaymentIntent`.
*
* @recommended
*/
payment_method?: string | Omit<CreatePaymentMethodBlikData, 'type'>;

/**
* An object containing payment-method-specific configuration to confirm the [PaymentIntent](https://stripe.com/docs/api/payment_intents) with.
*/
payment_method_options: {
/**
* A configuration for this BLIK payment.
*/
blik: {
/**
* Your customer's 6-digit BLIK code.
*/
code: string;
};
};
}

/**
* Data to be sent with a `stripe.confirmBoletoPayment` request.
* Refer to the [Payment Intents API](https://stripe.com/docs/api/payment_intents/confirm) for a full list of parameters.
Expand Down Expand Up @@ -598,6 +637,16 @@ export interface ConfirmBancontactPaymentOptions {
handleActions?: boolean;
}

/**
* An options object to control the behavior of `stripe.confirmBlikPayment`.
*/
export interface ConfirmBlikPaymentOptions {
/**
* Set this to false if you want to manually determine if the confirmation has succeeded or failed.
*/
handleActions?: boolean;
}

/**
* Data to be sent with a `stripe.confirmCardPayment` request.
* Refer to the [Payment Intents API](https://stripe.com/docs/api/payment_intents/confirm) for a full list of parameters.
Expand Down
12 changes: 12 additions & 0 deletions types/stripe-js/stripe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ export interface Stripe {
options?: paymentIntents.ConfirmBancontactPaymentOptions
): Promise<PaymentIntentResult>;

/**
* Use `stripe.confirmBlikPayment` in the [BLIK Payments with Payment Methods](https://stripe.com/docs/payments/blik) flow when the customer submits your payment form.
* When called, it will confirm the PaymentIntent with data you provide, and it will automatically prompt the customer to authorize the transaction.
*
* @docs https://stripe.com/docs/js/payment_intents/confirm_blik_payment
*/
confirmBlikPayment(
clientSecret: string,
data: paymentIntents.ConfirmBlikPaymentData,
options?: paymentIntents.ConfirmBlikPaymentOptions
): Promise<PaymentIntentResult>;

/**
* Use `stripe.confirmBoletoPayment` in the [Boleto Payment](https://stripe.com/docs/payments/boleto) with Payment Methods flow when the customer submits your payment form.
* When called, it will confirm the [PaymentIntent](https://stripe.com/docs/api/payment_intents) with `data` you provide.
Expand Down