@crediblemark/buayar 0.1.0 → 0.1.1
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/dist/index.js +11 -5
- package/dist/index.mjs +11 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,11 +51,12 @@ var DuitkuProvider = class extends BasePaymentProvider {
|
|
|
51
51
|
const { orderId, amount, productDetails, customer, returnUrl, callbackUrl } = params;
|
|
52
52
|
const { merchantCode, apiKey, sandbox } = config;
|
|
53
53
|
const url = sandbox ? "https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry" : "https://passport.duitku.com/webapi/api/merchant/v2/inquiry";
|
|
54
|
-
const
|
|
54
|
+
const integerAmount = Math.round(amount);
|
|
55
|
+
const rawSignature = merchantCode + orderId + integerAmount.toString() + apiKey;
|
|
55
56
|
const signature = import_crypto.default.createHash("md5").update(rawSignature).digest("hex");
|
|
56
57
|
const payload = {
|
|
57
58
|
merchantCode,
|
|
58
|
-
paymentAmount:
|
|
59
|
+
paymentAmount: integerAmount,
|
|
59
60
|
merchantOrderId: orderId,
|
|
60
61
|
productDetails,
|
|
61
62
|
email: customer.email,
|
|
@@ -74,14 +75,19 @@ var DuitkuProvider = class extends BasePaymentProvider {
|
|
|
74
75
|
},
|
|
75
76
|
body: JSON.stringify(payload)
|
|
76
77
|
});
|
|
78
|
+
const text = await response.text();
|
|
79
|
+
let data = null;
|
|
80
|
+
try {
|
|
81
|
+
data = JSON.parse(text);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
}
|
|
77
84
|
if (!response.ok) {
|
|
78
85
|
return {
|
|
79
86
|
success: false,
|
|
80
|
-
rawResponse:
|
|
81
|
-
error: `HTTP error! Status: ${response.status}`
|
|
87
|
+
rawResponse: data,
|
|
88
|
+
error: data?.Message || data?.statusMessage || `HTTP error! Status: ${response.status} - ${text}`
|
|
82
89
|
};
|
|
83
90
|
}
|
|
84
|
-
const data = await response.json();
|
|
85
91
|
if (data.statusCode === "00") {
|
|
86
92
|
return {
|
|
87
93
|
success: true,
|
package/dist/index.mjs
CHANGED
|
@@ -12,11 +12,12 @@ var DuitkuProvider = class extends BasePaymentProvider {
|
|
|
12
12
|
const { orderId, amount, productDetails, customer, returnUrl, callbackUrl } = params;
|
|
13
13
|
const { merchantCode, apiKey, sandbox } = config;
|
|
14
14
|
const url = sandbox ? "https://sandbox.duitku.com/webapi/api/merchant/v2/inquiry" : "https://passport.duitku.com/webapi/api/merchant/v2/inquiry";
|
|
15
|
-
const
|
|
15
|
+
const integerAmount = Math.round(amount);
|
|
16
|
+
const rawSignature = merchantCode + orderId + integerAmount.toString() + apiKey;
|
|
16
17
|
const signature = crypto.createHash("md5").update(rawSignature).digest("hex");
|
|
17
18
|
const payload = {
|
|
18
19
|
merchantCode,
|
|
19
|
-
paymentAmount:
|
|
20
|
+
paymentAmount: integerAmount,
|
|
20
21
|
merchantOrderId: orderId,
|
|
21
22
|
productDetails,
|
|
22
23
|
email: customer.email,
|
|
@@ -35,14 +36,19 @@ var DuitkuProvider = class extends BasePaymentProvider {
|
|
|
35
36
|
},
|
|
36
37
|
body: JSON.stringify(payload)
|
|
37
38
|
});
|
|
39
|
+
const text = await response.text();
|
|
40
|
+
let data = null;
|
|
41
|
+
try {
|
|
42
|
+
data = JSON.parse(text);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
}
|
|
38
45
|
if (!response.ok) {
|
|
39
46
|
return {
|
|
40
47
|
success: false,
|
|
41
|
-
rawResponse:
|
|
42
|
-
error: `HTTP error! Status: ${response.status}`
|
|
48
|
+
rawResponse: data,
|
|
49
|
+
error: data?.Message || data?.statusMessage || `HTTP error! Status: ${response.status} - ${text}`
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
|
-
const data = await response.json();
|
|
46
52
|
if (data.statusCode === "00") {
|
|
47
53
|
return {
|
|
48
54
|
success: true,
|