1.2.5 • Published 7 years ago

latam_payment v1.2.5

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

latam_payment

Library to handle payment providers. At the moment, the library handles PayU and Stripe.

Require

var latam_payment = require('latam_payment');

Register Card Token

PayU register example

var type = 'payu';
var data = {
  email: 'some_email@test.com',
  metadata: {
    id: 'user id 1',
    first_name: 'John',
    last_name: 'Doe',
    country: 'COL',
    city: 'BOG'
  },
  description: `Customer for some_email@test.com`,
  card: '<payu token>',
  user_token: null,
  security: {
    url: 'https://sandbox.api.payulatam.com/payments-api/4.0/service.token',
    api_login: 'pRRXKOl8ikMmt9u',
    api_key: '4Vj8eK4rloUd272L48hsrarnUA'
  }
};
latam_payment.register(type, data, function(err, card){
    // do something with card
});

Stripe register example

var type = 'stripe';
var data = {
  email: 'some_email@test.com',
  metadata: {
    id: 'user id 1',
    first_name: 'John',
    last_name: 'Doe',
    country: 'MEX',
    city: 'MEX'
  },
  description: `Customer for some_email@test.com`,
  card: '<stripe token>',
  user_token: '<customer stripe token (if exists)>',
  security: {
    api_key: '<stripe api key>',
  }
};
latam_payment.register(type, data, function(err, card){
    // do something with card
});

Amex register example

var type = 'amex';
var data = {
  email: 'some_email@test.com',
  metadata: {
    id: 'user id 1',
    first_name: 'John',
    last_name: 'Doe',
    country: 'MEX',
    city: 'MEX'
  },
  description: `Customer for some_email@test.com`,
  card: '<amex token>',
  security: {
	merchantId: '<amex_merchant_id>',
	password: '<amex_merchant_api_password>',
  }
};
latam_payment.register(type, data, function(err, card){
    // do something with card
});

Register response

{
    "token": "<card token>",
    "last4": "1234",
    "cardType": "VISA",
    "maskedNumber": "****1234",
    "uniqueNumberIdentifier": "jkaslgjdakl328975",
    "customer": "<stripe user token> | null",
    "country": "MEX|COL|ARG",
    "type": "payu|stripe|amex",
    "csv": "123|null"
}

Checkout

PayU checkout example

var type = 'payu';
var data = {
  email: 'test@email.com',
  payment: {
    internal_reference: 'ABC12398',
    amount: 500,
    source: {
      user: null,
      card: 'f064b5d0-2fbb-43df-b54f-ab92a3796a5c'
    },
    cvc: '123', //optional for Colombia
    card_type: 'VISA',
    mode: 'AUTHORIZATION' //Colombia only accepts 'AUTHORIZATION_AND_CAPTURE'; if not present, defaults to 'AUTHORIZATION_AND_CAPTURE'
  },
  metadata: {
    id: '123456789',// user id
    first_name: 'John',
    last_name: 'Doe',
    phone: '123456789',
    country: 'ARG',
    city: 'BNA'
  },
  address: {
    line1: 'Avenida entre rios 256',
    country: 'ARG',
    city: 'BNA'
  },
  security: {
    url: 'https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi',
    account_id: '512322',
    merchant_id: '508029',
    api_key: '4Vj8eK4rloUd272L48hsrarnUA',
    api_login: 'pRRXKOl8ikMmt9u',
    ip: '127.0.0.1',
    device_session_id: 'vghs6tvkcle931686k1900o6e1',
    user_agent: 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0'
  }
};
latam_payment.checkout(type, data, function(err, transaction){
    // do something with transaction
});

Stripe checkout example

var type = 'stripe';
var data = {
  email: 'test@email.com',
  payment: {
    internal_reference: 'ABC12398',
    amount: 500,
    source: {
      user: 'cus_jkds78392ufdsa78',
      card: 'card_jdk789236fdjk39'
    },
    mode: 'capture' // if equal to 'capture', sets capture=true; else, sets capture=false
  },
  metadata: {
    id: '123456789',// user id
    first_name: 'John',
    last_name: 'Doe',
    phone: '123456789',
    country: 'ARG',
    city: 'BNA'
  },
  address: {
    line1: 'Avenida entre rios 256',
    country: 'ARG',
    city: 'BNA'
  },
  security: {
    api_key: '<stripe api key>',
  }
};
latam_payment.checkout(type, data, function(err, transaction){
    // do something with transaction
});

Amex checkout example

var type = 'amex';
var data = {
  email: 'test@email.com',
  payment: {
    internal_reference: 'ABC12398',
    amount: 500,
    currency: 'MXN',
    source: {
      card: ''
    },
    mode: 'capture' // if equal to 'capture', sets capture=true; else, sets capture=false
  },
  metadata: {
    id: '123456789',// user id
    first_name: 'John',
    last_name: 'Doe',
    phone: '123456789',
    country: 'MEX',
    city: 'MEX'
  },
  address: {
    line1: 'Avenida entre rios 256',
    country: 'MEX',
    city: 'MEX'
  },
  security: {
	merchantId: '<amex_merchant_id>',
	password: '<amex_merchant_api_password>',
  }
};
latam_payment.checkout(type, data, function(err, transaction){
    // do something with transaction
});

Checkout response

NOTE: orderId is null for Stripe transactions.

{
  "success": true,
  "error": null,
  "body": {
    "orderId": "<order_id>",
    "transaction": "<transaction id>",
    "status": "paid|authorized",
    "amount": 500,
    "currency": "MXN"
  }
}

Void

PayU void example

var type = "payu";
var data = {
  metadata: {
    id: '123456789', // user id
    first_name: 'John',
    last_name: 'Doe',
    phone: '123456789',
    country: 'COL',
    city: 'BOG'
  },
  transaction: {
    transaction_id: '96535b36-99db-4c66-bd87-6ad5c59b25a8',
    order_id: '40049920'
  },
  security: {
    url: 'https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi',
    api_key: '4Vj8eK4rloUd272L48hsrarnUA',
    api_login: 'pRRXKOl8ikMmt9u',
  }
};

latam_payment.void(type, data, function(err, transaction) {
  // do something with transaction
});

Amex void example

var type = "amex";
var data = {
  transaction: {
    transaction_id: '96535b36-99db-4c66-bd87-6ad5c59b25a8',
    order_id: '40049920'
  },
  security: {
	merchantId: '<amex_merchant_id>',
	password: '<amex_merchant_api_password>',
  }
};

latam_payment.void(type, data, function(err, transaction) {
  // do something with transaction
});

Void response

{
  "success": true,
  "error": null,
  "body": {
  }
}
1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.89

8 years ago

1.0.88

8 years ago

1.0.87

8 years ago

1.0.86

8 years ago

1.0.85

8 years ago

1.0.84

8 years ago

1.0.83

8 years ago

1.0.82

8 years ago

1.0.81

8 years ago

1.0.80

8 years ago

1.0.79

8 years ago

1.0.78

8 years ago

1.0.77

8 years ago

1.0.76

8 years ago

1.0.75

8 years ago

1.0.74

8 years ago

1.0.73

8 years ago

1.0.72

8 years ago

1.0.71

8 years ago

1.0.70

8 years ago

1.0.69

8 years ago

1.0.68

8 years ago

1.0.66

8 years ago

1.0.65

8 years ago

1.0.64

8 years ago

1.0.63

8 years ago

1.0.62

8 years ago

1.0.61

8 years ago

1.0.60

8 years ago

1.0.59

8 years ago

1.0.58

8 years ago

1.0.57

8 years ago

1.0.56

8 years ago

1.0.55

8 years ago

1.0.54

8 years ago

1.0.53

8 years ago

1.0.52

8 years ago

1.0.51

8 years ago

1.0.50

8 years ago

1.0.49

8 years ago

1.0.48

8 years ago

1.0.47

8 years ago

1.0.46

8 years ago

1.0.45

8 years ago

1.0.44

8 years ago

1.0.43

8 years ago

1.0.42

8 years ago

1.0.41

8 years ago

1.0.40

8 years ago

1.0.39

8 years ago

1.0.38

8 years ago

1.0.37

8 years ago

1.0.36

8 years ago

1.0.35

8 years ago

1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

8 years ago

1.0.30

8 years ago

1.0.29

8 years ago

1.0.28

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago