-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
75 lines (61 loc) · 2.16 KB
/
index.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const got = require('got');
const axios = require('axios');
const qs = require('qs');
// const fetch = require('node-fetch');
//var FormData = require('form-data');
//module.exports.request = async (method, url, urlParams, post_body) => {
let post_body = {};
post_body['store_id'] = 'abc5ee5f6e3c9c73';
post_body['store_passwd'] = 'abc5ee5f6e3c9c73@ssl';
post_body['total_amount'] = 100.26;
post_body['currency'] = "BDT";
post_body['tran_id'] = "1234";
post_body['success_url'] = "https://tigrow.herokuapp.com";
post_body['fail_url'] = "your fail url";
post_body['cancel_url'] = "your cancel url";
post_body['emi_option'] = 0;
post_body['cus_name'] = "nizam";
post_body['cus_email'] = "[email protected]";
post_body['cus_phone'] = "01700000000";
post_body['cus_add1'] = "customer address";
post_body['cus_city'] = "Dhaka";
post_body['cus_country'] = "Bangladesh";
post_body['shipping_method'] = "NO";
post_body['multi_card_name'] = ""
post_body['num_of_item'] = 1;
post_body['product_name'] = "Test";
post_body['product_category'] = "Test Category";
post_body['product_profile'] = "general";
//fetch
// let fdata = new FormData();
// for(const a in post_body) {
// fdata.append(a, post_body[a] ? post_body[a] : '');
// }
const urlParams = null;
const url = 'https://sandbox.sslcommerz.com/gwprocess/v4/api.php';
async function start() {
try{
let params = {
method: 'POST',
form: post_body ,
responseType: 'json'
};
// params.searchParams = urlParams ? urlParams : undefined;
params.form = post_body ? post_body : undefined;
// const response = await got(url, params);
//console.log(response.body);
const response = await axios(url, {method: 'POST', data: qs.stringify(post_body)});
console.log(response.data);
//fetch
// fetch(url, {method: 'POST', body: fdata})
// .then(function(u){
// return u.json();
// })
// .then(function(j) {
// console.log(1,j);
// });
} catch(error){
console.log(error) ;
}
}
start();