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

@adriantombu/paybox-system

v2.0.7

Published

A simple implementation of the Paybox System payment solution

Downloads

61

Readme

Paybox System npm version

This library is a simple implementation of the Paybox System payment solution

How to use it

  • Install the library first with yarn add @adriantombu/paybox-system
  • And then import it in your script

Get the payment form button

const { Paybox } = require('@adriantombu/paybox-system')

const payment = Paybox.create({
    payboxSite: '1999888',
    payboxRang: '32',
    payboxIdentifiant: '1686319',
    payboxHmac: 'HMACHMACHMAC',
    payboxEffectue: 'https://www.exemple.com/payment/success',
    payboxRefuse: 'https://www.exemple.com/payment/error',
    payboxAnnule: 'https://www.exemple.com/payment/cancelled',
    payboxAttente: 'https://www.exemple.com/payment/waiting',
    payboxRepondreA: 'https://www.exemple.com/payment/process',
    amount: 4990, // This is the price x100 to remove the comma
    email: '[email protected]',
    reference: '123456',
});

const form = await payment.form();

Where form contains an object similar to the one below.

{
  "url": "https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi",
  "method": "POST",
  "form": "<input type=\"hidden\" name=\"PBX_SITE\" value=\"1999888\" /><input type=\"hidden\" name=\"PBX_RANG\" value=\"32\" /><input type=\"hidden\" name=\"PBX_IDENTIFIANT\" value=\"1686319\" /><input type=\"hidden\" name=\"PBX_ARCHIVAGE\" value=\"559891246771\" /><input type=\"hidden\" name=\"PBX_TOTAL\" value=\"0000004990\" /><input type=\"hidden\" name=\"PBX_DEVISE\" value=\"978\" /><input type=\"hidden\" name=\"PBX_CMD\" value=\"123456\" /><input type=\"hidden\" name=\"PBX_PORTEUR\" value=\"[email protected]\" /><input type=\"hidden\" name=\"PBX_RETOUR\" value=\"amount:M;paymentId:R;transactionId:T;authorizationId:A;cardType:P;cardNumber:N;cardExpiration:D;error:E;payboxRef:S;signature:K;\" /><input type=\"hidden\" name=\"PBX_RUF1\" value=\"POST\" /><input type=\"hidden\" name=\"PBX_3DS\" value=\"N\" /><input type=\"hidden\" name=\"PBX_TIME\" value=\"07062019090726\" /><input type=\"hidden\" name=\"PBX_HASH\" value=\"SHA512\" /><input type=\"hidden\" name=\"PBX_EFFECTUE\" value=\"https://www.arlettie.fr/payment/success\" /><input type=\"hidden\" name=\"PBX_REFUSE\" value=\"https://www.arlettie.fr/payment/error\" /><input type=\"hidden\" name=\"PBX_ANNULE\" value=\"https://www.arlettie.fr/payment/cancelled\" /><input type=\"hidden\" name=\"PBX_ATTENTE\" value=\"https://www.arlettie.fr/payment/waiting\" /><input type=\"hidden\" name=\"PBX_REPONDRE_A\" value=\"https://api.arlettie.fr/payments/webhook\" /><input type=\"hidden\" name=\"PBX_HMAC\" value=\"713E1F0FF270D5AA16A61B76C3BACCC4A15B039E6472B0D13EE51D905D3DFA196FC572600646B5897ACDFBDE1404EE7BAFF727D1EDB723C0DA121720D485E7F7\" />",
  "elements": [
    {
      "name": "PBX_SITE",
      "value": "1999888"
    },

    [...]

    {
      "name": "PBX_HMAC",
      "value": "713E1F0FF270D5AA16A61B76C3BACCC4A15B039E6472B0D13EE51D905D3DFA196FC572600646B5897ACDFBDE1404EE7BAFF727D1EDB723C0DA121720D485E7F7"
    }
  ]
}

Note: It is better to use the form string instead of the elements array because the values are computed in a given order. This way you are certain that there will be no problem.

Check the returned transaction

Always use the payboxRepondreA to check the transaction. This is a url directly called by Paybox from server to server that returns the result of the transaction.

const { Paybox } = require('@adriantombu/paybox-system')

// This is an exemple of a POST body that you retrieve from the Paybox call
const body = {
  authorizationId: '1234',
  error: '00000',
  amount: '4990',
  signature: 'SQDGFQSDGFQSDFR234GGR23523423',
  paymentId: '123456'
}

 // This should be saved in your database (along with the transaction id) before the user goes to the Paybox form
const amount = 4990;

const status = Paybox.isValid(body, amount)
// true

How to contribute

  • Clone the repository git clone [email protected]:adriantombu/paybox-system.git
  • Install the packages with yarn install
  • Modify the files under in the src/ folder
  • When everything's done, you can send a PR \o/