npm install
const mugglepay = require('./mugglepay')
const MugglepayClient = mugglepay.MugglepayClient
const apiKey = 'your_api_key'; # put your api key here
const mgp = new MugglepayClient(apiKey);
newOrder = {
'merchant_order_id': 'test_order_id',
'title': 'Monthly Program x 2',
'description': 'test python',
'price_amount': 0.01,
'price_currency': 'USD',
'pay_currency': 'CNY',
'callback_url': 'https://{your_host}/mugglepay_callback_api', // replace { your_host } with your own host where you deployed callback server, example your_host:http://123.123.123.12:2340
'cancel_url': 'https://{your_host}/mugglepay?status=cancel',
'success_url': 'https://{your_host}/mugglepay?status=cancel',
'mobile': false,
'fast': false,
'token': 'test12345'
}
res = mgp.create_order(
newOrder,
function (body) {
console.log(body)
order = body['order']
console.log(order)
}
);
mgp.get_order(orderId, function (body) {
console.log(body)
})
mgp.get_orders('NEW', 10, 0, function (body) {
console.log(body)
})
mgp.checkout_order(orderId, 'USD', function (body) {
console.log(body)
})
node callback_server.js
You need deploy this server online in order to get mugglepay official callback request. Make sure you put correct callback_url when you try to create an order.
- First click on the Sign Up address above
- Sign InMugglePay Portal
- Choose"Developer Center"->“API”->“Use on backend server”,click“Add Key”,Get ur Key。
- replace
apiKey
in mugglepay.js with your key