Giter Club home page Giter Club logo

openpay-node's Introduction

Openpay nodejs

Installation

npm install openpay

Documentation

Full API documentation available at http://docs.openpay.mx/.

Overview

//class
var Openpay = require('openpay');
//instantiation
var openpay = new Openpay(' your merchant id ', ' your private key ', [ isProduction ]);
//use the api
openpay.< resource_name >.< method_name >( ... )

All methods accept an optional callback as last argument.

The callback function should follow the format: function(error, body) {...}.

  • error: null if the response status code is 200, 201, 204
  • body: null if the response status code is different from 200, 201, 204

Examples

Creating a customer

var newCustomer = {
  "name":"John",
  "email":"[email protected]",
  "last_name":"Doe",
  "address":{
    "city":"Queretaro",
    "state":"Queretaro",
    "line1":"Calle Morelos no 10",
    "line2":"col. san pablo",
    "postal_code":"76000",
    "country_code":"MX"
  },
  "phone_number":"44209087654"
};

openpay.customers.create(newCustomer, function(error, body) {
    error;    // null if no error occurred (status code != 200||201||204)
    body;     // contains the object returned if no error occurred (status code == 200||201||204)
});

Charging

var newCharge = {
  "method": "card",
  "card": {
    "card_number": "4111111111111111",
    "holder_name": "John Doe",
    "expiration_year": "20",
    "expiration_month": "12",
    "cvv2": "110",
  },
  "amount" : 200.00,
  "description" : "Service Charge",
  "order_id" : "oid-00721"
};
openpay.charges.create(testCreateCharge, function (error, body){
  // ...
});

Payout

var payout = {
  "method": "bank_account",
  "bank_account":{
    "clabe":"012298026516924616",
    "holder_name": "John Doe"
  },
  "amount" : 10.50,
  "description" : "Monthly payment"
};
openpay.payouts.create(payout, function (error, body){
  // ...
});

Configuration

  • openpay.setTimeout(20000); // in ms (default is 90000ms)
  • openpay.setMerchantId(' your merchant id ');
  • openpay.setPrivateKey(' your private key ');
  • openpay.setProductionReady(true);

Development

To run the tests you'll need your sandbox credentials: merchant id and private key from your Dashboard:

$ npm install -g mocha
$ npm test

openpay-node's People

Contributors

romanvi avatar darkaz avatar mecoronado avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.