Compare commits
2 Commits
26653ef372
...
ec737139fa
Author | SHA1 | Date |
---|---|---|
MarkHipe | ec737139fa | |
Jun Barroga | 2ba801d77d |
|
@ -1380,16 +1380,15 @@ if (isset($customer_data[0]["address"]) && is_array($customer_data[0]["address"]
|
|||
console.log(orderId)
|
||||
const token = '<?php echo $_SESSION["token"] ?>';
|
||||
const shippingfee = parseFloat(orderId.shipping_fee)
|
||||
const orderPay3ProductId = orderId.items[0].product.product_id;
|
||||
const productPay3Response = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/products/${orderPay3ProductId}`);
|
||||
const productPay3Data = await productPay3Response.json();
|
||||
const orderPay2ProductId = orderId.items[0].product.product_id;
|
||||
const productPay2Response = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/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://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/orders/${orderId._id}`, {
|
||||
const shippingFeesPay2 = freeShippingObPay ? 0 : shippingfee;
|
||||
const patchResponse2 = await fetch(`https://<?php echo $_SESSION["data_endpoint"]; ?>/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( <?php echo $filteredIdsJSON; ?>);
|
||||
}
|
||||
window.location.href = result.attributes.checkout_url;
|
||||
|
|
Loading…
Reference in New Issue