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

webpay-bahamta

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpay-bahamta - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

example/server.js

97

index.js
"use strict";
const axios = require('axios').default;
const pjson = require('./package.json');
const BASE_URL = 'https://webpay.bahamta.com/api';
const DOCS_URL = 'https://webpay.bahamta.com/doc/api';
const USER_AGENT = `Webpay NodeJS Library - ${pjson.version}`;
axios.interceptors.response.use(
response => {
return response;
},
error => {
if(!error.response)
error.response = {
data: { ok: false, error: 'NETWORK_ERROR', apidoc: DOCS_URL},
status: 500,
};
return Promise.reject(error.response);
}
);
const serverCall = config => {
config.headers = {
"user-agent": USER_AGENT,
};
config.baseURL = BASE_URL;
config.timeout = 60 * .5 * 1000; // Let's say you want to wait at least .5 mins
return axios(config);
};
/**
* @param {string} api_key - The bahamta api-key: 'webpay:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz'
* @param {string} reference - The order number (should be unique): 'order#1004'
* @param {number} amount_irr - The amount of money in Rials: 100000
* @param {string} callback_url - Call back url for bahamta recall (should start with http or https) : 'https://mydomain.ir/checkout/order#1004'
* @param {string} payer_mobile - The payer mobile number: '98912*******'
* @param {string} trusted_pan - The trusted credit cards number list: '6219234531241234,623254******5645,5453612376879876'
* @returns {Promise} Promise object represents server response success=({ok: true, result}), failure = ({ok: false, error})
*/
const payment = async (
api_key,
reference,
amount_irr,
callback_url,
payer_mobile = null,
trusted_pan = null
) => {
try {
let params = {
api_key,
reference,
amount_irr,
callback_url,
payer_mobile,
trusted_pan
};
const response = await serverCall({method: 'GET', url:`/create_request`, params: params});
return response.data;
} catch (error) {
return {...response.data, apidoc: DOCS_URL};
}
}
/**
* @param {string} api_key - The bahamta api-key: 'webpay:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz'
* @param {string} reference - The order number (should be unique): 'order#1004'
* @param {number} amount_irr - The amount of money in Rials: 100000
* @returns {Promise} Promise object represents server response success=({ok: true, result}), failure = ({ok: false, error})
*/
const verify = async (
api_key,
reference,
amount_irr
) => {
try {
let params = {
api_key,
reference,
amount_irr
};
const response = await serverCall({method: 'GET', url:`/confirm_payment`, params});
return response.data;
} catch (error) {
return {...response.data, apidoc: DOCS_URL};
}
}
module.exports = {
payment : payment,
verify : verify
};
module.exports = require('./lib/webpay');
{
"name": "webpay-bahamta",
"version": "1.0.1",
"version": "1.0.2",
"description": "This a lib to handle payment from bahamta",

@@ -8,2 +8,3 @@ "author": "Hossein Rashidi",

"main": "index.js",
"types": "index.d.ts",
"repository": {

@@ -25,3 +26,7 @@ "type": "git",

"axios": "^0.21.1"
},
"devDependencies": {
"dotenv": "^8.2.0",
"typescript": "^4.2.4"
}
}

@@ -63,12 +63,12 @@ [![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/hrashidi/webpay-bahamta)](https://github.com/hrashidi/webpay-bahamta/releases/latest)

{
"state": "paid",
"total": 1000000,
"wage": 5000,
"gateway": "sep",
"terminal": "11223344",
"pay_ref": "GmshtyjwKSu5lKOLquYrzO9BqjUMb/TPUK0qak/iVs",
"pay_trace": "935041",
"pay_pan": "123456******1234",
"pay_cid": "77CB1B455FB5F60415A7A02E4502134CFD72DBF6D1EC8FA2B48467DFB124AA75A",
"pay_time": "2019-11-12T16:39:57.686436+03:30"
"state": "paid",
"total": 1000000,
"wage": 5000,
"gateway": "sep",
"terminal": "11223344",
"pay_ref": "GmshtyjwKSu5lKOLquYrzO9BqjUMb/TPUK0qak/iVs",
"pay_trace": "935041",
"pay_pan": "123456******1234",
"pay_cid": "77CB1B455FB5F60415A7A02E4502134CFD72DBF6D1EC8FA2B48467DFB124AA75A",
"pay_time": "2019-11-12T16:39:57.686436+03:30"
}

@@ -75,0 +75,0 @@ ```

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