Giter Club home page Giter Club logo

payline's Introduction

Payline

NodeJS SDK for payline.com API

This provides a very succinct SDK for the payline.com API. If you need additional Payline methods covered, feel free to contribute :-) Highly inspired from Django-Payline, thanks!

As promised (Bluebird based).

Usage

Where to find those f**** config strings? Well I've been there:

  • userId is sent by email when you subscribe to Payline. joyfully named Vendor identifier or Merchant's Login elsewhere in their admin
  • userPass is called access key and available in Settings > Change your access key
  • contractNumber is related to a point of sale and a method of payment. So once you created a point of sale, head to method of payment and you will get a contract number after that. In the test mode, '1234567' seems to be accepted by default
npm install payline
var Payline = require('payline');
var payline = new Payline('<% userId %>', '<% userPass %>', '<% contractNumber %>');

Example

payline.createWallet('wallet_0001', {
        number: '4970101122334471',
        type: 'CB',
        expirationDate: '0117',
        cvx: '123'
    })
    .then(function() {
        // issue a 10€ order
        return payline.makeWalletPayment('wallet_0001', 1000, Payline.CURRENCIES.EUR);
    })
    .then(function(result) {
        console.log("Youpi! Transaction id: " + result.transactionId);
    }, function(err) {
        console.log("Wtf happened: " + err.shortMessage + ' - ' + err.longMessage);
    });

Example using doWebPayment

payline.doWebPayment(123, 'A-PAY-TEST', '20/06/2015 20:21', 'http://www.wexample.com', 'http://v2.wexample.com')
  .then(function (result) {
    console.log("Youpla! Redirect to: " + result.redirectURL);
  }, function (err) {
    console.log("Wtf happened: " + err.shortMessage + ' - ' + err.longMessage);
  });

API

new Payline(userId, userPass, contractNumber) -> instance

See Usage to find those variables

You can override the wsdl bundled in this module by setting a 4th arg : new Payline(userId, userPass, contractNumber, 'my file path or url')

instance.createWallet(walletId, card) -> Promise({ walletId })
instance.updateWallet(walletId, card) -> Promise({ walletId })

Card object: { number, type, expirationDate, cvx }

Type: One of CB, AMEX, VISA (but abroad France only), MASTERCARD (same) - cf page 148 of their doc

instance.getWallet(walletId) -> Promise(wallet)
instance.makeWalletPayment(walletId, amount, currency = 978) -> Promise({ transactionId })

Note that amounts are in cents

instance.validateCard(card, tryAmount = 100, currency = 978) -> Promise(bool)

Will try to issue a 1€ order (that will be cancelled right after the call is verified)

Contributions

npm run watch

# this module is written in ES6 - so it has to be transpiled
# before being published to NPM. check the package.json prepublish script

payline's People

Contributors

getvega avatar ifig29 avatar weeger avatar

Watchers

 avatar

Forkers

lvelours

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.