Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ EBANX.config.setPublishableKey('put your key here'); // Set your Publishable key
EBANX.config.setCountry('br'); // Set your checkout country (see: https://en.wikipedia.org/wiki/ISO_3166-1).
```

This is all. Use:
### 3. Create a credit card request

Lets start by collecting credit card details and preparing a request token, please notice that other payment methods are also supported, see [payment methods]().

#### card.createToken

Creates a single use token used to pass credit-card information to your server in a safe way.
Creates a single use token used to pass credit card information to your server in a safe way.

```javascript
var createTokenCallback = function(ebanxResponse) {
Expand All @@ -42,6 +44,41 @@ EBANX.card.createToken({
}, createTokenCallback);
```

-------- Prepare request alternative

#### card.createRequest

Creates a single use token used to pass credit card information to your server in a safe way.

```javascript
var createTokenCallback = function(ebanxResponse) {
if (ebanxResponse.error) {
document.getElementById('status').textContent = 'Error ' + ebanxResponse.error.message;
} else {
document.getElementById('status').textContent = 'Success, the token is: ' + ebanxResponse.token;
}
}

EBANX.card.prepareRequest({
customer_name: document.getElementById('customer_name').value,
customer_email: document.getElementById('customer_email').value,
customer_document: document.getElementById('customer_document').value,
customer_birth_date: document.getElementById('customer_birth_date').value,
customer_zipcode: document.getElementById('customer_zipcode').value,
customer_address: document.getElementById('customer_address').value,
customer_street_number: document.getElementById('customer_street_number').value,
customer_city: document.getElementById('customer_city').value,
customer_state: document.getElementById('customer_state').value,
country: document.getElementById('customer_country').value,
currency_code: "BRL",
ammount_total: "100.00",
card_number: document.getElementById('card-number').value,
card_name: document.getElementById('card-name').value,
card_due_date: document.getElementById('card-due-date').value,
card_cvv: document.getElementById('card-cvv').value
}, createTokenCallback);
```

## Notes

- [x] EBANX Checkout JS Only works on HTTPS;