Installation
npm install openpay
Documentation
Full API documentation available at http://docs.openpay.mx/.
Overview
//classvar Openpay = ;//instantiationvar openpay = ' your merchant id ' ' your private key ' isProduction ;//use the apiopenpay< 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":"johndoe@example.com" "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"; openpaycustomers;
Charging
var newCharge = "method": "card" "card": "card_number": "4111111111111111" "holder_name": "John Doe" "expiration_year": "20" "expiration_month": "12" "cvv2": "110" "amount" : 20000 "description" : "Service Charge" "order_id" : "oid-00721";openpaycharges;
Payout
var payout = "method": "bank_account" "bank_account": "clabe":"012298026516924616" "holder_name": "John Doe" "amount" : 1050 "description" : "Monthly payment";openpaypayouts;
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