FlowComponent
Last updated: May 14, 2025
Submits a FlowComponent
, if you require your own pay button.
Information
This option is not available for digital wallets, including Apple Pay and Google Pay.
1function submit() {2return FlowComponent;3}
This method must be used with your own pay button. It submits a FlowComponent
element with card tokenization. This method only works with card payments.
Returns a JavaScript Promise that resolves with the TokenizeResult
object, which includes the following fields:
type
– The name of the payment method that triggered the tokenization. Onlycard
is supported.data
– The Card Tokenization response.cardMetadata
– An optional Card Metadata lookup response object included when a Card Metadata API response is received during customer input.
1const cardComponent = checkout.create('card');23if (await cardComponent.isAvailable()) {4cardComponent.mount('#card-container');5}67const cardPayButton = document.getElementbyId('card-pay-button');89cardPayButton.addEventListener('click', async () => {10const { data } = await cardComponent.tokenize();1112await utilizeToken(data.token);13});+
Checks if the FlowComponent
has captured all details from the customer and can be submitted.
1function isValid() {2return boolean;3}
Checks if the FlowComponent
can be rendered. Call this before mounting the FlowComponent
.
1function isAvailable() {2return Promise<boolean>;3}
Mounts a FlowComponent
to a page. You can either provide:
Parameter | Type | Description |
---|---|---|
|
| The Element Selector or DOM Element object to mount to |
1function mount('#element') {2return FlowComponent;3}
Unmounts a FlowComponent
from the page.
This stops rendering the component, and removes all life-cycles from the browser.
1function unmount() {2return FlowComponent;3}
Raised when a FlowComponent
is initialized and ready for the customer to interact.
1const flowComponent = checkout.create('flow', {2onReady: (_self) => {3// Hide loading overlay4hideLoadingOverlay();5},6});7flowComponent.mount('#flow-container');
Raised when a FlowComponent
changes after a customer interaction.
1const flowComponent = checkout.create('flow', {2onChange: (_self) => {3// Enable/disable custom pay button based on input validity4if (self.isValid()) {5submitButton.removeAttribute('disabled');6} else {7submitButton.setAttribute('disabled', true);8}9},10});11flowComponent.mount('#flow-container');
Raised when you or the customer have triggered a FlowComponent
submission.
1const flowComponent = checkout.create('flow', {2onSubmit: (_self) => {3// Show loading overlay to prevent further user interaction4showLoadingOverlay();5},6});7flowComponent.mount('#flow-container');
Raised when the payment has been completed synchronously.
This event will not be raised if the payment requires asynchronous action. For example, 3DS authentication.
The PaymentResponse
object contains information on the successful payment:
id
- a unique identifier for the payment.status
- the payment status. This value will always returnApproved
.type
- the name of the payment method that was used for the payment.
1const flowComponent = checkout.create('flow', {2onPaymentCompleted: async (_self, paymentResponse) => {3// Complete order in server side4await completeOrder(paymentResponse.id);5},6});7flowComponent.mount('#flow-container');
Raised when an error occurs. For more information, see the CheckoutError reference.
1const flowComponent = checkout.create('flow', {2onError: async (_self, error) => {3// Display payment request failure message4if (error.code === 'payment_request_failed') {5showErrorMessage('Payment could not be processed. Please try again.');6}7},8});9flowComponent.mount('#flow-container');
Raised when the customer inputs or changes the first 8 digits of a card.
You can use this event to perform checks on a card based on its metadata or to observe changes to the BIN.
The CardMetadataResponse
object contains the Card Metadata lookup response.
Flow accepts the card if your provided callback doesn't return a response, or you can provide one of the following objects:
- Accept the card:
{ continue: true }
- Reject the card:
{ continue: false, errorMessage: "Message" }
- Provide the optional
errorMessage
to display a custom error message on Flow when rejecting the card.
1const flowComponent = checkout.create('flow', {2onCardBinChanged: (_self, cardMetadata) => {3if (card_metadata.card_type === 'credit') {4return {5continue: false,6errorMessage: 'Credit cards are not accepted.',7};8}9return { continue: true };10}11});1213flowComponent.mount('#flow-container');
Raised when the cardholder details provided by the customer have been tokenized.
You can use this event to perform checks on a card based on its tokenization result and metadata.
The TokenizeResult
object contains the following information:
type
– The name of the payment method that triggered the tokenization. Onlycard
is supported.data
– The Card Tokenization response.cardMetadata
– An optional Card Metadata lookup response object included when a Card Metadata API response is received during customer input.
Flow accepts the card if your provided callback doesn't return a response, or you can provide one of the following objects:
- Accept the card:
{ continue: true }
- Reject the card:
{ continue: false, errorMessage: "Message" }
- Provide the optional
errorMessage
to display a custom error message on Flow when rejecting the card
1const flowComponent = checkout.create('flow', {2onTokenized: (_self, tokenizeResult) => {3if (tokenizeResult.data.card_type === 'CREDIT') {4return {5continue: false,6errorMessage: 'Credit cards are not accepted.',7};8}9return { continue: true };10}11});1213flowComponent.mount('#flow-container');
Raised when a wallet payment button is clicked. For example, Apple Pay, Google Pay, or PayPal.
You can use this to perform checks before beginning the payment process.
FlowComponent
is the instance that triggered the callback.
1const flowComponent = checkout.create('flow', {2handleClick: (_self) => {3if (acceptedTermsAndConditions) {4return { continue: true };5}6return { continue: false };7},8});9flowComponent.mount('#flow-container');
Raised when you or the customer submit a FlowComponent
element.
You can use this callback to submit a customized payment, using the Submit a Payment Session Payment endpoint.
The SubmitData
object contains the following information:
session_data
– A unique token representing the additional customer data that Flow captured. You must provide this token when you submit the customized payment session request.
You must provide the unmodified response body returned by the endpoint.