Created
September 8, 2023 02:43
-
-
Save rickithadi/9e6bf4f7ee854812229064f2ea5c0a98 to your computer and use it in GitHub Desktop.
endpoint to create durianpay order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post("/create-order", (req, res) => { | |
// const { order_ref_id, customer_ref_id, email, amount } = req.body; | |
console.log(req.body); | |
const { | |
order_ref_id, | |
customer_ref_id, | |
email, | |
amount, | |
lobbyImage, | |
lineItemText, | |
metadata, | |
} = req.body; | |
var options = { | |
amount, | |
currency: "IDR", | |
metadata, | |
order_ref_id, | |
customer: { | |
customer_ref_id, | |
email, | |
}, | |
items: [ | |
{ | |
name: lineItemText, | |
qty: 1, | |
price: amount, | |
logo: lobbyImage, | |
}, | |
], | |
}; | |
// Create Orders | |
return dpay.orders | |
.create(options) | |
.then((resp) => { | |
console.log("created order 💰", resp); | |
// order_id = resp.order_id; | |
const { id, access_token, metadata } = resp; | |
console.log(metadata); | |
res.json({ data: { id, access_token, metadata } }); | |
}) | |
.catch((error) => { | |
console.log(error.err + " | " + JSON.stringify(error.data)); | |
return error; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment