@muhammedaksam/sipay-node 1.0.5 → 1.0.6
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/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/payments.js +8 -1
- package/dist/esm/resources/payments.js.map +1 -1
- package/dist/esm/utils/index.js +154 -16
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/payments.d.ts +3 -3
- package/dist/resources/payments.d.ts.map +1 -1
- package/dist/resources/payments.js +8 -1
- package/dist/resources/payments.js.map +1 -1
- package/dist/utils/index.d.ts +41 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +162 -50
- package/dist/utils/index.js.map +1 -1
- package/package.json +11 -9
package/dist/esm/index.js
CHANGED
|
@@ -42,4 +42,5 @@ export { Payments } from './resources/payments';
|
|
|
42
42
|
export { Recurring } from './resources/recurring';
|
|
43
43
|
export { BrandedSolution } from './resources/branded-solution';
|
|
44
44
|
export { Commissions } from './resources/commissions';
|
|
45
|
+
export * from './utils';
|
|
45
46
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,OAAO,KAAK;IAQhB,YAAY,MAAmB;QAC7B,IAAI,CAAC,M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AO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,cAAc,SAAS,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { SipayResource } from './base';
|
|
2
|
+
import { generatePaymentHashKey, generateStatusHashKey } from '../utils';
|
|
2
3
|
export class Payments extends SipayResource {
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Make a 2D payment (without 3D Secure authentication)
|
|
5
6
|
*/
|
|
6
7
|
async pay2D(paymentData, options) {
|
|
7
8
|
const data = this.addMerchantKey(paymentData);
|
|
9
|
+
// Generate hash key for payment
|
|
10
|
+
const hashKey = generatePaymentHashKey(data.total, data.installments_number || 1, data.currency_code, this.client['config'].merchantKey, data.invoice_id, this.client['config'].appSecret);
|
|
11
|
+
data.hash_key = hashKey;
|
|
8
12
|
return this.post('/api/paySmart2D', data, options);
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
@@ -30,6 +34,9 @@ export class Payments extends SipayResource {
|
|
|
30
34
|
*/
|
|
31
35
|
async checkStatus(statusData, options) {
|
|
32
36
|
const data = this.addMerchantKey(statusData);
|
|
37
|
+
// Generate hash key for status check
|
|
38
|
+
const hashKey = generateStatusHashKey(data.invoice_id, this.client['config'].merchantKey, this.client['config'].appSecret);
|
|
39
|
+
data.hash_key = hashKey;
|
|
33
40
|
return this.post('/api/checkstatus', data, options);
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../../src/resources/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../../src/resources/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAWvC,OAAO,EAAE,sBAAs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AAC,CAAC;QAE7C,qCAAqC;QACrC,MAAM,OAAO,GAAG,qBAAqB,CACnC,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAChC,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,UAA+C,EAC/C,OAAwB;QAExB,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CACP,WAAmD,EACnD,OAAwB;QAExB,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createHash, createCipheriv, createDecipheriv } from 'crypto';
|
|
2
2
|
/**
|
|
3
3
|
* Utility functions for Sipay SDK
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
6
|
-
* Generate hash key for payment requests
|
|
7
|
-
* Based on Sipay documentation requirements
|
|
8
|
-
*/
|
|
9
|
-
export function generateHashKey(merchantKey, invoiceId, amount, secretKey) {
|
|
10
|
-
const hashString = `${merchantKey}${invoiceId}${amount}${secretKey}`;
|
|
11
|
-
return crypto.createHash('sha256').update(hashString).digest('hex');
|
|
12
|
-
}
|
|
13
5
|
/**
|
|
14
6
|
* Validate credit card number using Luhn algorithm
|
|
15
7
|
*/
|
|
16
|
-
export function
|
|
17
|
-
const
|
|
18
|
-
// Check
|
|
19
|
-
if (
|
|
8
|
+
export function luhnCheck(cardNumber) {
|
|
9
|
+
const digits = cardNumber.replace(/\D/g, '').split('').map(Number);
|
|
10
|
+
// Check minimum length
|
|
11
|
+
if (digits.length < 13 || digits.length > 19) {
|
|
20
12
|
return false;
|
|
21
13
|
}
|
|
22
14
|
let sum = 0;
|
|
23
15
|
let isEven = false;
|
|
24
|
-
for (let i =
|
|
25
|
-
let digit =
|
|
16
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
17
|
+
let digit = digits[i];
|
|
26
18
|
if (isEven) {
|
|
27
19
|
digit *= 2;
|
|
28
20
|
if (digit > 9) {
|
|
@@ -35,11 +27,98 @@ export function validateCreditCard(cardNumber) {
|
|
|
35
27
|
return sum % 10 === 0;
|
|
36
28
|
}
|
|
37
29
|
/**
|
|
38
|
-
*
|
|
30
|
+
* Validate credit card number (alias for luhnCheck)
|
|
31
|
+
*/
|
|
32
|
+
export function validateCreditCard(cardNumber) {
|
|
33
|
+
return luhnCheck(cardNumber);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Mask credit card number for display
|
|
37
|
+
*/
|
|
38
|
+
export function maskCardNumber(cardNumber) {
|
|
39
|
+
const cleaned = cardNumber.replace(/\D/g, '');
|
|
40
|
+
if (cleaned.length < 8)
|
|
41
|
+
return cleaned;
|
|
42
|
+
const first4 = cleaned.slice(0, 4);
|
|
43
|
+
const last4 = cleaned.slice(-4);
|
|
44
|
+
const middle = '*'.repeat(cleaned.length - 8);
|
|
45
|
+
return `${first4}${middle}${last4}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Format amount for Sipay API - amounts should be sent as numbers, not cents
|
|
39
49
|
*/
|
|
40
50
|
export function formatAmount(amount) {
|
|
51
|
+
// Amount should be formatted as a float with proper decimal places
|
|
52
|
+
// For amounts like 100.00, it should be "100.00", not "1.00"
|
|
41
53
|
return amount.toFixed(2);
|
|
42
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Format amount specifically for hash key generation
|
|
57
|
+
* This should match PHP's format exactly: just the number as-is, no forced decimals
|
|
58
|
+
*/
|
|
59
|
+
export function formatAmountForHash(amount) {
|
|
60
|
+
// PHP uses: $total.'|' - which converts number to string without forcing decimal places
|
|
61
|
+
// For integer amounts like 10, PHP outputs "10", not "10.00"
|
|
62
|
+
// For decimal amounts like 10.5, PHP outputs "10.5", not "10.50"
|
|
63
|
+
return amount.toString();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Generate hash key for payment requests
|
|
67
|
+
* Order matches PHP SDK CreateNonSecurePaymentRequest::generateHashKeyParts():
|
|
68
|
+
* 1. total, 2. installments_number, 3. currency_code, 4. merchant_key, 5. invoice_id
|
|
69
|
+
*/
|
|
70
|
+
export function generatePaymentHashKey(total, installment, currencyCode, merchantKey, invoiceId, apiSecret) {
|
|
71
|
+
const parts = [
|
|
72
|
+
formatAmountForHash(total),
|
|
73
|
+
installment.toString(),
|
|
74
|
+
currencyCode,
|
|
75
|
+
merchantKey,
|
|
76
|
+
invoiceId,
|
|
77
|
+
];
|
|
78
|
+
return generateHashKey(parts, apiSecret);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generate hash key for status check requests
|
|
82
|
+
* Order matches PHP SDK CheckTransactionStatusRequest::generateHashKeyParts():
|
|
83
|
+
* 1. invoice_id, 2. merchant_key
|
|
84
|
+
*/
|
|
85
|
+
export function generateStatusHashKey(invoiceId, merchantKey, apiSecret) {
|
|
86
|
+
const parts = [invoiceId, merchantKey];
|
|
87
|
+
return generateHashKey(parts, apiSecret);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generate hash key for payment requests based on official Sipay documentation
|
|
91
|
+
* This matches exactly the official JavaScript implementation in sipayEn.yaml
|
|
92
|
+
*/
|
|
93
|
+
export function generateHashKey(parts, appSecret) {
|
|
94
|
+
try {
|
|
95
|
+
// Join parts with pipe separator - exactly like official: data = total + '|' + ...
|
|
96
|
+
const data = parts.join('|');
|
|
97
|
+
// Generate random IV - exactly like official: crypto.createHash('sha1').update(String(Math.random())).digest('hex').slice(0, 16)
|
|
98
|
+
const iv = createHash('sha1').update(String(Math.random())).digest('hex').slice(0, 16);
|
|
99
|
+
// Create password hash from app secret - exactly like official: crypto.createHash('sha1').update(app_secret).digest('hex')
|
|
100
|
+
const password = createHash('sha1').update(appSecret).digest('hex');
|
|
101
|
+
// Generate random salt - exactly like official: crypto.createHash('sha1').update(String(Math.random())).digest('hex').slice(0, 4)
|
|
102
|
+
const salt = createHash('sha1').update(String(Math.random())).digest('hex').slice(0, 4);
|
|
103
|
+
// Create salt with password - get full 32-byte key
|
|
104
|
+
const saltWithPasswordHash = createHash('sha256')
|
|
105
|
+
.update(password + salt)
|
|
106
|
+
.digest(); // Get Buffer directly, not hex string
|
|
107
|
+
// Encrypt data using AES-256-CBC - exactly like official implementation
|
|
108
|
+
const cipher = createCipheriv('aes-256-cbc', saltWithPasswordHash, // Use Buffer directly
|
|
109
|
+
Buffer.from(iv, 'ascii'));
|
|
110
|
+
// Official uses: cipher.update(padded_data, 'binary', 'base64'); cipher.final('base64');
|
|
111
|
+
let encrypted = cipher.update(data, 'binary', 'base64');
|
|
112
|
+
encrypted += cipher.final('base64');
|
|
113
|
+
// Format the final hash key - exactly like official: iv + ':' + salt + ':' + encrypted
|
|
114
|
+
const msgBundle = `${iv}:${salt}:${encrypted}`;
|
|
115
|
+
// Replace / with __ - exactly like official: msg_encrypted_bundle.replace('/', '__')
|
|
116
|
+
return msgBundle.replace(/\//g, '__');
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw new Error(`Hash key generation failed: ${error}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
43
122
|
/**
|
|
44
123
|
* Generate a unique invoice ID
|
|
45
124
|
*/
|
|
@@ -133,4 +212,63 @@ export function parseSipayError(error) {
|
|
|
133
212
|
message: error.message || 'Network error',
|
|
134
213
|
};
|
|
135
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Validate hash key using server-side validation logic
|
|
217
|
+
* This matches exactly what the PHP SDK does for server-side validation
|
|
218
|
+
* Expected decrypted format: status|total|invoiceId|orderId|currencyCode
|
|
219
|
+
*/
|
|
220
|
+
export function validateHashKey(hashKey, secretKey) {
|
|
221
|
+
let status = '';
|
|
222
|
+
let currencyCode = '';
|
|
223
|
+
let total = 0;
|
|
224
|
+
let invoiceId = '';
|
|
225
|
+
let orderId = 0;
|
|
226
|
+
if (!hashKey) {
|
|
227
|
+
return [status, total, invoiceId, orderId, currencyCode];
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
// Replace underscores with forward slashes (PHP compatibility)
|
|
231
|
+
const normalizedHashKey = hashKey.replace(/_/g, '/');
|
|
232
|
+
const password = createHash('sha1').update(secretKey).digest('hex');
|
|
233
|
+
const components = normalizedHashKey.split(':');
|
|
234
|
+
if (components.length > 2) {
|
|
235
|
+
const iv = components[0] || '';
|
|
236
|
+
const saltHex = components[1] || '';
|
|
237
|
+
const encryptedMsg = components[2] || '';
|
|
238
|
+
// Generate salt exactly like PHP: hash('sha256', $password . $salt)
|
|
239
|
+
const saltWithPassword = createHash('sha256')
|
|
240
|
+
.update(password + saltHex)
|
|
241
|
+
.digest('hex');
|
|
242
|
+
// Create decipher with proper parameters
|
|
243
|
+
// PHP's openssl_decrypt expects:
|
|
244
|
+
// - IV as raw ASCII bytes (16-char hex string treated as ASCII)
|
|
245
|
+
// - Key as binary from hex string (32 bytes for AES-256)
|
|
246
|
+
const decipher = createDecipheriv('aes-256-cbc', Buffer.from(saltWithPassword, 'hex').slice(0, 32), // 32-byte key from hex
|
|
247
|
+
Buffer.from(iv, 'ascii') // IV: 16-char hex string as ASCII bytes
|
|
248
|
+
);
|
|
249
|
+
let decrypted = decipher.update(encryptedMsg, 'base64', 'utf8');
|
|
250
|
+
decrypted += decipher.final('utf8');
|
|
251
|
+
if (decrypted.includes('|')) {
|
|
252
|
+
const array = decrypted.split('|');
|
|
253
|
+
status = array[0] || '0';
|
|
254
|
+
total = parseFloat(array[1] || '0');
|
|
255
|
+
invoiceId = array[2] || '0';
|
|
256
|
+
orderId = parseInt(array[3] || '0');
|
|
257
|
+
currencyCode = array[4] || '';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
// Silently handle decryption errors
|
|
263
|
+
}
|
|
264
|
+
return [status, total, invoiceId, orderId, currencyCode];
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Generate hash key in server validation format
|
|
268
|
+
* Server expects: status|total|invoiceId|orderId|currencyCode
|
|
269
|
+
*/
|
|
270
|
+
export function generateServerFormatHashKey(status, total, invoiceId, orderId, currencyCode, appSecret) {
|
|
271
|
+
const parts = [status, formatAmountForHash(total), invoiceId, orderId.toString(), currencyCode];
|
|
272
|
+
return generateHashKey(parts, appSecret);
|
|
273
|
+
}
|
|
136
274
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEtE;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,UAAkB;IAC1C,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEnE,uBAAuB;IACvB,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,MAAM,CAAC,M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AAE,CAAC;gBAC5B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;gBACzB,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;gBACpC,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;gBAC5B,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;gBACpC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oCAAoC;IACtC,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAc,EACd,KAAa,EACb,SAAiB,EACjB,OAAe,EACf,YAAoB,EACpB,SAAiB;IAEjB,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC,CAAC;IAEhG,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -32,4 +32,5 @@ export { Payments } from './resources/payments';
|
|
|
32
32
|
export { Recurring } from './resources/recurring';
|
|
33
33
|
export { BrandedSolution } from './resources/branded-solution';
|
|
34
34
|
export { Commissions } from './resources/commissions';
|
|
35
|
+
export * from './utils';
|
|
35
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"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CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAkB;IAEzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC;gBAEpB,MAAM,EAAE,WAAW;IAU/B;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;OAEG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAG9B;AAGD,eAAe,KAAK,CAAC;AAGrB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -66,4 +66,5 @@ var branded_solution_2 = require("./resources/branded-solution");
|
|
|
66
66
|
Object.defineProperty(exports, "BrandedSolution", { enumerable: true, get: function () { return branded_solution_2.BrandedSolution; } });
|
|
67
67
|
var commissions_2 = require("./resources/commissions");
|
|
68
68
|
Object.defineProperty(exports, "Commissions", { enumerable: true, get: function () { return commissions_2.Commissions; } });
|
|
69
|
+
__exportStar(require("./utils"), exports);
|
|
69
70
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1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e,OAAA;AACxB,uDAAsD;AAA7C,0GAAA,WAAW,OAAA;AACpB,0CAAwB"}
|
|
@@ -2,9 +2,9 @@ import { SipayResource } from './base';
|
|
|
2
2
|
import { Payment2DRequest, Payment3DRequest, GetPosRequest, PosInfo, SipayApiResponse, RequestOptions, OrderStatusRequest, RefundRequest } from '../types';
|
|
3
3
|
export declare class Payments extends SipayResource {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Make a 2D payment (without 3D Secure authentication)
|
|
6
6
|
*/
|
|
7
|
-
pay2D(paymentData: Omit<Payment2DRequest, 'merchant_key'>, options?: RequestOptions): Promise<SipayApiResponse>;
|
|
7
|
+
pay2D(paymentData: Omit<Payment2DRequest, 'merchant_key' | 'hash_key'>, options?: RequestOptions): Promise<SipayApiResponse>;
|
|
8
8
|
/**
|
|
9
9
|
* Process a 3D payment (with 3D Secure authentication)
|
|
10
10
|
* Returns HTML form that should be rendered and auto-submitted
|
|
@@ -17,7 +17,7 @@ export declare class Payments extends SipayResource {
|
|
|
17
17
|
/**
|
|
18
18
|
* Check the status of a payment
|
|
19
19
|
*/
|
|
20
|
-
checkStatus(statusData: Omit<OrderStatusRequest, 'merchant_key'>, options?: RequestOptions): Promise<SipayApiResponse>;
|
|
20
|
+
checkStatus(statusData: Omit<OrderStatusRequest, 'merchant_key' | 'hash_key'>, options?: RequestOptions): Promise<SipayApiResponse>;
|
|
21
21
|
/**
|
|
22
22
|
* Refund a payment
|
|
23
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../src/resources/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACd,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pay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ineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Payments = void 0;
|
|
4
4
|
const base_1 = require("./base");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
5
6
|
class Payments extends base_1.SipayResource {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Make a 2D payment (without 3D Secure authentication)
|
|
8
9
|
*/
|
|
9
10
|
async pay2D(paymentData, options) {
|
|
10
11
|
const data = this.addMerchantKey(paymentData);
|
|
12
|
+
// Generate hash key for payment
|
|
13
|
+
const hashKey = (0, utils_1.generatePaymentHashKey)(data.total, data.installments_number || 1, data.currency_code, this.client['config'].merchantKey, data.invoice_id, this.client['config'].appSecret);
|
|
14
|
+
data.hash_key = hashKey;
|
|
11
15
|
return this.post('/api/paySmart2D', data, options);
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
@@ -33,6 +37,9 @@ class Payments extends base_1.SipayResource {
|
|
|
33
37
|
*/
|
|
34
38
|
async checkStatus(statusData, options) {
|
|
35
39
|
const data = this.addMerchantKey(statusData);
|
|
40
|
+
// Generate hash key for status check
|
|
41
|
+
const hashKey = (0, utils_1.generateStatusHashKey)(data.invoice_id, this.client['config'].merchantKey, this.client['config'].appSecret);
|
|
42
|
+
data.hash_key = hashKey;
|
|
36
43
|
return this.post('/api/checkstatus', data, options);
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/resources/payments.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/resources/payments.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;AAWvC,oCAAyE;AAEzE,MAAa,QAAS,SAAQ,oBAAa;IACzC;;OAEG;IACH,KAAK,CAAC,KAAK,CACT,WAAgE,EAChE,OAAwB;QAExB,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAE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CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,UAA+C,EAC/C,OAAwB;QAExB,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CACP,WAAmD,EACnD,OAAwB;QAExB,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF;AA7FD,4BA6FC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,18 +2,43 @@
|
|
|
2
2
|
* Utility functions for Sipay SDK
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Based on Sipay documentation requirements
|
|
5
|
+
* Validate credit card number using Luhn algorithm
|
|
7
6
|
*/
|
|
8
|
-
export declare function
|
|
7
|
+
export declare function luhnCheck(cardNumber: string): boolean;
|
|
9
8
|
/**
|
|
10
|
-
* Validate credit card number
|
|
9
|
+
* Validate credit card number (alias for luhnCheck)
|
|
11
10
|
*/
|
|
12
11
|
export declare function validateCreditCard(cardNumber: string): boolean;
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Mask credit card number for display
|
|
14
|
+
*/
|
|
15
|
+
export declare function maskCardNumber(cardNumber: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format amount for Sipay API - amounts should be sent as numbers, not cents
|
|
15
18
|
*/
|
|
16
19
|
export declare function formatAmount(amount: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format amount specifically for hash key generation
|
|
22
|
+
* This should match PHP's format exactly: just the number as-is, no forced decimals
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatAmountForHash(amount: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate hash key for payment requests
|
|
27
|
+
* Order matches PHP SDK CreateNonSecurePaymentRequest::generateHashKeyParts():
|
|
28
|
+
* 1. total, 2. installments_number, 3. currency_code, 4. merchant_key, 5. invoice_id
|
|
29
|
+
*/
|
|
30
|
+
export declare function generatePaymentHashKey(total: number, installment: number, currencyCode: string, merchantKey: string, invoiceId: string, apiSecret: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate hash key for status check requests
|
|
33
|
+
* Order matches PHP SDK CheckTransactionStatusRequest::generateHashKeyParts():
|
|
34
|
+
* 1. invoice_id, 2. merchant_key
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateStatusHashKey(invoiceId: string, merchantKey: string, apiSecret: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate hash key for payment requests based on official Sipay documentation
|
|
39
|
+
* This matches exactly the official JavaScript implementation in sipayEn.yaml
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateHashKey(parts: (string | number)[], appSecret: string): string;
|
|
17
42
|
/**
|
|
18
43
|
* Generate a unique invoice ID
|
|
19
44
|
*/
|
|
@@ -33,4 +58,15 @@ export declare function parseSipayError(error: any): {
|
|
|
33
58
|
code: number;
|
|
34
59
|
message: string;
|
|
35
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Validate hash key using server-side validation logic
|
|
63
|
+
* This matches exactly what the PHP SDK does for server-side validation
|
|
64
|
+
* Expected decrypted format: status|total|invoiceId|orderId|currencyCode
|
|
65
|
+
*/
|
|
66
|
+
export declare function validateHashKey(hashKey: string, secretKey: string): [string, number, string, number, string];
|
|
67
|
+
/**
|
|
68
|
+
* Generate hash key in server validation format
|
|
69
|
+
* Server expects: status|total|invoiceId|orderId|currencyCode
|
|
70
|
+
*/
|
|
71
|
+
export declare function generateServerFormatHashKey(status: string, total: number, invoiceId: string, orderId: number, currencyCode: string, appSecret: string): string;
|
|
36
72
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CA0BrD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CASzD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAInD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,MAAM,CAIR;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAsCrF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,SAAQ,GAAG,MAAM,CAIxD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,EAAE,CAsDvD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAmBzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAa7E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAsD1C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,MAAM,CAIR"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,70 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
3
|
+
exports.luhnCheck = luhnCheck;
|
|
37
4
|
exports.validateCreditCard = validateCreditCard;
|
|
5
|
+
exports.maskCardNumber = maskCardNumber;
|
|
38
6
|
exports.formatAmount = formatAmount;
|
|
7
|
+
exports.formatAmountForHash = formatAmountForHash;
|
|
8
|
+
exports.generatePaymentHashKey = generatePaymentHashKey;
|
|
9
|
+
exports.generateStatusHashKey = generateStatusHashKey;
|
|
10
|
+
exports.generateHashKey = generateHashKey;
|
|
39
11
|
exports.generateInvoiceId = generateInvoiceId;
|
|
40
12
|
exports.validatePaymentData = validatePaymentData;
|
|
41
13
|
exports.maskCreditCard = maskCreditCard;
|
|
42
14
|
exports.parseSipayError = parseSipayError;
|
|
43
|
-
|
|
15
|
+
exports.validateHashKey = validateHashKey;
|
|
16
|
+
exports.generateServerFormatHashKey = generateServerFormatHashKey;
|
|
17
|
+
const crypto_1 = require("crypto");
|
|
44
18
|
/**
|
|
45
19
|
* Utility functions for Sipay SDK
|
|
46
20
|
*/
|
|
47
|
-
/**
|
|
48
|
-
* Generate hash key for payment requests
|
|
49
|
-
* Based on Sipay documentation requirements
|
|
50
|
-
*/
|
|
51
|
-
function generateHashKey(merchantKey, invoiceId, amount, secretKey) {
|
|
52
|
-
const hashString = `${merchantKey}${invoiceId}${amount}${secretKey}`;
|
|
53
|
-
return crypto.createHash('sha256').update(hashString).digest('hex');
|
|
54
|
-
}
|
|
55
21
|
/**
|
|
56
22
|
* Validate credit card number using Luhn algorithm
|
|
57
23
|
*/
|
|
58
|
-
function
|
|
59
|
-
const
|
|
60
|
-
// Check
|
|
61
|
-
if (
|
|
24
|
+
function luhnCheck(cardNumber) {
|
|
25
|
+
const digits = cardNumber.replace(/\D/g, '').split('').map(Number);
|
|
26
|
+
// Check minimum length
|
|
27
|
+
if (digits.length < 13 || digits.length > 19) {
|
|
62
28
|
return false;
|
|
63
29
|
}
|
|
64
30
|
let sum = 0;
|
|
65
31
|
let isEven = false;
|
|
66
|
-
for (let i =
|
|
67
|
-
let digit =
|
|
32
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
33
|
+
let digit = digits[i];
|
|
68
34
|
if (isEven) {
|
|
69
35
|
digit *= 2;
|
|
70
36
|
if (digit > 9) {
|
|
@@ -77,11 +43,98 @@ function validateCreditCard(cardNumber) {
|
|
|
77
43
|
return sum % 10 === 0;
|
|
78
44
|
}
|
|
79
45
|
/**
|
|
80
|
-
*
|
|
46
|
+
* Validate credit card number (alias for luhnCheck)
|
|
47
|
+
*/
|
|
48
|
+
function validateCreditCard(cardNumber) {
|
|
49
|
+
return luhnCheck(cardNumber);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mask credit card number for display
|
|
53
|
+
*/
|
|
54
|
+
function maskCardNumber(cardNumber) {
|
|
55
|
+
const cleaned = cardNumber.replace(/\D/g, '');
|
|
56
|
+
if (cleaned.length < 8)
|
|
57
|
+
return cleaned;
|
|
58
|
+
const first4 = cleaned.slice(0, 4);
|
|
59
|
+
const last4 = cleaned.slice(-4);
|
|
60
|
+
const middle = '*'.repeat(cleaned.length - 8);
|
|
61
|
+
return `${first4}${middle}${last4}`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Format amount for Sipay API - amounts should be sent as numbers, not cents
|
|
81
65
|
*/
|
|
82
66
|
function formatAmount(amount) {
|
|
67
|
+
// Amount should be formatted as a float with proper decimal places
|
|
68
|
+
// For amounts like 100.00, it should be "100.00", not "1.00"
|
|
83
69
|
return amount.toFixed(2);
|
|
84
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Format amount specifically for hash key generation
|
|
73
|
+
* This should match PHP's format exactly: just the number as-is, no forced decimals
|
|
74
|
+
*/
|
|
75
|
+
function formatAmountForHash(amount) {
|
|
76
|
+
// PHP uses: $total.'|' - which converts number to string without forcing decimal places
|
|
77
|
+
// For integer amounts like 10, PHP outputs "10", not "10.00"
|
|
78
|
+
// For decimal amounts like 10.5, PHP outputs "10.5", not "10.50"
|
|
79
|
+
return amount.toString();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Generate hash key for payment requests
|
|
83
|
+
* Order matches PHP SDK CreateNonSecurePaymentRequest::generateHashKeyParts():
|
|
84
|
+
* 1. total, 2. installments_number, 3. currency_code, 4. merchant_key, 5. invoice_id
|
|
85
|
+
*/
|
|
86
|
+
function generatePaymentHashKey(total, installment, currencyCode, merchantKey, invoiceId, apiSecret) {
|
|
87
|
+
const parts = [
|
|
88
|
+
formatAmountForHash(total),
|
|
89
|
+
installment.toString(),
|
|
90
|
+
currencyCode,
|
|
91
|
+
merchantKey,
|
|
92
|
+
invoiceId,
|
|
93
|
+
];
|
|
94
|
+
return generateHashKey(parts, apiSecret);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generate hash key for status check requests
|
|
98
|
+
* Order matches PHP SDK CheckTransactionStatusRequest::generateHashKeyParts():
|
|
99
|
+
* 1. invoice_id, 2. merchant_key
|
|
100
|
+
*/
|
|
101
|
+
function generateStatusHashKey(invoiceId, merchantKey, apiSecret) {
|
|
102
|
+
const parts = [invoiceId, merchantKey];
|
|
103
|
+
return generateHashKey(parts, apiSecret);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Generate hash key for payment requests based on official Sipay documentation
|
|
107
|
+
* This matches exactly the official JavaScript implementation in sipayEn.yaml
|
|
108
|
+
*/
|
|
109
|
+
function generateHashKey(parts, appSecret) {
|
|
110
|
+
try {
|
|
111
|
+
// Join parts with pipe separator - exactly like official: data = total + '|' + ...
|
|
112
|
+
const data = parts.join('|');
|
|
113
|
+
// Generate random IV - exactly like official: crypto.createHash('sha1').update(String(Math.random())).digest('hex').slice(0, 16)
|
|
114
|
+
const iv = (0, crypto_1.createHash)('sha1').update(String(Math.random())).digest('hex').slice(0, 16);
|
|
115
|
+
// Create password hash from app secret - exactly like official: crypto.createHash('sha1').update(app_secret).digest('hex')
|
|
116
|
+
const password = (0, crypto_1.createHash)('sha1').update(appSecret).digest('hex');
|
|
117
|
+
// Generate random salt - exactly like official: crypto.createHash('sha1').update(String(Math.random())).digest('hex').slice(0, 4)
|
|
118
|
+
const salt = (0, crypto_1.createHash)('sha1').update(String(Math.random())).digest('hex').slice(0, 4);
|
|
119
|
+
// Create salt with password - get full 32-byte key
|
|
120
|
+
const saltWithPasswordHash = (0, crypto_1.createHash)('sha256')
|
|
121
|
+
.update(password + salt)
|
|
122
|
+
.digest(); // Get Buffer directly, not hex string
|
|
123
|
+
// Encrypt data using AES-256-CBC - exactly like official implementation
|
|
124
|
+
const cipher = (0, crypto_1.createCipheriv)('aes-256-cbc', saltWithPasswordHash, // Use Buffer directly
|
|
125
|
+
Buffer.from(iv, 'ascii'));
|
|
126
|
+
// Official uses: cipher.update(padded_data, 'binary', 'base64'); cipher.final('base64');
|
|
127
|
+
let encrypted = cipher.update(data, 'binary', 'base64');
|
|
128
|
+
encrypted += cipher.final('base64');
|
|
129
|
+
// Format the final hash key - exactly like official: iv + ':' + salt + ':' + encrypted
|
|
130
|
+
const msgBundle = `${iv}:${salt}:${encrypted}`;
|
|
131
|
+
// Replace / with __ - exactly like official: msg_encrypted_bundle.replace('/', '__')
|
|
132
|
+
return msgBundle.replace(/\//g, '__');
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
throw new Error(`Hash key generation failed: ${error}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
85
138
|
/**
|
|
86
139
|
* Generate a unique invoice ID
|
|
87
140
|
*/
|
|
@@ -175,4 +228,63 @@ function parseSipayError(error) {
|
|
|
175
228
|
message: error.message || 'Network error',
|
|
176
229
|
};
|
|
177
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Validate hash key using server-side validation logic
|
|
233
|
+
* This matches exactly what the PHP SDK does for server-side validation
|
|
234
|
+
* Expected decrypted format: status|total|invoiceId|orderId|currencyCode
|
|
235
|
+
*/
|
|
236
|
+
function validateHashKey(hashKey, secretKey) {
|
|
237
|
+
let status = '';
|
|
238
|
+
let currencyCode = '';
|
|
239
|
+
let total = 0;
|
|
240
|
+
let invoiceId = '';
|
|
241
|
+
let orderId = 0;
|
|
242
|
+
if (!hashKey) {
|
|
243
|
+
return [status, total, invoiceId, orderId, currencyCode];
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
// Replace underscores with forward slashes (PHP compatibility)
|
|
247
|
+
const normalizedHashKey = hashKey.replace(/_/g, '/');
|
|
248
|
+
const password = (0, crypto_1.createHash)('sha1').update(secretKey).digest('hex');
|
|
249
|
+
const components = normalizedHashKey.split(':');
|
|
250
|
+
if (components.length > 2) {
|
|
251
|
+
const iv = components[0] || '';
|
|
252
|
+
const saltHex = components[1] || '';
|
|
253
|
+
const encryptedMsg = components[2] || '';
|
|
254
|
+
// Generate salt exactly like PHP: hash('sha256', $password . $salt)
|
|
255
|
+
const saltWithPassword = (0, crypto_1.createHash)('sha256')
|
|
256
|
+
.update(password + saltHex)
|
|
257
|
+
.digest('hex');
|
|
258
|
+
// Create decipher with proper parameters
|
|
259
|
+
// PHP's openssl_decrypt expects:
|
|
260
|
+
// - IV as raw ASCII bytes (16-char hex string treated as ASCII)
|
|
261
|
+
// - Key as binary from hex string (32 bytes for AES-256)
|
|
262
|
+
const decipher = (0, crypto_1.createDecipheriv)('aes-256-cbc', Buffer.from(saltWithPassword, 'hex').slice(0, 32), // 32-byte key from hex
|
|
263
|
+
Buffer.from(iv, 'ascii') // IV: 16-char hex string as ASCII bytes
|
|
264
|
+
);
|
|
265
|
+
let decrypted = decipher.update(encryptedMsg, 'base64', 'utf8');
|
|
266
|
+
decrypted += decipher.final('utf8');
|
|
267
|
+
if (decrypted.includes('|')) {
|
|
268
|
+
const array = decrypted.split('|');
|
|
269
|
+
status = array[0] || '0';
|
|
270
|
+
total = parseFloat(array[1] || '0');
|
|
271
|
+
invoiceId = array[2] || '0';
|
|
272
|
+
orderId = parseInt(array[3] || '0');
|
|
273
|
+
currencyCode = array[4] || '';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
// Silently handle decryption errors
|
|
279
|
+
}
|
|
280
|
+
return [status, total, invoiceId, orderId, currencyCode];
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Generate hash key in server validation format
|
|
284
|
+
* Server expects: status|total|invoiceId|orderId|currencyCode
|
|
285
|
+
*/
|
|
286
|
+
function generateServerFormatHashKey(status, total, invoiceId, orderId, currencyCode, appSecret) {
|
|
287
|
+
const parts = [status, formatAmountForHash(total), invoiceId, orderId.toString(), currencyCode];
|
|
288
|
+
return generateHashKey(parts, appSecret);
|
|
289
|
+
}
|
|
178
290
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["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,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC,CAAC;IAEhG,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muhammedaksam/sipay-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Node.js TypeScript SDK for Sipay payment gateway",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,22 +35,22 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/muhammedaksam/sipay-node#readme",
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@eslint/js": "^9.
|
|
38
|
+
"@eslint/js": "^9.36.0",
|
|
39
39
|
"@types/jest": "^30.0.0",
|
|
40
|
-
"@types/node": "^24.
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
42
|
-
"@typescript-eslint/parser": "^8.
|
|
43
|
-
"eslint": "^9.
|
|
44
|
-
"jest": "^30.
|
|
40
|
+
"@types/node": "^24.5.2",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
42
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
43
|
+
"eslint": "^9.36.0",
|
|
44
|
+
"jest": "^30.1.3",
|
|
45
45
|
"prettier": "^3.6.2",
|
|
46
46
|
"rimraf": "^6.0.1",
|
|
47
|
-
"ts-jest": "^29.4.
|
|
47
|
+
"ts-jest": "^29.4.4",
|
|
48
48
|
"ts-node": "^10.9.2",
|
|
49
49
|
"tsx": "^4.20.5",
|
|
50
50
|
"typescript": "^5.9.2"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"axios": "^1.
|
|
53
|
+
"axios": "^1.12.2"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=18"
|
|
@@ -64,6 +64,8 @@
|
|
|
64
64
|
"test": "jest",
|
|
65
65
|
"test:watch": "jest --watch",
|
|
66
66
|
"test:coverage": "jest --coverage",
|
|
67
|
+
"test:integration": "npx tsx test/integration/test-runner.ts",
|
|
68
|
+
"test:final": "npx tsx examples/final-payment-test.ts",
|
|
67
69
|
"lint": "eslint src test examples --ext .ts",
|
|
68
70
|
"lint:fix": "eslint src test examples --ext .ts --fix",
|
|
69
71
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"examples/**/*.ts\"",
|