aeremmiddleware 1.0.32 → 1.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aeremmiddleware",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "",
5
5
  "type": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -5,100 +5,112 @@ import { createHash } from "crypto";
5
5
  import { mandateHtml } from "./ingenicoHtml";
6
6
 
7
7
  class IngenicoApiWrapper {
8
- private verificationUrl = "https://www.paynimo.com/api/paynimoV2.req";
9
- private salt = "";
8
+ private verificationUrl = "https://www.paynimo.com/api/paynimoV2.req";
9
+ private salt = "";
10
10
 
11
- constructor(salt: string) {
12
- this.salt = salt;
13
- }
14
- async startMandate(mandateData: MandateDataType): Promise<any> {
15
- const hashingData = {
16
- merchantId: mandateData.merchantId,
17
- txnId: mandateData.txnId,
18
- totalamount: mandateData.totalamount,
19
- accountNo: mandateData.accountNo,
20
- consumerId: mandateData.consumerId,
21
- consumerMobileNo: mandateData.consumerMobileNo,
22
- consumerEmailId: mandateData.consumerEmailId,
23
- debitStartDate: mandateData.debitStartDate,
24
- debitEndDate: mandateData.debitEndDate,
25
- maxAmount: mandateData.maxAmount,
26
- amountType: mandateData.amountType,
27
- frequency: mandateData.frequency,
28
- cardNumber: "",
29
- expMonth: "",
30
- expYear: "",
31
- cvvCode: "",
32
- };
11
+ constructor(salt: string) {
12
+ this.salt = salt;
13
+ }
14
+ async startMandate(mandateData: MandateDataType): Promise<any> {
15
+ const hashingData = {
16
+ merchantId: mandateData.merchantId,
17
+ txnId: mandateData.txnId,
18
+ totalamount: mandateData.totalamount,
19
+ accountNo: mandateData.accountNo,
20
+ consumerId: mandateData.consumerId,
21
+ consumerMobileNo: mandateData.consumerMobileNo,
22
+ consumerEmailId: mandateData.consumerEmailId,
23
+ debitStartDate: mandateData.debitStartDate,
24
+ debitEndDate: mandateData.debitEndDate,
25
+ maxAmount: mandateData.maxAmount,
26
+ amountType: mandateData.amountType,
27
+ frequency: mandateData.frequency,
28
+ cardNumber: "",
29
+ expMonth: "",
30
+ expYear: "",
31
+ cvvCode: "",
32
+ };
33
+
34
+ const tokenId = createSHA512Hash(hashingData, this.salt);
35
+ return mandateHtml(mandateData, tokenId);
36
+ }
33
37
 
34
- const tokenId = createSHA512Hash(hashingData, this.salt);
35
- return mandateHtml(mandateData, tokenId);
36
- }
38
+ private hashString(input: string): string {
39
+ const hash = createHash("sha512");
40
+
41
+ return hash.update(input).digest("hex");
42
+ }
37
43
 
38
- private hashString(input: string): string {
39
- const hash = createHash("sha512");
44
+ async dualVerification(inputString: string): Promise<any> {
45
+ const modifiedHash = inputString.split("|").slice(-1).join("");
46
+ const payload =
47
+ inputString.split("|").slice(0, -1).join("|") + `|${this.salt}`;
40
48
 
41
- return hash.update(input).digest("hex");
42
- }
49
+ const originalHash = this.hashString(payload);
43
50
 
44
- async dualVerification(inputString: any): Promise<any> {
45
- const originalHash = this.hashString(inputString);
46
- console.log("originalhash", originalHash);
47
- const dataArray = inputString.split("|");
48
- dataArray[dataArray.length - 1] = this.salt;
49
- const modifiedString = dataArray.join("|");
50
- const modifiedHash = this.hashString(modifiedString);
51
- console.log("modifiedhash", modifiedHash);
51
+ console.log("dualVerification==", modifiedHash, payload, originalHash);
52
52
 
53
- if (originalHash === modifiedHash) {
54
- console.log("true");
55
- return true;
56
- } else {
57
- console.log("faalse");
58
- return false;
53
+ if (originalHash === modifiedHash) {
54
+ console.log("true");
55
+ return true;
56
+ } else {
57
+ console.log("faalse");
58
+ return false;
59
+ }
59
60
  }
60
- }
61
61
 
62
- async mandateVerification(requestData: any): Promise<any> {
63
- try {
64
- const response = await axios.post(this.verificationUrl, requestData, {
65
- headers: {
66
- "Content-Type": "application/json",
67
- },
68
- });
62
+ async mandateVerification(requestData: any): Promise<any> {
63
+ try {
64
+ const response = await axios.post(
65
+ this.verificationUrl,
66
+ requestData,
67
+ {
68
+ headers: {
69
+ "Content-Type": "application/json",
70
+ },
71
+ }
72
+ );
69
73
 
70
- return response.data;
71
- } catch (error) {
72
- console.error("Error:", error);
74
+ return response.data;
75
+ } catch (error) {
76
+ console.error("Error:", error);
77
+ }
73
78
  }
74
- }
75
79
 
76
- async transactionScheduling(requestData: any): Promise<any> {
77
- try {
78
- const response = await axios.post(this.verificationUrl, requestData, {
79
- headers: {
80
- "Content-Type": "application/json",
81
- },
82
- });
80
+ async transactionScheduling(requestData: any): Promise<any> {
81
+ try {
82
+ const response = await axios.post(
83
+ this.verificationUrl,
84
+ requestData,
85
+ {
86
+ headers: {
87
+ "Content-Type": "application/json",
88
+ },
89
+ }
90
+ );
83
91
 
84
- return response.data;
85
- } catch (error) {
86
- console.error("Error:", error);
92
+ return response.data;
93
+ } catch (error) {
94
+ console.error("Error:", error);
95
+ }
87
96
  }
88
- }
89
- async transactionVerification(requestData: any): Promise<any> {
90
- try {
91
- const response = await axios.post(this.verificationUrl, requestData, {
92
- headers: {
93
- "Content-Type": "application/json",
94
- },
95
- });
97
+ async transactionVerification(requestData: any): Promise<any> {
98
+ try {
99
+ const response = await axios.post(
100
+ this.verificationUrl,
101
+ requestData,
102
+ {
103
+ headers: {
104
+ "Content-Type": "application/json",
105
+ },
106
+ }
107
+ );
96
108
 
97
- return response.data;
98
- } catch (error) {
99
- console.error("Error:", error);
109
+ return response.data;
110
+ } catch (error) {
111
+ console.error("Error:", error);
112
+ }
100
113
  }
101
- }
102
114
  }
103
115
 
104
116
  export default IngenicoApiWrapper;