All Projects → paynow → Paynow-NodeJS-SDK

paynow / Paynow-NodeJS-SDK

Licence: other
NodeJS SDK for Zimbabwe's leading payments gateway, Paynow

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Paynow-NodeJS-SDK

paymentgateway
Dokumentace ČSOB platební brány a jejího eAPI pro platby platebními kartami, Apple Pay, mallpay a platebními tlačítky ČSOB.
Stars: ✭ 104 (+352.17%)
Mutual labels:  payment, online-payments, payment-gateway, payment-integration
adyen-python-api-library
Adyen API Library for Python
Stars: ✭ 41 (+78.26%)
Mutual labels:  payment, payment-gateway, payment-integration
omnipay-2checkout
2Checkout driver for the Omnipay PHP payment processing library
Stars: ✭ 25 (+8.7%)
Mutual labels:  payment, payment-gateway, payment-integration
react-native-payumoney
React Native Payumoney (Android/IOS)
Stars: ✭ 18 (-21.74%)
Mutual labels:  payment, payment-gateway, payment-integration
python-daraja
Python Wrapper for interacting with the MPESA Daraja API. More Features to be implemented
Stars: ✭ 20 (-13.04%)
Mutual labels:  payment, payment-gateway, payment-integration
cybersource-sdk-java
Java SDK for CyberSource Simple Order API
Stars: ✭ 44 (+91.3%)
Mutual labels:  payment, payment-gateway, payment-integration
wc-moldovaagroindbank
WooCommerce maib Moldova Agroindbank Payment Gateway
Stars: ✭ 13 (-43.48%)
Mutual labels:  payment, payment-gateway, payment-integration
ccashcow
💰 Accept cards & crypto. Payments so easy a cow could do it.
Stars: ✭ 40 (+73.91%)
Mutual labels:  payment, payment-gateway, payment-integration
nagadApi
This is Bangladeshi nagad payment gateway api development library. This library can be used in any php application.
Stars: ✭ 20 (-13.04%)
Mutual labels:  payment, payment-gateway, payment-integration
adyen-dotnet-api-library
Adyen API Library for .NET
Stars: ✭ 69 (+200%)
Mutual labels:  payment, payment-gateway, payment-integration
adyen-node-api-library
Adyen API Library for Node.js
Stars: ✭ 82 (+256.52%)
Mutual labels:  payment, payment-gateway, payment-integration
adyen-hybris
Adyen Payment plugin for Hybris
Stars: ✭ 23 (+0%)
Mutual labels:  payment, payment-gateway, payment-integration
adyen-salesforce-commerce-cloud
Salesforce Commerce Cloud (formerly Demandware)
Stars: ✭ 63 (+173.91%)
Mutual labels:  payment, payment-gateway, payment-integration
awesome-payment
A curated list of payment services
Stars: ✭ 22 (-4.35%)
Mutual labels:  payment, payment-gateway, payment-integration
cybersource-android-sdk
The CyberSource InApp SDK enables developers to simply and securely incorporate mobile payments into their Android applications.
Stars: ✭ 25 (+8.7%)
Mutual labels:  payment, payment-gateway, payment-integration
Go Payment
Payment Connector for Midtrans and Xendit. Sample site that is using this payment proxy is https://imrenagi.com/donate
Stars: ✭ 136 (+491.3%)
Mutual labels:  payment, payment-gateway
Omnipay Pingpp
A Ping++ driver for the Omnipay PHP payment processing library. 一个聚合了支付宝(APP、Wap、PC、即时到账、扫码、企业付款),微信(APP、公众号、红包), 银联网关、银联企业网银、Apple Pay、QQ 钱包、易宝支付、百度钱包、京东支付、京东白条、招行一网通、分期支付等国内主流支付渠道的聚合支付网关(Ping++, also known as Pingpp/Pingxx/Pingplusplus)
Stars: ✭ 227 (+886.96%)
Mutual labels:  payment, payment-gateway
Laravel Paddle
Paddle.com API integration for Laravel with support for webhooks/events
Stars: ✭ 132 (+473.91%)
Mutual labels:  payment, payment-gateway
42-cent
Node.js multi-gateway payment processing module
Stars: ✭ 43 (+86.96%)
Mutual labels:  payment, payment-gateway
midtrans-nodejs-client
Official Midtrans Payment API Client for Node JS | https://midtrans.com
Stars: ✭ 124 (+439.13%)
Mutual labels:  payment, payment-gateway

Build Status

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
  2. NPM (node's package manager, used to install the node library)

Installation

Install the library using NPM or yarn

$ npm install --save paynow
$ yarn add paynow

Usage example

Importing library

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) */

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:

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.

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 and OneMoney are supported

paynow.sendMobile(payment, '0777000000', 'ecocash').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.sendMobile(
    
    // The payment to send to Paynow
    payment, 

    // The phone number making payment
    '0777000000',
    
    // The mobile money method to use.
    'ecocash' 

).then(function(response) {
    if(response.success) {
        // These are the instructions to show the user. 
        // Instruction for how the user can make payment
        let instructions = response.instructions // Get Payment instructions for the selected mobile money method

        // Get poll url for the transaction. This is the url used to check the status of the transaction. 
        // You might want to save this, we recommend you do it
        let pollUrl = response.pollUrl; 

        console.log(instructions)

    } else {
        console.log(response.error)
    }
}).catch(ex => {
    // Ahhhhhhhhhhhhhhh
    // *freak out*
    console.log('Your application has broken an axle', ex)
});

Checking transaction status

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?");
}

Full Usage Example

// 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;
    }

});

Development

Fork this repository and clone to local machine

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].