Przeglądaj źródła

修改支付方式

llp 2 dni temu
rodzic
commit
f9fb60a2e2

+ 14 - 3
packages/Longyi/Pay/AwxAfterpay/src/Payment/AwxAfterpay.php

@@ -15,6 +15,7 @@ class AwxAfterpay extends Payment
     protected $apikey;
     protected $secret;
     protected $currentOrder;
+    protected $currentInput;
     protected $prefix = 'QQS';
     protected $tokenCacheKey = 'airwallex_klarna_token';
     protected $tokenUrl = 'https://api-demo.airwallex.com/api/v1/authentication/login';
@@ -60,11 +61,21 @@ class AwxAfterpay extends Payment
     {
         return $this->currentOrder;
     }
+    public function setInput($input = null): self
+    {
+        $this->currentInput = $input;
+        return $this;
+    }
+
+    public function getInput()
+    {
+        return $this->currentInput;
+    }
     public function createGatewayOrder()
     {
-        return $this->createPayment($this->getOrder(), ['merchantOrderId' => $this->getOrder()->id]);
+        return $this->createPayment($this->getOrder(), ['merchantOrderId' => $this->getOrder()->id], $this->currentInput);
     }
-    public function createPayment($order, $override)
+    public function createPayment($order, $override, $input)
     {
         $shop = $order->shipping_address;
         $bill = $order->billing_address;
@@ -79,7 +90,7 @@ class AwxAfterpay extends Payment
             'request_id' => $this->createUuid(),
             'amount' => $grandTotal,
             'descriptor' => $this->prefix,
-            'return_url' => $this->getBaseUlr() . '/afterpay/standard/return?orderId=' . $override['merchantOrderId'],
+            'return_url' => $input->paymentSuccessUrl. '?orderId=' . $override['merchantOrderId'],
             'merchant_order_id' => $this->prefix . $override['merchantOrderId'],
             'currency' => $order->order_currency_code,
             'customer' => [

+ 4 - 4
packages/Longyi/Pay/AwxKlarna/src/Http/Controllers/KlarnaController.php

@@ -87,11 +87,11 @@ class KlarnaController extends Controller
         $awxReturnResult = request()->input('awx_return_result');
         $orderId = request()->input('orderId');
         if ($awxReturnResult == 'success') {
-            session()->flash('order_id', $orderId);
-            return redirect()->route('shop.checkout.onepage.success');
+            return redirect()->to('/paymentresult/success?orderId=' . $orderId);
+        } else if ($awxReturnResult == 'cancel') {
+            return redirect()->to('/paymentresult/cancel?orderId=' . $orderId);
         } else {
-            session()->flash('error', 'afterpay cancel');
-            return redirect()->route('shop.checkout.cart.index');
+            return redirect()->to('/paymentresult/failure?orderId=' . $orderId);
         }
     }
 

+ 3 - 3
packages/Webkul/BagistoApi/src/Services/PaymentService.php

@@ -255,7 +255,7 @@ class PaymentService
 
         }
 
-        $gatewayOrderId = $this->createGatewayOrderForOrder($order);
+        $gatewayOrderId = $this->createGatewayOrderForOrder($order, $input);
 
         $this->writeGatewayOrderId($order, $gatewayOrderId);
 
@@ -446,10 +446,10 @@ class PaymentService
      * Variant used by replay() where there's no Cart - amount comes
      * straight from the existing order.
      */
-    protected function createGatewayOrderForOrder($order): ?string
+    protected function createGatewayOrderForOrder($order, $input): ?string
     {
         $method = $order->payment?->method;
-        $gatewayHandler = $this->resolveGatewayHandler($method, $order);
+        $gatewayHandler = $this->resolveGatewayHandler($method, $order, $input);
         if ($gatewayHandler) {
             return $gatewayHandler->createGatewayOrder();
         } else {