Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chuva.io/sisp

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chuva.io/sisp

This module simplifies getting started with processing Vinti4, Visa, and Mastercard payments using SISP on Node.js.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by250%
Maintainers
5
Weekly downloads
 
Created
Source

SISP PAYMENTS JS

Introduction

This module simplifies getting started with processing Vinti4, Visa, and Mastercard payments using SISP on Node.js.

Note: You can request SISP credentials, view their documentation, and more here.

// Credentials that should be provided by SISP
const posID = "";
const posAutCode = "";
const url = "";

These credentials are used to allow you to process the payment using SISP payment services.

Getting Started

Quick Overview

You can install this package using npm or yarn by running one of the following commands:

$ npm install @chuva.io/sisp
# OR
$ yarn add @chuva.io/sisp

Module Configuration

Import sisp-payments and create a new instance using your credentials. (obtained from SISP):

const Sisp = require('sisp-payments');

const posID = 900512;
const posAutCode = "123456789ssA";
const url = "https://mc.vinti4net.cv/payments";

const sisp = new Sisp({ posID, posAutCode, url });

Generate Payment Request Form

sisp.generatePaymentRequestForm(referenceId, total, webhookUrl);

Generates and returns an HTML form that can be used to process payments.

  • referenceId: Client-generated payment reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the payment request and response.
  • total: Payment amount (in CVE).
  • webhookUrl: The url where SISP should send the payment response. You should expect a POST request with payment information in the body. See the SISP documentation for more information.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/sisp-payment';

const htmlForm = sisp.generatePaymentRequestForm(referenceId, total, webhookUrl);

Generate Service Payment Request Form

sisp.generateServicePaymentRequestForm(referenceId, total, webhookUrl, entityCode, referenceNumber);

Generates and returns an HTML form that can be used to process service payments.

  • referenceId: Client-generated payment reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the payment request and response.
  • total: Payment amount (in CVE).
  • webhookUrl: The url where SISP should send the payment response. You should expect a POST request with payment information in the body. See the SISP documentation for more information.
  • entityCode: The code of the entity that will receive the payment.
  • referenceNumber: The reference number of the invoice to be paid.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/sisp-payment';
const entityCode = '6';
const referenceNumber = '216465697';

const htmlForm = sisp.generateServicePaymentRequestForm(referenceId, total, webhookUrl, entityCode, referenceNumber);

Generate Recharge Request Form

sisp.generateRechargeRequestForm(referenceId, total, webhookUrl, entityCode, phoneNumber);

Generates and returns an HTML form that can be used to process phone recharge.

  • referenceId: Client-generated payment reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the payment request and response.
  • total: Payment amount (in CVE).
  • webhookUrl: The url where SISP should send the payment response. You should expect a POST request with payment information in the body. See the SISP documentation for more information.
  • entityCode: The code of the entity that will receive the payment.
  • phoneNumber: The phone number to be recharged.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/sisp-payment';
const entityCode = '2';
const phoneNumber = '9573234';

const htmlForm = sisp.generateRechargeRequestForm(referenceId, total, webhookUrl, entityCode, phoneNumber);

Generate Token Enrollment Request Form

sisp.generateTokenEnrollmentRequestForm(referenceId, total, webhookUrl);

Generates and returns an HTML form that can be used to make a token enrollment request.

  • referenceId: Client-generated token enrollment reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the token enrollment request and response.
  • total: This is the minimal amount (in CVE) accepted for a payment.
  • webhookUrl: The url where SISP should send the token enrollment response. You should expect a POST request with token enrollment information in the body. See the SISP documentation for more information.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/token-enrollment';

const htmlForm = sisp.generateTokenEnrollmentRequestForm(referenceId, total, webhookUrl);

Generate Token Cancel Request Form

sisp.generateTokenCancelRequestForm(referenceId, webhookUrl, token);

Generates and returns an HTML form that can be used to make a token cancel request.

  • referenceId: Client-generated token cancel reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the token cancel request and response.
  • webhookUrl: The url where SISP should send the token cancel response. You should expect a POST request with token cancel information in the body. See the SISP documentation for more information.
  • token: The token to be cancelled. It is also used to authenticate the request. This token is retrieved from the token enrollment request response.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/token-cancel';

const token = '831561583';

const htmlForm = sisp.generateTokenCancelRequestForm(referenceId, webhookUrl, token);

Generate Token Purchase Request Form

sisp.generateTokenPurchaseRequestForm(referenceId, total, webhookUrl, token);

Generates and returns an HTML form that can be used to make a token purchase request.

  • referenceId: Client-generated token purchase reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the token purchase request and response.
  • total: Payment amount (in CVE).
  • webhookUrl: The url where SISP should send the token purchase response. You should expect a POST request with token purchase information in the body. See the SISP documentation for more information.
  • token: The token to authenticate the request. This token is retrieved from the token enrollment request response.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/token-payment';

const token = '831561583';

const htmlForm = sisp.generateTokenPurchaseRequestForm(referenceId, total, webhookUrl, token);

Generate Token Service Payment Request Form

sisp.generateTokenServicePaymentRequestForm(referenceId, total, webhookUrl, entityCode, referenceNumber, token);

Generates and returns an HTML form that can be used to make a token service payment request.

  • referenceId: Client-generated token service payment reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the token service payment request and response.
  • total: Payment amount (in CVE).
  • webhookUrl: The url where SISP should send the token service payment response. You should expect a POST request with token service payment information in the body. See the SISP documentation for more information.
  • entityCode: The code of the entity that will receive the payment.
  • referenceNumber: The reference number of the invoice to be paid.
  • token: The token to authenticate the request. This token is retrieved from the token enrollment request response.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/token-payment';
const entityCode = '6';
const referenceNumber = '216465697';

const token = '831561583';

const htmlForm = sisp.generateTokenServicePaymentRequestForm(referenceId, total, webhookUrl, entityCode, referenceNumber, token);

Generate Token Phone Recharge Request Form

sisp.generateTokenRechargeRequestForm(referenceId, total, webhookUrl, entityCode, phoneNumber, token);

Generates and returns an HTML form that can be used to make a token phone recharge request.

  • referenceId: Client-generated token phone recharge reference ID. This value is sent via a POST request to the webhookUrl and allows the client to correlate the token phone recharge request and response.
  • total: Payment amount (in CVE).
  • webhookUrl: The url where SISP should send the token phone recharge response. You should expect a POST request with token phone recharge information in the body. See the SISP documentation for more information.
  • entityCode: The code of the entity that will receive the payment.
  • phoneNumber: The phone number to be recharged.
  • token: The token to authenticate the request. This token is retrieved from the token enrollment request response.

Example

const referenceId = 'abc-123';
const total = 1200;
const webhookUrl = 'https://samba.chuva.io/webhooks/token-payment';
const entityCode = '2';
const phoneNumber = '9573234';

const token = '831561583';

const htmlForm = sisp.generateTokenRechargeRequestForm(referenceId, total, webhookUrl, entityCode, phoneNumber, token);

Validate Payment Processing Status (convenience method)

Check whether or not a payment was processed successfully. Note: This method is provided as a convenience. See the SISP documentation for the request structure.

Usage

Pass the Webhook request body to validatePayment. Returns an error object containing code and description if there is an error, otherwise returns undefined.

validatePayment(responseBody)

Note: The responseBody should be of type x-www-form-urlencoded as provided by SISP.

Possible success messageTypes per transactionCode
Transaction: stringtransactionCode: stringmessageType: string
Purchase18
Service Payment2P
Phone recharge3M
Token enrollment5A
Token cancel7C
Token purchase6B
Token service payment2B
Token recharge3B
Possible Errors
Code: stringDescription: string
001Payment processing error: Invalid fingerprint
002Payment processing error: Cancelled by user
003Payment processing error: Processing error

Example

 app.post("/webhook-handler", (request, response) => {
     const error = sisp.validatePayment(request.body);

     if(error === undefined) {
         // Payment processed successfully
     }
     else {
         // Payment processing error
         console.log(error.code);
         console.log(error.description);
     }
 }

Keywords

FAQs

Package last updated on 23 Nov 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc