Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import {
BraintreeError,
BraintreeFormOptions,
} from '@bigcommerce/checkout-sdk/braintree-utils';
import { StandardError } from '@bigcommerce/checkout-sdk/payment-integration-api';
import { RequestOptions } from '@bigcommerce/request-sender';
import { BraintreeThreeDSecureOptions } from '@bigcommerce/checkout-sdk/braintree-integration';

export interface PaymentRequestOptions extends RequestOptions {
/**
* The identifier of the payment method.
*/
methodId: string;

/**
* The identifier of the payment provider providing the payment method. This
* option is only required if the provider offers multiple payment options.
* i.e.: Adyen and Klarna.
*/
gatewayId?: string;
}

interface BraintreePaymentInitializeOptions {
/**
* The CSS selector of a container where the payment widget should be inserted into.
*/
containerId?: string;

threeDSecure?: BraintreeThreeDSecureOptions;

/**
* @alpha
* Please note that this option is currently in an early stage of
* development. Therefore the API is unstable and not ready for public
* consumption.
*/
form?: BraintreeFormOptions;

/**
* The location to insert the Pay Later Messages.
*/
bannerContainerId?: string;

/**
* A callback right before render Smart Payment Button that gets called when
* Smart Payment Button is eligible. This callback can be used to hide the standard submit button.
*/
onRenderButton?(): void;

/**
* A callback for submitting payment form that gets called
* when buyer approved PayPal account.
*/
submitForm?(): void;

/**
* A callback that gets called if unable to submit payment.
*
* @param error - The error object describing the failure.
*/
onPaymentError?(error: BraintreeError | StandardError): void;

/**
* A callback for displaying error popup. This callback requires error object as parameter.
*/
onError?(error: unknown): void;

/**
* A list of card brands that are not supported by the merchant.
*
* List of supported brands by braintree can be found here: https://braintree.github.io/braintree-web/current/module-braintree-web_hosted-fields.html#~field
* search for `supportedCardBrands` property.
*
* List of credit cards brands:
* 'visa',
* 'mastercard',
* 'american-express',
* 'diners-club',
* 'discover',
* 'jcb',
* 'union-pay',
* 'maestro',
* 'elo',
* 'mir',
* 'hiper',
* 'hipercard'
*
* */
unsupportedCardBrands?: string[];
}

/**
* A set of options that are required to initialize the payment step of the
* current checkout flow.
*/
export interface WithBraintreeCreditCardPaymentStrategyInitializeOptions extends PaymentRequestOptions {

/**
* The options that are required to initialize the Braintree payment method.
* They can be omitted unless you need to support Braintree.
*/
braintree?: BraintreePaymentInitializeOptions;
}
Loading