forked from RapydPayments/rapyd-request-signatures
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
57 lines (45 loc) · 1.2 KB
/
app.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
/**
* Rapyd Integrations: Request Signature.
*
* This app implements the Rapyd's API request signature. The crypto-js library
* is required (https://www.npmjs.com/package/crypto-js). To install it, run:
*
* npm install crypto-js
*
* @link https://docs.rapyd.net/
* @file This files defines the main node.js application.
* @author Isaac Benitez.
* @version 0.0.1
*
* @requires express
* @requires https
* @requires crypto-js
*/
const express = require('express');
const makeRequest = require('./utilities').makeRequest;
const app = express();
app.set('json spaces', 4);
app.listen(3000);
app.get('/country', async (req, res) => {
try {
const result = await makeRequest('GET', '/v1/payment_methods/country?country=mx');
res.json(result);
} catch (error) {
res.json(error);
}
})
app.get('/payment', async (req, res) => {
try {
const body = {
amount: 230,
currency: 'MXN',
payment_method: {
type: 'mx_diestel_cash'
}
};
const result = await makeRequest('POST', '/v1/payments', body);
res.json(result);
} catch (error) {
res.json(error);
}
})