@404-software/benefit
TypeScript icon, indicating that this package has built-in type declarations

1.0.46 • Public • Published

About

This package helps in generating a Benefit (Bahrain) payment session using a link that can be passed to the user to pay using Benefit's hosted session.



How to use

1- you can set the following environment variables:

BENEFIT_TRANSPORTAL_ID="Transportal Id"
BENEFIT_TRANSPORTAL_PASSWORD="Transportal Password"
BENEFIT_TERMINAL_RESOURCE_KEY="Terminal Resource Key"
BENEFIT_IV="Initialization Vector"
BENEFIT_CANCEL_URL="Website's cancel URL"
BENEFIT_RETURN_URL="Website's return URL"
BENEFIT_TEST_MODE=false

alternatively, you can pass these details to the config of the function directly mentioned in the next step.


2- You need to pass the following object to the CreateBenefitSession function:

{
  order: {
    id: string | number
    total: string | number
  },
  config: { //ONLY if not using environment variables
    tranportalId: string
    tranportalPassword: string
    terminalResourcekey: string
    iv: string
    cancelUrl: string
    returnUrl: string
    testMode?: boolean // defaults to false
  }
}



Example

import { CreateBenefitSession } from '@404-software/benefit'

const { paymentUrl } = await CreateBenefitSession({
	order: {
		id: '123',
		total: 20.5,
	},
})



Decrypting Response

import { DecryptBenefitTrandata } from '@404-software/benefit'

const buffer = req.body

const { id } = await DecryptBenefitTrandata({ buffer })

Readme

Keywords

none

Package Sidebar

Install

npm i @404-software/benefit

Weekly Downloads

2

Version

1.0.46

License

MIT

Unpacked Size

12.9 kB

Total Files

7

Last publish

Collaborators

  • alqassab