瀏覽代碼

添加支付方式

llp 1 月之前
父節點
當前提交
e210efa012
共有 1 個文件被更改,包括 14 次插入3 次删除
  1. 14 3
      packages/Longyi/Pay/AwxKlarna/src/Payment/AwxKlarna.php

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

@@ -16,6 +16,7 @@ class AwxKlarna 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';
@@ -61,11 +62,21 @@ class AwxKlarna 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->getInput());
     }
-    public function createPayment($order, $override)
+    public function createPayment($order, $override, $input)
     {
         $shop = $order->shipping_address;
         $bill = $order->billing_address;
@@ -80,7 +91,7 @@ class AwxKlarna extends Payment
             'request_id' => $this->createUuid(),
             'amount' => $grandTotal,
             'descriptor' => $this->prefix,
-            'return_url' => $this->getBaseUlr() . '/klarna/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' => [