Logo Lanfrica

paynow/Paynow-NodeJS-SDK

Domaine:

digital infrastructure

Type de record:

software
Créateur:
pay
Hôte:
NodeJS SDK for Zimbabwe's leading payments gateway, Paynow # Node.JS SDK for Paynow Zimbabwe's API ## Sign in to Paynow and get integration details > Before you can start making requests to Paynow's API, you need to get an integration ID and integration Key from Paynow. See Documentation Generating Integration Key and Viewing integration ID ## Documentation See the Paynow QuickStart. ## Prerequisites This library has a set of prerequisites that must be met for it to work 1. Node version 0.6.0 and above 1. NPM (node's package manager, used to install the node library) ## Installation Install the library using NPM or yarn ```sh $ npm install --save paynow ``` ```sh $ yarn add paynow ``` ## Usage example ### Importing library ```javascript const { Paynow } = require("paynow"); ``` Create an instance of the Paynow class optionally setting the result and return url(s) ```javascript let paynow = new Paynow("INTEGRATION_ID", "INTEGRATION_KEY"); paynow.resultUrl = "example.com"; paynow.returnUrl = "example.com"; /* The return url can be set at later stages. You might want to do this if you want to pass data to the return url (like the reference of the transaction) */ ``` The Integration ID and Key can be optionally loaded from `PAYNOW_INTEGRATION_ID` and `PAYNOW_INTEGRATION_KEY` environment variables (respectively). An instance of the Paynow class can then be created using the following: ```javascript let paynow = new Paynow(); ``` Create a new payment passing in the reference for that payment (e.g invoice id, or anything that you can use to identify the transaction. ```javascript let payment = paynow.createPayment("Invoice 35"); ``` You can then start adding items to the payment ```javascript // Passing in the name of the item and the price of the item payment.add("Bananas", 2.5); payment.add("Apples", 3.4); ``` Once you're done building up your cart and you're finally ready to send your payment to Paynow, you can use the `send` method in the `payn …