-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-payment.js
More file actions
49 lines (46 loc) · 1.41 KB
/
Copy pathtest-payment.js
File metadata and controls
49 lines (46 loc) · 1.41 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
async function run() {
try {
const loginRes = await fetch('http://localhost:3001/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'testuser99@gmail.com',
password: 'password123'
})
});
const login = await loginRes.json();
if (!login.accessToken) {
console.log("Login failed", login);
return;
}
console.log("Logged in");
const orderRes = await fetch('http://localhost:3001/api/payment/create-order', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${login.accessToken}`
},
body: JSON.stringify({ tier: 'PRO' })
});
const orderData = await orderRes.json();
console.log("Order created:", orderData);
const verifyRes = await fetch('http://localhost:3001/api/payment/verify-payment', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${login.accessToken}`
},
body: JSON.stringify({
tier: 'PRO',
razorpay_order_id: orderData.orderId,
razorpay_payment_id: "pay_mock_" + Date.now(),
razorpay_signature: "signature_mock"
})
});
const verifyData = await verifyRes.json();
console.log("Verify result:", verifyData);
} catch (e) {
console.log(e.message);
}
}
run();