Integration
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.Importing the SDK
The first step to import the SDK is to check your integration environment:Development (Sandbox)
For development use the sandbox SDK through the URL below.
Production
For the production environment use the production SDK through the URL below.
Initializing the SDK
The SDK can be initialized in 2 ways: manually or automatically.Initialize manually
To manually initialize the SDK, you need to have apublicKey, 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:
Initialize automatically
To automatically initialize the SDK, you need to include thewindow.autoInitWeSdk instruction before including the script on the page, as in the example:
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.
Retrieve installments
With the SDK instantiated, we now have control over theinstallments 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.
Payload
Parameters
| Parameter | Type | Description |
|---|---|---|
| amountInCents | number | string | Total amount in cents of the charge (Required) |
| bin | string | First six digits of the credit card (Required) |
Response
Theinstallments method used is a Promise that returns the following object, according to your configured number of installments:
Generate card token
With SSL configured, we can start tokenizing the credit card data. For this, it is necessary to call thetokenize method passing its required parameters about the customer’s card data.
Payload
Parameters
| Param | Type | Description |
|---|---|---|
| cardNumber | string | Credit card number (16-19) - Required |
| cardholderName | string | Cardholder name - Required |
| cardExpirationMonth | string | Expiration month (MM) - Required |
| cardExpirationYear | string | Expiration year (YY - YYYY) - Required |
| securityCode | string | Security code number (3-4) - Required |
| identificationType | string | Document type (CPF - CNPJ) - Required |
| identificationNumber | string | Document number - Required |
Response
Thetokenize method used is a Promise that returns the following object:
Checkout
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 calledcheckout 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
Payload
Response
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.Related Resources
Create Charge
Create a new credit card charge
Callback Charge
Receive charge callbacks
About Credit Card
Learn about credit card charges
FAQ
Frequently asked questions

