Kaynağa Gözat

修改官方afterpay

llp 2 hafta önce
ebeveyn
işleme
5e75beafa8

+ 19 - 5
packages/Longyi/Pay/Afterpay/src/Payment/Afterpay.php

@@ -16,6 +16,7 @@ class Afterpay extends Payment
     protected $apikey;
     protected $secret;
     protected $currentOrder;
+    protected $currentInput;
     protected $createPaymentUlr = 'https://global-api-sandbox.afterpay.com/v2/checkouts';
     protected $capturePaymentUlr = 'https://global-api-sandbox.afterpay.com/v2/payments/capture';
 
@@ -23,7 +24,7 @@ class Afterpay extends Payment
     {
         if ($this->getConfigData('mode') == 'live') {
             $this->createPaymentUlr = 'https://global-api.afterpay.com/v2/checkouts';
-            $this->capturePaymentUlr = 'https://global-api-sandbox.afterpay.com/v2/payments/capture';
+            $this->capturePaymentUlr = 'https://global-api.afterpay.com/v2/payments/capture';
         }
         $this->clientId = $this->getConfigData('client_id');
         $this->apikey = $this->getConfigData('secret_id');
@@ -46,17 +47,30 @@ class Afterpay 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()
     {
         try {
-            return $this->createPayment($this->getOrder(), ['merchantOrderId' => $this->getOrder()->increment_id]);
+            return $this->createPayment(
+                $this->getOrder(),
+                ['merchantOrderId' => $this->getOrder()->increment_id],
+                $this->getInput()
+            );
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage());
         }
     }
 
-    public function createPayment($order, $override)
+    public function createPayment($order, $override, $input = null)
     {
         $shop = $order->shipping_address;
         $bill = $order->billing_address;
@@ -106,8 +120,8 @@ class Afterpay extends Payment
                 'countryCode' => $shop->country,
             ],
             'merchant' => [
-                'redirectConfirmUrl' => $this->getBaseUlr() . '/afterpay/return?order_id=' . $override['merchantOrderId'],
-                'redirectCancelUrl' => $this->getBaseUlr() . '/afterpay/return?order_id=' . $override['merchantOrderId']
+                'redirectConfirmUrl' => $input->paymentSuccessUrl . '?orderId=' . $order->id,
+                'redirectCancelUrl' => $input->paymentCancelUrl. '?orderId=' . $order->id
             ],
             'items' => $products
         ];

+ 2 - 2
packages/Longyi/Pay/AwxKlarna/src/Config/system.php

@@ -39,7 +39,7 @@ return [
                 'locale_based' => true,
             ], [
                 'name' => 'client_id',
-                'title' => 'ClientId',
+                'title' => 'Merchant ID',
                 'type' => 'text',
                 'depend' => 'active:1',
                 'validation' => 'required_if:active,1',
@@ -47,7 +47,7 @@ return [
                 'locale_based' => true,
             ], [
                 'name' => 'secret_id',
-                'title' => 'Secret',
+                'title' => 'Merchant Key',
                 'type' => 'password',
                 'depend' => 'active:1',
                 'validation' => 'required_if:active,1',