-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnexio-form-backend.js
63 lines (60 loc) · 1.81 KB
/
nexio-form-backend.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
const express = require('express');
const app = express();
const port = 3000;
const cors = require('cors');
const fetch = require('node-fetch');
console.log('------->loading' );
app.use(cors());
app.get('/', (req, res) => {
return getOneTimeUseFunction().then((response) => {
return res.json(response);
})
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});
let otuRequest = {
"data": {
"customer": {
"firstName": "Rocky",
"lastName": "Squirrel",
"phone": "5555551234",
"email": "[email protected]",
"billToAddressOne": "123 Test St",
"billToAddressTwo": "Suite 123",
"billToCity": "Testerville",
"billToState": "UT",
"billToPostal": "12345",
"billToCountry": "US",
"billToPhone": "8015551234",
"shipToAddressOne": "123 Ship St",
"shipToAddressTwo": "Warehouse 456",
"shipToCity": "Shipperville",
"shipToState": "OR",
"shipToPostal": "67890",
"shipToCountry": "US",
"shipToPhone": "5033335678"
}
},
"uiOptions": {
"displaySubmitButton": true,
"useLegacyIframe": false,
"hideCvc": false,
"requireCvc": true,
"hideBilling": false,
"forceExpirationSelection": true
}
};
function getOneTimeUseFunction() {
return fetch('https://api.nexiopaysandbox.com/pay/v3/token', {
method: 'post',
body: JSON.stringify(otuRequest),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic eW91clVzZXJOYW1lOnlvdXJQYXNzd29yZA=='
}
}).then((res) => {
console.log('------->res', res);
return res.json();
})
};