-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcallback_server.js
41 lines (36 loc) · 1.78 KB
/
callback_server.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
/*
* @Author: fay
* @Date: 2021-03-02 09:49:52
* @LastEditTime: 2021-03-02 12:00:52
* @LastEditors: Please set LastEditors
* @Description: mugglepay callback server example
* @FilePath: /mugglepay-nodejs-sdk/callback_server.js
*/
const express = require('express')
const bodyParser = require('body-parser');
const app = express()
const port = 3000
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());
app.post('/mugglepay_callback_api', (req, res) => {
console.log(req.body)
// example callback request body
// {
// order_id: '1233213', MugglePay order ID
// merchant_order_id: '3213213', Order ID of the merchant. Should be used to identify order or invoice.
// status: 'PAID', MugglePay payment status.
// price_amount: 12, The price set by the merchant; Example: 9.99
// price_currency: 'USD', Currency in which the merchant\'s goods/services are priced; Example: USD
// created_at: '2019-04-24T17:23:54.311Z', Invoice creation time; Example: \'2019-04-24T17:23:54.311Z
// created_at_t: '1556126634311', Your token provided by CreateOrder to validate Payment Callback
// token: 'test token', Your token provided by CreateOrder api to validate Payment Callback.
// <<token field is generated by merchant.you can compare your own token with this token field to make sure you get callback from real mugglepay service.
// The token validation try to avoid fake callback request from others.>>
// meta: {} provide third party information. e.g. Alipay or WechatPay. An example of Alipay is provided as example.
// }
res.send('callback done')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})