express-pay 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,16 @@
1
1
  Hello Everyone👋,
2
2
 
3
- - Not Officially Supported By Paynow
4
-
5
- I am pleased to introduce you to the Express Pay. This package is a part of "PAYNOW" and aims to simplify the process of implementing EXPRESS CHECKOUT PAYMENTS using ECOCASH.
3
+ I am pleased to introduce you to the Paynow Integration Package. This package is a part of "PAYNOW" and aims to simplify the process of implementing EXPRESS CHECKOUT PAYMENTS using ECOCASH.
6
4
 
7
5
 
8
6
  - SETUP
9
7
 
10
- To set up the package, you simply need to run "npm i express-pay" and configure your keys from https://www.paynow.co.zw/home/businesshome in the .env file. Then, import the downloaded method into your file. Make sure to enter all required arguments for the function to work correctly and implement it as an asynchronous function.
8
+ To set up the package, you simply need to run "npm i paynow_integration" and configure your keys from https://www.paynow.co.zw/home/businesshome in the .env file. Then, import the downloaded method into your file. Make sure to enter all required arguments for the function to work correctly and implement it as an asynchronous function.
11
9
 
12
10
 
13
11
  - USAGE EXAMPLE
14
12
 
15
- const pay = require("express-pay");
13
+ const pay = require("paynow_integration");
16
14
 
17
15
  REQUIRED ARGUMENTS
18
16
  - Payee Contact (String)
package/express_pay.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const {Paynow} = require("paynow");
2
2
  require("dotenv").config();
3
+ const axios = require("axios");
4
+
3
5
 
4
6
  const ID = process.env.PAYNOW_INTEGRATION_ID;
5
7
  const KEY = process.env.PAYNOW_INTEGRATION_KEY;
@@ -9,7 +11,7 @@ module.exports = function Pay(Payee_Contact, Transaction_Reference,Transaction_A
9
11
 
10
12
  const payment = paynow.createPayment(`${Transaction_Reference}`, `${Customer_Email}`);
11
13
  payment.add(`${Product_Name}`, `${Transaction_Amount}`);
12
- const maxTimeout = 20000;
14
+ const maxTimeout = 30000;
13
15
 
14
16
  return paynow.sendMobile(payment, `${Payee_Contact}`, "ecocash")
15
17
  .then(async function (response) {
@@ -30,6 +32,8 @@ module.exports = function Pay(Payee_Contact, Transaction_Reference,Transaction_A
30
32
  resolve("Paid");
31
33
  } else if (result === "Cancelled") {
32
34
  resolve("Cancelled");
35
+ }else if(result==="Sent"){
36
+ resolve("Not Authorised");
33
37
  } else {
34
38
  resolve("Transaction failed")
35
39
  }
@@ -46,21 +50,31 @@ module.exports = function Pay(Payee_Contact, Transaction_Reference,Transaction_A
46
50
  });
47
51
  }
48
52
 
49
- async function getTransactionStatus(response){
50
- let requestOptions = {
51
- method: 'GET',
52
- redirect: 'follow'
53
- };
54
- try {
55
- const response_1 = await fetch(`${response.pollUrl}`, requestOptions);
56
- const result_1 = await response_1.text();
57
- const resbody = `${result_1}`;
58
- const start = resbody.indexOf('status=') + 'status='.length;
59
- const end = resbody.indexOf('&', start);
60
- const status = resbody.substring(start, end);
61
- return status;
53
+ async function getTransactionStatus(response){
54
+
55
+
56
+ try {
57
+
58
+
59
+
60
+
61
+ const response_1 = await axios.get(`${response.pollUrl}`);
62
+
63
+ const resbody = response_1.data;
64
+
65
+
66
+ const start = resbody.indexOf('status=') + 'status='.length;
67
+
68
+
69
+ const end = resbody.indexOf('&', start);
70
+
71
+
72
+ const status = resbody.substring(start, end);
73
+
74
+
75
+
76
+ return status;
62
77
  } catch (error) {
63
- return console.log('error', error);
78
+ return console.log('error', error);
64
79
  }
65
-
66
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-pay",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Node Package To Simplify Express Payments Via Ecocash",
5
5
  "main": "express_pay.js",
6
6
  "bin": "express_pay.js",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "homepage": "https://github.com/Luke-Tembani/Express-Pay#readme",
26
26
  "dependencies": {
27
+ "axios": "^1.4.0",
27
28
  "dotenv": "^16.0.3",
28
29
  "paynow": "^1.0.9"
29
30
  }