Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
mellat-checkout2
Advanced tools
Unofficial Behpardakht Mellat Gateway implementation in Node.JS
NOTICE: SUBJECT TO BACKWARD INCOMPATIBLE CHANGES (Due to under V1.0.0 version).
Install the package from npm
or yarn
.
npm install mellat-checkout
yarn add mellat-checkout
Import the package:
const MellatCheckout = require('mellat-checkout');
// or (ES6):
import MellatCheckout from 'mellat-checkout';
Then create an instance:
const mellat = new MellatCheckout({
terminalId: 'xxxxxxx',
username: 'xxxxxxx',
password: 'xxxxxxx',
timeout: 10000, // Optional, number in millisecond (defaults to 10 sec)
apiUrl: 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl', // Optional, exists (and may updated) in bank documentation (defaults to this)
});
// Initialize the client, this step is optional
// but gives you more control over your flow
// and speeds up the first (and just first) request.
mellat.initialize().then(function () {
console.log("Mellat client ready")
})
.catch(function (error) {
// you can retry here
console.log("Mellat client encountered error:", error)
});
mellat.paymentRequest({
amount: 1000, // Payment Amount In Rials
orderId: '12345678912', // OrderID Generated By You
callbackUrl: 'https://call.back/mellat', // Payment Callback URL
payerId: '0' // Optional
}).then(function (response) {
if (response.resCode === 0) {
console.log(response.refId);
// Now redirect user to following address with post param
// { RefId: response.refId }
// https://bpm.shaparak.ir/pgwchannel/startpay.mellat
} else {
console.warn('Gateway Error: ', response.resCode);
}
}).catch(function (error) {
console.error(error);
});
mellat.verifyPayment({
orderId: '12345678912', // OrderID Used In Payment Request
saleOrderId: '12345678912', // Get From Payment Callback Post Params
saleReferenceId: '5142510', // Get From Payment Callback Post Params
}).then(function (response) {
if (response.resCode === 0) {
console.log("Verified, Call settlePayment");
} else {
console.warn('Gateway Error: ', response.resCode);
}
}).catch(function (error) {
console.error(error);
});
mellat.settlePayment({
orderId: '12345678912', // OrderID Used In Payment Request
saleOrderId: '12345678912', // Get From Payment Callback Post Params
saleReferenceId: '5142510', // Get From Payment Callback Post Params
}).then(function (response) {
if (response.resCode === 0) {
console.log("Payment Is Done.");
} else if (response.resCode === 45) {
console.log("Payment Already Done(Settled Before).");
} else {
console.warn('Gateway Error: ', response.resCode);
}
}).catch(function (error) {
console.error(error);
});
mellat.inquiryRequest({
orderId: '12345678912', // OrderID Used In Payment Request
saleOrderId: '12345678912', // Get From Payment Callback Post Params
saleReferenceId: '5142510', // Get From Payment Callback Post Params
}).then(function (response) {
console.log('Payment Status: ' + response.resCode)
}).catch(function (error) {
console.error(error);
});
mellat.reversalRequest({
orderId: '12345678912', // OrderID Used In Payment Request
saleOrderId: '12345678912', // Get From Payment Callback Post Params
saleReferenceId: '5142510', // Get From Payment Callback Post Params
}).then(function (response) {
if (response.resCode === 0) {
console.log("Payment Is Reversed.");
} else {
console.warn('Gateway Error: ', response.resCode);
}
}).catch(function (error) {
console.error(error);
});
All methods can be called by using Callbacks instead of Promises, lets take paymentRequest
as an example:
mellat.paymentRequest({
amount: 1000, // Payment Amount In Rials
orderId: '12345678912', // OrderID Generated By You
callbackUrl: 'https://call.back/mellat', // Payment Callback URL
payerId: '0' // Optional
}, function (error, response) {
if (error) {
console.error(error);
} else if (response.resCode === 0) {
console.log(response.refId);
} else {
console.warn('Gateway Error: ', response.resCode);
}
});
mocha
Contributions are welcome. Please submit PRs or just file an Issue if you see something broken or in need of improving.
ResCode | Description |
---|---|
0 | تراکنش با موفقیت انجام شد |
11 | شماره کارت نا معتبر است |
12 | موجودی کافی نیست |
13 | رمز نادرست است |
14 | تعداد دفعات وارد کردن رمز بیش از حد مجاز است |
15 | کارت نامعتبر است |
16 | دفعات برداشت وجه بیش از حد مجاز است |
17 | کاربر از انجام تراکنش منصرف شده است |
18 | تاریخ انقضای کارت گذشته است |
19 | مبلغ برداشت وجه بیش از حد مجاز است |
21 | پذیرنده نا معتبر است |
23 | خطای امنیتی رخ داده است |
24 | اطلاعات کاربری پذیرنده نا معتبر است |
25 | مبلغ نا معتبر است |
31 | پاسخ نا معتبر است |
32 | فرمت اطلاعات وارد شده صحیح نمی باشد |
33 | حساب نا معتبر است |
34 | خطای سیستمی |
35 | تاریخ نا معتبر است |
41 | شماره درخواست تکراری است |
42 | تراکنش Sale یافت نشد |
43 | قبلا درخواست Verify داده شده است |
44 | درخواست Verify یافت نشد |
45 | تراکنش Settle شده است |
46 | تراکنش Settle نشده است |
47 | تراکنش Settle یافت نشد |
48 | تراکنش Reverse شده است |
49 | تراکنش Refund یافت نشد |
51 | تراکنش تکراری است |
54 | تراکنش مرجع موجود نیست |
55 | تراکنش نا معتبر است |
61 | خطا در واریز |
62 | مسير بازگشت به سايت در دامنه ثبت شده برای پذيرنده قرار ندارد |
98 | سقف استفاده از رمز ایستا به پایان رسیده است |
111 | صادر کننده کارت نا معتبر است |
112 | خطای سوییچ صادر کننده کارت |
113 | پاسخی از صادر کننده ی کارت دریافت نشد |
114 | دارنده کارت مجاز به انجام این تراکنش نیست |
412 | شناسه قبض نادرست است |
413 | شناسه پرداخت نادرست است |
414 | سازمان صادر کننده قبض نامعتبر است |
415 | زمان جلسه کاری به پایان رسیده است |
416 | خطا در ثبت اطلاعات |
417 | شناسه پرداخت کننده نا معتبر است |
418 | اشکال در تعریف اطلاعات مشتری |
419 | تعداد دفعات ورود اطلاعات از حد مجاز گذشته است |
421 | IP نامعتبر است |
FAQs
Unofficial implementation of Behpardakht Mellat Gateway API.
We found that mellat-checkout2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.