From f15a7f8a4387d215abd1051ee520adca8944fa05 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 28 Mar 2023 16:32:45 +0700 Subject: checkout, quotation --- src/pages/api/shop/midtrans-payment.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/pages/api') diff --git a/src/pages/api/shop/midtrans-payment.js b/src/pages/api/shop/midtrans-payment.js index be676d38..1772e9e0 100644 --- a/src/pages/api/shop/midtrans-payment.js +++ b/src/pages/api/shop/midtrans-payment.js @@ -31,6 +31,20 @@ export default async function handler(req, res) { serverKey: process.env.MIDTRANS_SERVER_KEY }) + let itemDetails = transaction.products.map((product) => ({ + id: product.code, + price: Math.round(product.price.priceDiscount), + quantity: product.quantity, + name: product.name?.substring(0, 50) + })) + + itemDetails.push({ + id: 'TAX', + price: transaction.amountTax, + quantity: 1, + name: 'PPN 11%' + }) + const parameter = { transaction_details: { order_id: transaction.name?.replaceAll('/', '-'), @@ -39,12 +53,6 @@ export default async function handler(req, res) { credit_card: { secure: true }, - item_details: transaction.products.map((product) => ({ - id: product.code, - price: Math.round(product.price.priceDiscount), - quantity: product.quantity, - name: product.name?.substring(0, 50) - })), customer_details: { first_name: transaction.address.customer.name, email: transaction.address.customer.email || '', -- cgit v1.2.3