payload built and nonce and established an instance of FlexPaymentForms and put the form on your DOM.
You need a
nonce Current API Nonce and payload of Construction of payload before we continue.Building parameters
Expand every block to check the fields you can send to the builder.Mandatory information
Mandatory information
Settings
Settings
Control the general visual performance of the component.
Object display_sittings
Object display_sittings
Define the means of payment that Flex will show the buyer.
You have to send
display_settings.methods with the payment methods you need to visualise at Flex.Subject matter
Subject matter
Configure available languages within form.
Initiate and mount Flex
1
It creates an instance
Send the
nonce, payload and the configuration that your integration needs.2
Create the container
Add to HTML the element where Flex will generate their DOM.
3
Surrender form
Fits the instance and delivers the functions that will process the response, monitoring and errors.
If you define
i18n.default_languageand uses one of the languages listed in i18n.languages.#flex-container That’s just an example. Can use another selector as long as the item exists before running paymentForm.init(...).Responsive conduct
Flex retains its internal structure while the outer container calculates an appropriate scale for viewing.Web
Keep the original scale as soon as the form fits into the window.
Cell
Reduces the form proportionally to avoid horizontal cuts.
Dynamic constore
Refigure height when Flex change of passage or payment method.
Example of implementation
That visual example uses a popular presentation. The initialization, callbacks and dismantling described above also apply to drunk and expanded presentations.
- Structure HTML
- Base Styles
- Responsible logic
- Unmount Flex
Life cycle of the instance
paymentForm.terminate?.() complete the internal processes, list and resources that maintain the Flex. That operation is different from eliminating the form from DOM (flexContainer.innerHTML = "") and applying to any type of presentation.
The operator
?. run terminate() only when the method exists. That prevents an error if the loaded version of Flex Do not implement that method.When to dismount according to presentation
In all 3 cases, first process any outstanding result and then run
unmountFlex() before updating the visual presentation.
own result screen
When you set upsettings.display_result_screen: false, Flex doesn’t have his final screen. Your application should get the response, evaluate the status of the transaction and display an own result screen.
1
Mount form
paymentForm.init(...) challenges Flex inside the container.2
Receives result
Flex run
responseCallback(response). Read the result from response.transaction.state and conduct related business validations.3
Show your screen
Save the
response at the status of your application and navigate or render the result screen from the merchant.4
Unmount Flex
When the result has been processed, run
terminate(), cleanes the container and updates the presentation drunk, popup or expanded.Reusable cleaning
It encapsulates initiation and dismantling into an independent framework controller. You can use them from pure JavaScript or connect them to React’s life cycle, Vue, Angular or other technologies.JavaScript
Execut
destroy() before withdrawing the container from the page.Implementation SPA
Connect
destroy() to change of path or to dismount vision.Dynamic presentation
Do so by hiding the embossed block, closing the Popup or getting an expanded view.
container.replaceChildren() an empty constore equivalent to container.innerHTML = ""without dependent on a specific framework.
terminate() does not return the payment response. The result always comes with the first call of paymentForm.init(...). Check. Capture callback functions to interpret and confirm the operation.Management of closure with show_close_button
Figuresettings.show_close_button: true to display the native clasp of Flex. That option works with embumbing, pounding and expanding presentations.
cerro el carrito with onErrorCallback. Although using the error call, this message represents a voluntary action by the buyer and not a technical failure.
Show the button
Active
show_close_button inside settings.Play the event
Identifies the exact message
cerro el carrito in onErrorCallback.Close presentation
Execut
onClose() for dismantling Flex and update the interface.show_close_button → onErrorCallback → onClose() → unmountFlex(). hideFlexPresentation() represents the visual logic of your application: remove the embedded block, hide the popup or get an expanded view.
Before posting
Check the component in these scenarios:Next step
Capture callback functions
Define
responseCallback, trackingCallback and onErrorCallback to react correctly to the flow.Construction of payload
If you haven’t put up an operation’s item, come back to the guide to
payload.
