|
| 1 | +import { |
| 2 | + BraintreeError, |
| 3 | + BraintreeFormOptions, |
| 4 | + BraintreeThreeDSecureOptions, |
| 5 | +} from '@bigcommerce/checkout-sdk/braintree-utils'; |
| 6 | +import { StandardError } from '@bigcommerce/checkout-sdk/payment-integration-api'; |
| 7 | +import { RequestOptions } from '@bigcommerce/request-sender'; |
| 8 | + |
| 9 | +export interface PaymentRequestOptions extends RequestOptions { |
| 10 | + /** |
| 11 | + * The identifier of the payment method. |
| 12 | + */ |
| 13 | + methodId: string; |
| 14 | + |
| 15 | + /** |
| 16 | + * The identifier of the payment provider providing the payment method. This |
| 17 | + * option is only required if the provider offers multiple payment options. |
| 18 | + * i.e.: Adyen and Klarna. |
| 19 | + */ |
| 20 | + gatewayId?: string; |
| 21 | +} |
| 22 | + |
| 23 | +interface BraintreePaymentInitializeOptions { |
| 24 | + /** |
| 25 | + * The CSS selector of a container where the payment widget should be inserted into. |
| 26 | + */ |
| 27 | + containerId?: string; |
| 28 | + |
| 29 | + threeDSecure?: BraintreeThreeDSecureOptions; |
| 30 | + |
| 31 | + /** |
| 32 | + * @alpha |
| 33 | + * Please note that this option is currently in an early stage of |
| 34 | + * development. Therefore the API is unstable and not ready for public |
| 35 | + * consumption. |
| 36 | + */ |
| 37 | + form?: BraintreeFormOptions; |
| 38 | + |
| 39 | + /** |
| 40 | + * The location to insert the Pay Later Messages. |
| 41 | + */ |
| 42 | + bannerContainerId?: string; |
| 43 | + |
| 44 | + /** |
| 45 | + * A callback right before render Smart Payment Button that gets called when |
| 46 | + * Smart Payment Button is eligible. This callback can be used to hide the standard submit button. |
| 47 | + */ |
| 48 | + onRenderButton?(): void; |
| 49 | + |
| 50 | + /** |
| 51 | + * A callback for submitting payment form that gets called |
| 52 | + * when buyer approved PayPal account. |
| 53 | + */ |
| 54 | + submitForm?(): void; |
| 55 | + |
| 56 | + /** |
| 57 | + * A callback that gets called if unable to submit payment. |
| 58 | + * |
| 59 | + * @param error - The error object describing the failure. |
| 60 | + */ |
| 61 | + onPaymentError?(error: BraintreeError | StandardError): void; |
| 62 | + |
| 63 | + /** |
| 64 | + * A callback for displaying error popup. This callback requires error object as parameter. |
| 65 | + */ |
| 66 | + onError?(error: unknown): void; |
| 67 | + |
| 68 | + /** |
| 69 | + * A list of card brands that are not supported by the merchant. |
| 70 | + * |
| 71 | + * List of supported brands by braintree can be found here: https://braintree.github.io/braintree-web/current/module-braintree-web_hosted-fields.html#~field |
| 72 | + * search for `supportedCardBrands` property. |
| 73 | + * |
| 74 | + * List of credit cards brands: |
| 75 | + * 'visa', |
| 76 | + * 'mastercard', |
| 77 | + * 'american-express', |
| 78 | + * 'diners-club', |
| 79 | + * 'discover', |
| 80 | + * 'jcb', |
| 81 | + * 'union-pay', |
| 82 | + * 'maestro', |
| 83 | + * 'elo', |
| 84 | + * 'mir', |
| 85 | + * 'hiper', |
| 86 | + * 'hipercard' |
| 87 | + * |
| 88 | + * */ |
| 89 | + unsupportedCardBrands?: string[]; |
| 90 | +} |
| 91 | + |
| 92 | +/** |
| 93 | + * A set of options that are required to initialize the payment step of the |
| 94 | + * current checkout flow. |
| 95 | + */ |
| 96 | +export interface WithBraintreeCreditCardPaymentStrategyInitializeOptions extends PaymentRequestOptions { |
| 97 | + |
| 98 | + /** |
| 99 | + * The options that are required to initialize the Braintree payment method. |
| 100 | + * They can be omitted unless you need to support Braintree. |
| 101 | + */ |
| 102 | + braintree?: BraintreePaymentInitializeOptions; |
| 103 | +} |
0 commit comments