npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

latam_payment

v1.2.5

Published

Payment module for latam

Downloads

124

Readme

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: '[email protected]',
  metadata: {
    id: 'user id 1',
    first_name: 'John',
    last_name: 'Doe',
    country: 'COL',
    city: 'BOG'
  },
  description: `Customer for [email protected]`,
  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: '[email protected]',
  metadata: {
    id: 'user id 1',
    first_name: 'John',
    last_name: 'Doe',
    country: 'MEX',
    city: 'MEX'
  },
  description: `Customer for [email protected]`,
  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: '[email protected]',
  metadata: {
    id: 'user id 1',
    first_name: 'John',
    last_name: 'Doe',
    country: 'MEX',
    city: 'MEX'
  },
  description: `Customer for [email protected]`,
  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: '[email protected]',
  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: '[email protected]',
  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: '[email protected]',
  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": {
  }
}