A simple implementation of the Paybox System payment solution
npm install @adriantombu/paybox-systemThis library is a simple implementation of the Paybox System payment solution
- Install the library first with yarn add @adriantombu/paybox-system
- And then import it in your script
``
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: 'adrian@example.com',
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": "",
"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.
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
`
- Clone the repository git clone git@github.com:adriantombu/paybox-system.gityarn install
- Install the packages with src/` folder
- Modify the files under in the
- When everything's done, you can send a PR \o/