Skip to content

Instantly share code, notes, and snippets.

@rickithadi
Created September 8, 2023 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickithadi/9e6bf4f7ee854812229064f2ea5c0a98 to your computer and use it in GitHub Desktop.
Save rickithadi/9e6bf4f7ee854812229064f2ea5c0a98 to your computer and use it in GitHub Desktop.
endpoint to create durianpay order
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