From 2ba801d77d2e52082d33ae1d0693bb7e0296b29c Mon Sep 17 00:00:00 2001 From: Jun Barroga Date: Mon, 22 Apr 2024 11:53:58 +0800 Subject: [PATCH] Obananapay Checkout Bug Fix --- checkouttest.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/checkouttest.php b/checkouttest.php index cf74d7c..192718a 100644 --- a/checkouttest.php +++ b/checkouttest.php @@ -1380,16 +1380,15 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] console.log(orderId) const token = ''; const shippingfee = parseFloat(orderId.shipping_fee) - const orderPay3ProductId = orderId.items[0].product.product_id; - const productPay3Response = await fetch(`https:///api/v1/products/${orderPay3ProductId}`); - const productPay3Data = await productPay3Response.json(); + const orderPay2ProductId = orderId.items[0].product.product_id; + const productPay2Response = await fetch(`https:///api/v1/products/${orderPay2ProductId}`); + const productPay2Data = await productPay2Response.json(); let freeShippingObPay = false; - if (productPay3Data.promo && productPay3Data.promo.length > 0 && productPay3Data.promo[0]['free-shipping'] === 'Yes') { + if (productPay2Data.promo && productPay2Data.promo.length > 0 && productPay2Data.promo[0]['free-shipping'] === 'Yes') { freeShippingObPay = true; } - const shippingFeesPay3 = freeShippingObPay ? 0 : shippingfee; - - const patchResponse = await fetch(`https:///api/v1/orders/${orderId._id}`, { + const shippingFeesPay2 = freeShippingObPay ? 0 : shippingfee; + const patchResponse2 = await fetch(`https:///api/v1/orders/${orderId._id}`, { method: "PATCH", body: JSON.stringify({ shipping_address: { @@ -1418,8 +1417,8 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] status: "UNPAID", reference_number: result.attributes.reference_number, }, - shipping_fee: shippingFeesPay3, - total_amount: parseFloat(orderId.total_amount) + shippingFeesPay3, + shipping_fee: shippingFeesPay2, + total_amount: parseFloat(orderId.total_amount) + shippingFeesPay2, order_date: iso8601String, payment_method: "Obananapay", }), @@ -1429,12 +1428,12 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"] }, }); - if (!patchResponse.ok) { - throw new Error(`Error updating payment status: ${patchResponse.status} ${patchResponse.statusText}`); + if (!patchResponse2.ok) { + throw new Error(`Error updating payment status: ${patchResponse2.status} ${patchResponse2.statusText}`); } }) console.log("Payment Successfull") - window.location.href = 'user-history.php'; + // window.location.href = 'user-history.php'; // console.log( ); } window.location.href = result.attributes.checkout_url;