Embedded Integration
The Embed SDK allows you to easily and quickly embed our checkout and subscription solution in any website.
The processing flow of the transaction in this mode, in the case of Checkout, is as follows:
The insertion of the embed starts when creating the Checkout or the Subscription via API. At this point, it is necessary to add within the options node the domain and embed attributes.
The latest version of the SDK is: 1.0.23.
Load our Javascript library on your site:
The payment modal (both for checkout and subscriptions) can be opened using the Mobbex button or through the code itself. In both situations, it is necessary to define some properties and render the corresponding objects.
Inside the HTML body where the modal is going to be inserted, it is necessary to define a div with the id property according to the type of opening to be used.
It is necessary to define a variable that contains all the event handlers for the Modal. Its structure differs depending on whether it is used for Checkout or Subscriptions.
The rendering or initialization process depends on the type of modal opening. It consists of defining a javascript function that will perform the process and is called from the point where the SDK is inserted in the page.
The result of the example operation will be obtained inside the onPayment method of the button.
The following options can be provided to the Mobbex button on rendering or initialization:
type: Embedded Payment Type: Only accepts 2 options: checkout (Checkout) or payment_source (Change Payment Method for Subscribers). id: Server-generated Checkout ID or Subscription ID, depending on the type. sid: Subscriber ID (for Subscriptions only).
onPayment: (data) => { } onError: (error) => { } onOpen: () => { } onClose: (cancelled) => { }
The onClose method will be called when closing the payment modal. The cancelled variable will be true or false depending on whether the modal has been closed before or after the operation, respectively.
The onPayment method will be called when an operation is processed, independently of the onClose method, and will contain within the data variable all the information related to the status of such operation.
button: Javascript object with the following options:
Only Server-side Checkouts should be created and only the ID or UID generated by Mobbex should be shared.
This is an example of using the special options in PHP. The creation of the checkout must always be done server-side, otherwise your account credentials will be exposed. For more examples see the Checkout documentation.
This example shows how to create a subscription so that it can be used with the SDK for embedding. Note that the same properties are used inside the options node as in the checkout case. For more information see the Subscriptions documentation.