Before starting the integration, it is necessary to keep in mind that, as this is a delicate operation involving sensitive data from an end user, it is necessary that your development and production environment is secure and has an https certificate. We recommend installing and using the ngrok CLI.
To manually initialize the SDK, you need to have a publicKey, this way the transparent checkout SDK will have the necessary configurations for your merchant.Your publicKey is visible within the payin settings view in your dashboard.With your key in hand, you now need to instantiate the SDK as follows:
To automatically initialize the SDK, you need to include the window.autoInitWeSdk instruction before including the script on the page, as in the example:
With this, the SDK will be instantiated in the global variable window.wesdk.
It is also necessary to whitelist, in your dashboard, the domain of the page where the SDK is being included. To do this, access Charges > SDK Management.
With the SDK instantiated, we now have control over the installments method, where we can retrieve data related to the installments that the customer can make the payment. To obtain this data, we must send to the SDK the total amount of the payment that the customer wants to make (in cents) and also the first six digits of the customer’s card number, this number is called BIN.
As informed at the beginning of the integration, the SSL certificate is necessary to operate. As this is a delicate operation involving sensitive data from an end user, it is necessary that your development and production environment is secure and has an https certificate.
With SSL configured, we can start tokenizing the credit card data. For this, it is necessary to call the tokenize method passing its required parameters about the customer’s card data.
With the data finally tokenized, we can now start the process of creating and paying the charge, which will occur simultaneously through a single call to the WEpayments API.
With the credit card token, the number of installments that will be paid and the other data related to the charge, we can start the checkout. Through the endpoint below that is currently used to create charges, a new object called checkout will now be passed in its payload. If this object is filled in, at the time of creating the charge, its payment will also be made.Endpoint: POST /v1/payin/payments/credit-card
After sending the data, the API will then return the response with the payment status at the time of completion of the request, as in the example below.
After this request has been completed, it is possible to check the status of the charge through a GET method at the following endpoint - /v1/payin/payments/credit-card/{key}/status - Passing as key the key of the charge created and returned in the Response above.