项目作者: menavita

项目描述 :
Node module for Expresspay API.
高级语言: JavaScript
项目地址: git://github.com/menavita/node-expresspay.git
创建时间: 2017-11-08T13:17:53Z
项目社区:https://github.com/menavita/node-expresspay

开源协议:MIT License

下载


node-expresspay

Node module for using Expresspay API.

  1. var Expresspay = require('node-expresspay');
  2. var expresspay = new Expresspay('https://api.express-pay.by/v1/', 'API-Key', 'Secret-Key', 'Return-Secret-Key');

ERIP functions

Signature included.

Create invoice

  1. expresspay.createInvoiceERIP({
  2. "AccountNo": 10, // required
  3. "Amount": 10, // required
  4. "Currency": 933, // required
  5. "Expiration": '20171210',
  6. "Info": 'info',
  7. "Surname": 'Ivanov',
  8. "FirstName": 'Ivan',
  9. "Patronymic": 'Ivanovich',
  10. "City": 'Minsk',
  11. "Street": 'Karl Marks',
  12. "House": '2a',
  13. "Building": '2',
  14. "Apartment": '34',
  15. "IsNameEditable": 1,
  16. "IsAddressEditable": 1,
  17. "IsAmountEditable": 1,
  18. "EmailNotifacation": 'ivanovivan@gmail.com',
  19. "SmsPhone": '+375291111111'
  20. })
  21. .then(function(res) {
  22. console.log(res.InvoiceNo);
  23. })
  24. .catch(function(e) {
  25. throw new Error(e.Error.Msg);
  26. })

Get invoices list by params

  1. expresspay.getInvoicesListERIP({
  2. "From": '20170110',
  3. "To": '20171210',
  4. "AccountNo": 100,
  5. "Status": 1
  6. })
  7. .then(function(res) {
  8. console.log(res);
  9. })
  10. .catch(function(e) {
  11. throw new Error(e.Error.Msg);
  12. })

Get invoice details

  1. expresspay.getInvoiceDetailsERIP({
  2. "InvoiceNo": 10 // required
  3. })
  4. .then(function(res) {
  5. console.log(res);
  6. })
  7. .catch(function(e) {
  8. throw new Error(e.Error.Msg);
  9. })

Get invoice status

  1. expresspay.getInvoiceStatusERIP({
  2. "InvoiceNo": 10 // required
  3. })
  4. .then(function(res) {
  5. console.log(res)
  6. })
  7. .catch(function(e) {
  8. throw new Error(e.Error.Msg);
  9. })

Get payments list

  1. expresspay.getPaymentsListERIP({
  2. "From": '20170110',
  3. "To": '20171210',
  4. "AccountNo": 100
  5. })
  6. .then(function(res) {
  7. console.log(res);
  8. })
  9. .catch(function(e) {
  10. throw new Error(e.Error.Msg);
  11. })

Get payment details

  1. expresspay.getPaymentDetailsERIP({
  2. "PaymentNo": 2 // required
  3. })
  4. .then(function(res) {
  5. console.log(res);
  6. })
  7. .catch(function(e) {
  8. throw new Error(e.Error.Msg);
  9. })

Cancel invoice

  1. expresspay.cancelInvoiceERIP({
  2. "InvoiceNo": 10 // required
  3. })
  4. .then(function(res) {
  5. console.log(res);
  6. })
  7. .catch(function(e) {
  8. throw new Error(e.Error.Msg)
  9. })

Card functions

Signature included.

Create invoice

  1. expresspay.createInvoiceCard({
  2. "AccountNo": "123456", // required
  3. "Expiration": "20161224", // required
  4. "Amount": 10, // required
  5. "Currency": 933, // required
  6. "Info": 'info', // required
  7. "ReturnUrl": 'https://example.com/success', // required
  8. "FailUrl": 'https://example.com/fail', // required
  9. "Language": 'ru',
  10. "SessionTimeoutSecs": 2000,
  11. "ExpirationDate": '20161224235001'
  12. })
  13. .then(function(res) {
  14. console.log(res);
  15. })
  16. .catch(function(e) {
  17. throw new Error(e.Error.Msg);
  18. })

Get invoice form

  1. expresspay.getInvoiceFormCard({
  2. "InvoiceId": 100 // required
  3. })
  4. .then(function(res) {
  5. console.log(res);
  6. })
  7. .catch(function(e) {
  8. throw new Error(e.Error.Msg)
  9. })

Get invoice status

  1. expresspay.getInvoiceStatusCard({
  2. "InvoiceId": 100, // required
  3. "Language": 'ru'
  4. })
  5. .then(function(res) {
  6. console.log(res);
  7. })
  8. .catch(function(e) {
  9. throw new Error(e.Error.Msg);
  10. })

Reverse invoice

  1. expresspay.reverseInvoiceCard({
  2. "InvoiceId": 100 // required
  3. })
  4. .then(function(res) {
  5. console.log(res);
  6. })
  7. .catch(function(e) {
  8. throw new Error(e.Error.Msg);
  9. })

Signature functions

Create signature

Return signtaure as string.

  1. expresspay.createSignature(type, data)
  2. var signature = expresspay.createSignature('create_invoice_erip',
  3. {
  4. "AccountNo": 26,
  5. "Amount": '10',
  6. "Currency": '933',
  7. "Info": 'testtest',
  8. "ReturnUrl": 'https://example.com/success',
  9. "FailUrl": 'https://example.com/fail',
  10. });

Types
|Function |String |
|———————————-|:————————————:|
|createInvoiceERIP |create_invoice_erip |
|getInvoicesListERIP |get_invoices_list_erip |
|getInvoiceDetailsERIP |get_invoice_details_erip |
|getInvoiceStatusERIP |get_invoice_status_erip |
|getPaymentsListERIP |get_payments_list_erip |
|getPaymentDetailsERIP |get_payment_details |
|cancelInvoiceERIP |create_invoice_card |
|cancelInvoiceERIP |get_invoice_form_card |
|cancelInvoiceERIP |get_invoice_status_card |
|cancelInvoiceERIP |reverse_invoice_card |

Check signature

Return true or false

  1. expresspay.checkSignature(data, signature);
  2. var check = expresspay.checkSignature('{"CmdType":1,"AccountNo":"123456789","PaymentNo":123,"Amount":"100000","Created":"20171121162605","Service":"Ремонт бытовой техники","Payer":"Иванов Петр Анатольевич","Address":"г. Минск, ул. Автозаводская, д.1, кв. 65"}', '7307D720623523CABB3C291AB1D9A683FFB711BB');

Tests

  1. npm run eriptest
  2. npm run cardtest
  3. npm run checktest

License

MIT