1.0.5 • Published 6 years ago

agropago-sdk-js v1.0.5

Weekly downloads
30
License
ISC
Repository
gitlab
Last release
6 years ago

AgroPago SDK Javascript

Installation

$ npm install agropago-sdk-js

Configuration

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));  
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago