0.1.7 • Published 1 year ago

festpay v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

festpay Javascript package

Build Status

What is it?

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

How to use?

Get payment page URL

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

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

// set payment details 
e.paymentAmount = 1000;
e.paymentId = 'F1212-30';
e.paymentCurrency = 'RUB';

// 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 festpay

Example with Express:

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

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.