-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-linkurl-format.js
More file actions
58 lines (50 loc) · 1.87 KB
/
Copy pathtest-linkurl-format.js
File metadata and controls
58 lines (50 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const axios = require('axios');
async function testLinkUrlFormat() {
try {
console.log('Testing payment link URL format...');
const response = await axios.post('http://localhost:4000/api/v1/payment-links', {
merchantId: 'test-merchant-url',
userId: 'test-user-url',
name: 'Test Link URL Format',
amount: '50.00',
currency: 'USD',
token: 'USDT',
selectedCurrency: 'USD',
paymentType: 'card',
description: 'Testing URL format'
});
const paymentLink = response.data.data;
console.log('✅ Payment link created successfully');
console.log('ID:', paymentLink.id);
console.log('Link URL:', paymentLink.linkUrl);
console.log('Success URL:', paymentLink.successUrl);
// Verify the URL format
const expectedLinkUrl = `https://chainpaye.com/payment/${paymentLink.id}`;
const expectedSuccessUrl = 'https://chainpaye.com/';
if (paymentLink.linkUrl === expectedLinkUrl) {
console.log('✅ Link URL format is correct');
} else {
console.log('❌ Link URL format is incorrect');
console.log('Expected:', expectedLinkUrl);
console.log('Actual:', paymentLink.linkUrl);
}
if (paymentLink.successUrl === expectedSuccessUrl) {
console.log('✅ Success URL format is correct');
} else {
console.log('❌ Success URL format is incorrect');
console.log('Expected:', expectedSuccessUrl);
console.log('Actual:', paymentLink.successUrl);
}
} catch (error) {
console.error('❌ Test failed:');
if (error.response) {
console.error('Status:', error.response.status);
console.error('Data:', JSON.stringify(error.response.data, null, 2));
} else if (error.request) {
console.error('No response received:', error.message);
} else {
console.error('Error:', error.message);
}
}
}
testLinkUrlFormat();