1.0.5 • Published 6 years ago
agropago-sdk-js v1.0.5
AgroPago SDK Javascript
Installation
$ npm install agropago-sdk-jsConfiguration
The constructor new Agropago({}) requires 2 params:
- apiKey: (string) Your public API key
- environment: (string) It can be one of two options dev|prod. Default is 'dev'.
Example for web pages
Include the script public/agropago.js into your index.html file
<script src="public/agropago.js"></script>
const agropago = new Agropago({
apiKey: 'yourapikey',
environment: 'dev'
});
const bodyJSON = {
"card_number" : "...",
"card_expiration_month" : "...",
"card_expiration_year" : "...",
"security_code" : "...",
"card_holder_name" : "...",
"card_holder_identification" : {
"type" : "...",
"number" : "..."
}
};
agropago.createToken(bodyJSON)
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data);
})
.catch(error => console.error('Error:', error));Example web applications
Example for React application
import Agropago from 'agropago-sdk-js';
const agropago = new Agropago({
apiKey: 'yourapikey',
environment: 'dev'
});
// Format json to send
const bodyJSON = {
"card_number" : "...",
"card_expiration_month" : "...",
"card_expiration_year" : "...",
"security_code" : "...",
"card_holder_name" : "",
"card_holder_identification" : {
"type" : "...",
"number" : "..."
}
};
agropago.createToken(bodyJSON)
.then(function(response) {
return response.json();
})
.then(function(data) {
console.log(data)
})
.catch(error => console.error('Error:', error));