From 76961c8312312609dbef0646274f6dd1f6c2bf19 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 3 Mar 2023 16:44:12 +0700 Subject: add midtrans payment email notification --- src/lib/checkout/components/Checkout.jsx | 6 +- src/lib/checkout/components/FinishCheckout.jsx | 18 +- src/lib/checkout/email/FinishCheckoutEmail.jsx | 326 +++++++++++++++++++++++++ src/pages/api/shop/finish-checkout.js | 91 +++++++ src/pages/api/shop/midtrans-payment.js | 33 ++- src/pages/shop/checkout/finish.jsx | 2 +- 6 files changed, 459 insertions(+), 17 deletions(-) create mode 100644 src/lib/checkout/email/FinishCheckoutEmail.jsx create mode 100644 src/pages/api/shop/finish-checkout.js diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 42608cef..8af3d996 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -126,7 +126,7 @@ const Checkout = () => { `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${isCheckouted.id}` ) for (const product of products) deleteItemCart({ productId: product.id }) - window.snap.pay(payment.data.token) + window.location.href = payment.data.redirectUrl } return ( @@ -252,7 +252,7 @@ const Checkout = () => { @@ -261,7 +261,7 @@ const Checkout = () => {