From 76961c8312312609dbef0646274f6dd1f6c2bf19 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 3 Mar 2023 16:44:12 +0700
Subject: add midtrans payment email notification

---
 src/lib/checkout/components/Checkout.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/lib/checkout/components/Checkout.jsx')

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 = () => {
         <button
           className='flex-1 btn-yellow'
           onClick={checkout}
-          disabled={isLoading}
+          disabled={isLoading || !products || products?.length == 0}
         >
           {isLoading ? 'Loading...' : 'Bayar'}
         </button>
@@ -261,7 +261,7 @@ const Checkout = () => {
       <Script
         async
         src='https://app.sandbox.midtrans.com/snap/snap.js'
-        data-client-key=''
+        data-client-key={process.env.NEXT_PUBLIC_MIDTRANS_CLIENT_KEY}
       />
     </>
   )
-- 
cgit v1.2.3

