
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
Before you can start making requests to Paynow's API, you need to get an integration ID and integration Key from Paynow. Details about how you can retrieve the ID and key are explained in detail on this page
This library has a set of prerequisites that must be met for it to work
Install the library using NPM or yarn
$ npm install --save paynow
Or
$ yarn add paynow
const Paynow = require("paynow");
Create an instance of the Paynow class optionally setting the result and return url(s)
let paynow = new Paynow("INTEGRATION_ID", "INTEGRATION_KEY");
paynow.resultUrl = "http://example.com/gateways/paynow/update";
paynow.returnUrl = "http://example.com/return?gateway=paynow";
// 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)
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.
let payment = paynow.createPayment("Invoice 35");
You can then start adding items to the payment
// 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 paynow object.
// Save the response from paynow in a variable
paynow.send(payment);
The send method will return a Promise<InitResponse>, the InitResponse object being the response from Paynow and it will contain some useful information like whether the request was successful or not. If it was, for example, it contains the url to redirect the user so they can make the payment. You can view the full list of data contained in the response in our wiki
If request was successful, you should consider saving the poll url sent from Paynow in your database
paynow.send(payment).then(response => {
// Check if request was successful
if (response.success) {
// Get the link to redirect the user to, then use it as you see fit
let link = response.redirectUrl;
}
});
Mobile Transactions
If you want to send an express (mobile) checkout request instead, the only thing that differs is the last step. You make a call to the sendMobile in the paynow object
instead of the send method.
The sendMobile method unlike the send method takes in two additional arguments i.e The phone number to send the payment request to and the mobile money method to use for the request. Note that currently only ecocash is supported
paynow.send(payment).then(response => {
// Handle response
});
The response object is almost identical to the one you get if you send a normal request. With a few differences, firstly, you don't get a url to redirect to. Instead you instructions (which ideally should be shown to the user instructing them how to make payment on their mobile phone)
paynow.send(payment).then(response => {
// Check if request was successful
if (response.success) {
// Get the poll url (used to check the status of a transaction). You might want to save this in your DB
let pollUrl = response.pollUrl;
// Get the instructions
let instructions = response.instructions;
} else {
// Ahhhhhhhhhhhhhhh
// *freak out*
}
});
The SDK exposes a handy method that you can use to check the status of a transaction. Once you have instantiated the Paynow class.
// Check the status of the transaction with the specified pollUrl
// Now you see why you need to save that url ;-)
let status = paynow.pollTransaction(pollUrl);
if (status.paid()) {
// Yay! Transaction was paid for
} else {
console.log("Why you no pay?");
}
// Require in the Paynow class
const Paynow = require("paynow");
// Create instance of Paynow class
let paynow = new Paynow("INTEGRATION_ID", "INTEGRATION_KEY");
// Set return and result urls
paynow.resultUrl = "http://example.com/gateways/paynow/update";
paynow.returnUrl = "http://example.com/return?gateway=paynow";
// Create a new payment
let payment = paynow.createPayment("Invoice 35");
// Add items to the payment list passing in the name of the item and it's price
payment.add("Bananas", 2.5);
payment.add("Apples", 3.4);
// Send off the payment to Paynow
paynow.send(payment).then( (response) => {
// Check if request was successful
if(response.success) {
// Get the link to redirect the user to, then use it as you see fit
let link = response->redirectUrl;
// Save poll url, maybe (recommended)?
let pollUrl = response.pollUrl;
}
});
FAQs
Paynow SDK Demo
The npm package paynowdemo receives a total of 2 weekly downloads. As such, paynowdemo popularity was classified as not popular.
We found that paynowdemo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.