Просмотр исходного кода

修改购物车地址不存在报的错误

llp 1 неделя назад
Родитель
Сommit
f80676da6d

+ 6 - 17
packages/Longyi/Pay/Afterpay/src/Payment/Afterpay.php

@@ -144,14 +144,14 @@ class Afterpay extends Payment
             'verify' => false
         ]);
         $resultObject = json_decode($response->getBody()->getContents());
-        if ($resultObject->token == 'APPROVED') {
-            return true;
+        if ($resultObject->status == 'APPROVED') {
+            return ['transaction_id' => $resultObject->token];
         } else {
-            return false;
+            return [];
         }
     }
 
-    public function paymentsSuccess($orderId, $transactionId)
+    public function captureAndVerify($orderId, $transactionId)
     {
         $order = app(OrderRepository::class)->find($orderId);
         if (!$order->id) {
@@ -166,17 +166,7 @@ class Afterpay extends Payment
         if ($transactionId != $token) {
             return new \Exception('order token is error');
         }
-        if (!$this->capture($token)) {
-            return new \Exception('order capture fail');
-        }
-        $order->status = Order::STATUS_PROCESSING;
-        $order->save();
-        $additional['transaction_id'] = $transactionId;
-        if ($order->payment) {
-            $order->payment->additional = $additional;
-            $order->payment->save();
-        }
-        return true;
+        return $this->capture($token);
     }
 
     public function getBaseUlr()
@@ -209,8 +199,7 @@ class Afterpay extends Payment
             return false;
         }
         $info = $this->getOrder() ?: Cart::getCart();
-        if ($info) {
-            $billingCountry = $info->billing_address->country;
+        if ($info && $billingCountry = $info->billing_address->country ?? false) {
             $allowedCountries = ['AU', 'CA', 'NZ', 'GB', 'US'];
             return in_array($billingCountry, $allowedCountries);
         }

+ 1 - 2
packages/Longyi/Pay/Airwallex/src/Payment/Airwallex.php

@@ -239,8 +239,7 @@ class Airwallex extends Payment
             return false;
         }
         $info = $this->getOrder() ?: Cart::getCart();
-        if ($info) {
-            $billingCountry = $info->billing_address->country;
+        if ($info && $billingCountry = $info->billing_address->country ?? false) {
             $allowedCountries = ['AU', 'CA', 'NZ', 'GB', 'US'];
             return in_array($billingCountry, $allowedCountries);
         }

+ 1 - 2
packages/Longyi/Pay/AwxAfterpay/src/Payment/AwxAfterpay.php

@@ -301,8 +301,7 @@ class AwxAfterpay extends Payment
             return false;
         }
         $info = $this->getOrder() ?: Cart::getCart();
-        if ($info) {
-            $billingCountry = $info->billing_address->country;
+        if ($info && $billingCountry = $info->billing_address->country ?? false) {
             $allowedCountries = ['AU', 'CA', 'NZ', 'GB', 'US'];
             return in_array($billingCountry, $allowedCountries);
         }

+ 1 - 2
packages/Longyi/Pay/AwxKlarna/src/Payment/AwxKlarna.php

@@ -308,8 +308,7 @@ class AwxKlarna extends Payment
             return false;
         }
         $info = $this->getOrder() ?: Cart::getCart();
-        if ($info) {
-            $billingCountry = $info->billing_address->country;
+        if ($info && $billingCountry = $info->billing_address->country ?? false) {
             $allowedCountries = ['AU', 'AT', 'BE', 'CA', 'CZ', 'DK', 'FI', 'FR', 'DE', 'GR', 'IE',
                 'IT', 'NL', 'NO', 'PL', 'PT', 'ES', 'SE', 'CH', 'GB', 'US'
             ];

+ 10 - 7
packages/Webkul/BagistoApi/src/Services/PaymentService.php

@@ -614,15 +614,18 @@ class PaymentService
                 }
 
                 $capture = null;
-
-                if ($method === 'paypal_smart_button') {
-                    if (! $gatewayOrderId) {
-                        throw new OperationFailedException(__('bagistoapi::app.graphql.payment.gateway-order-id-required'));
+                $gatewayHandler = $this->resolveGatewayHandler($method, $order, $input);
+                if ($gatewayHandler) {
+                    $capture = $gatewayHandler->captureAndVerify($order, $gatewayOrderId);
+                } else {
+                    if ($method === 'paypal_smart_button') {
+                        if (! $gatewayOrderId) {
+                            throw new OperationFailedException(__('bagistoapi::app.graphql.payment.gateway-order-id-required'));
+                        }
+
+                        $capture = $this->captureAndVerify($order, $gatewayOrderId);
                     }
-
-                    $capture = $this->captureAndVerify($order, $gatewayOrderId);
                 }
-
                 if ($isExpress) {
                     $this->fillAddressesFromCallback($order, $input);
                 }