0.1.7 • Published 4 years ago

ecommpay v0.1.7

Weekly downloads
217
License
MIT
Repository
github
Last release
4 years ago

EcommPay Javascript package

Build Status Test Coverage Maintainability

What is it?

It is package that will help you with generating payment URL according to EcommPay documentation.

How to use?

Get payment page URL

  1. Install the package (with your package manager):
npm install ecommpay
yarn add ecommpay
  1. Require somewhere in your code, set parameters and get the URL:
const { Payment } = require('ecommpay');

// create ECP object with your account ID and secret salt
const e = new Payment('112', 'my_secret');

// set payment details 
e.paymentAmount = 1000;
e.paymentId = 'FFCD12-30';
e.paymentCurrency = 'USD';

// set another parameters, like success or fail callback URL, customer details, etc.

// get payment URL
const url = e.getUrl();

Now your can render payment url somewhere on your checkout page.

Receive callback from Ecommpay

Example with Express:

const { Callback } = require('ecommpay');

app.post('/payment/callback', function(req, res) {
  const callback = new Callback('secret', req.body);
  if (callback.isPaymentSuccess()) {
    const paymentId = callback.getPaymentId();
    // here is your code for success payment
  }
});

Note that Callback constructor throws Error if signature isn't valid.

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5-1

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

6 years ago