From 940b82cdeb6d828444112fe8d7184e594a20bc8b Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Tue, 22 Nov 2022 13:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BApaypal=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/Paypal/Controllers/PaypalController.php | 3 ++- plugins/Paypal/Views/checkout/payment.blade.php | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/Paypal/Controllers/PaypalController.php b/plugins/Paypal/Controllers/PaypalController.php index afe572ae..eb05f14f 100644 --- a/plugins/Paypal/Controllers/PaypalController.php +++ b/plugins/Paypal/Controllers/PaypalController.php @@ -69,6 +69,7 @@ class PaypalController $orderNumber = $data['orderNumber']; $customer = current_customer(); $order = OrderRepo::getOrderByNumber($orderNumber, $customer); + $total = round($order->total, 2); $paypalOrder = $this->paypalClient->createOrder([ "intent" => "CAPTURE", @@ -76,7 +77,7 @@ class PaypalController [ "amount" => [ "currency_code" => $order->currency_code, - "value" => $order->total, + "value" => $total, ], 'description' => 'test' ] diff --git a/plugins/Paypal/Views/checkout/payment.blade.php b/plugins/Paypal/Views/checkout/payment.blade.php index e6b7c32a..5c1cf7a7 100644 --- a/plugins/Paypal/Views/checkout/payment.blade.php +++ b/plugins/Paypal/Views/checkout/payment.blade.php @@ -23,10 +23,13 @@ orderNumber: "{{$order->number}}", }) }).then(function (res) { - //res.json(); return res.json(); }).then(function (orderData) { - //console.log(orderData); + if (orderData.error) { + layer.alert(orderData.error.details[0].description, function(index){ + window.location.reload(); + }); + } return orderData.id; }); },