Skip to content

ingameltd/pay-now

Repository files navigation

PayNow for NodeJS

Build License Package Version Last Commit

NodeJS library for PayNow payment service. This library is written in Typescript to provide best typesafety.

Official REST API docs can be found here.

Documentation

Documentation can be in read here.

Installation

npm install --save @ingameltd/pay-now

Typescript

Importing

import {
  PayNow,
  Payment,
  PaymentCreatedResponse
} from "@ingameltd/pay-now";

Initialization

  • apiKey - API Key from PayNow panel
  • signatureKey - Signature Key from PayNow panel
const payNow = new PayNow(
  apiKey, 
  signatureKey, 
  { 
    sandbox: false // enable or disable sandbox
  }
);

Create payment

const payment: Payment = {
    amount: 1000, // 10,00 PLN
    externalId: '9fea23c7-cd5c-4884-9842-6f8592be65df', // unique id from merchant system
    description: "Test transaction",
    buyer: {
        email: "[email protected]"
    }
}

const result: PaymentCreatedResponse = await payNow.createPayment(payment)

console.log(result)

Get payment status

// payment id from paynow
const result: PaymentStatusResponse = payNow.paymentStatus(paymentId)
console.log(result)

Check integrity of incoming message

To verify a notification you must check integrity of an incoming message and compare it with Signature header field(you can set Notification endpoint in panel)

Example with Express

const calculatedSignature = paynow.calculateSignature(req.body)
console.log(calculatedSignature === req.header('Signature'))