npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sherlocks-sips-payment-sdk

v1.0.1

Published

Library to interact with the Sherlocks Worldline Sips 2.0 API

Downloads

9

Readme

SIPS Payment SDK npm version

This package provides a Node.js implementation for SIPS, the Worldline e-payments gateway.

:warning: This library was written for SIPS 2.0 and is not compatible with SIPS 1.0!

Installing

This library is provided as two separate packages on NPM . To install it, simply run:

npm install sherlocks-sips-payment-sdk

Or if you prefer Yarn, run:

yarn add sherlocks-sips-payment-sdk

Usage

:bulb: Currently this library only supports SIPS in pay page mode.

Initialization

First, create a client for the desired environment using your merchant ID, key version & secret key:

import Sips from 'sherlocks-sips-payment-sdk';

const paypageClient = new Sips.PaypageClient(
    process.env.NODE_ENV == 'production' ? Sips.Environment.PROD : Sips.Environment.SIMU,
    process.env.MERCHANT_ID,
    process.env.KEY_VERSION,
    process.env.SECRET_VERSION);

Then set up a request to initialize a session on the SIPS server:

import Sips from 'sherlocks-sips-payment-sdk';

const paymentRequest = Object.assign(new Sips.PaymentRequest(), {
    currencyCode: Sips.Currency.EUR,
    orderChannel: Sips.OrderChannel.INTERNET,
    interfaceVersion: 'IR_WS_3.4',
    automaticResponseUrl: 'AUTOMATIC_RETURN_URL',
    normalReturnUrl: 'NORMAL_RETURN_URL',
    amount: Math.round(req.body.amount * 100) // Amount in the minimal unit used in the currency
    // bypassReceiptPage: true
});

Add unique reference for the transaction:

If SIPS 2.0 contract :

paymentRequest.transactionReference = 'unique-transaction-ref'; // Max 35 alphanumeric characters string

If SIPS 1.0 contract migrated to SIPS 2.0 :

paymentRequest.s10TransactionReference = {
    s10TransactionId: 'unique-transaction-ref' // Max 6 numeric characters string
}

And initialize your session on the server:

const initializationResponse = await paypageClient.initializePayment(paymentRequest);

The initializationResponse you'll receive from the server contains all information needed to continue handling your transaction. If you're initialization was successful, your response will contain a RedirectionStatusCode.TRANSACTION_INITIALIZED (Code 00).

Making the payment

In case your initialization was successful, you have to use the redirectionUrl received to perform a POST request with both the redirectionData and seal as parameters. Since this should redirect the customer the SIPS payment page, the cleanest example is a simple HTML form:

<form method="post" action="redirectionUrl">
    <input name="redirectionData" type="hidden" value="..." />
    <input name="seal" type="hidden" value="..." />
    <input type="submit" value="Proceed to checkout"/>
</form>

Verifying the payment

When your customer is done, he will be able to return to your application. This is done via a form, making a POST request to the normalReturnUrl provided during the initialization of your payment. This POST request contains details on the payment. You can simply decode these responses, providing the parameters included in the received request to your paypageClient:

const paypageResponse = paypageClient.decodeResponse(request.data);

:warning: Since the customer is not always redirecting back (e.g. he closes the confirmation page), it's a a good practice to include an automaticReturnUrl. SIPS will always POST details on the transaction on this URL, even if a customer doesn't redirect back to your application.