|
|
@@ -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=' . $order->id,
|
|
|
'merchant_order_id' => $this->prefix . $override['merchantOrderId'],
|
|
|
'currency' => $order->order_currency_code,
|
|
|
'customer' => [
|
|
|
@@ -297,11 +308,17 @@ class AwxKlarna extends Payment
|
|
|
return false;
|
|
|
}
|
|
|
$cart = Cart::getCart();
|
|
|
- $billingCountry = $cart->billing_address->country;
|
|
|
- $allowedCountries = ['AU', 'AT', 'BE', 'CA', 'CZ', 'DK', 'FI', 'FR', 'DE', 'GR', 'IE',
|
|
|
- 'IT', 'NL', 'NO', 'PL', 'PT', 'ES', 'SE', 'CH', 'GB', 'US'
|
|
|
- ];
|
|
|
- return in_array($billingCountry, $allowedCountries);
|
|
|
+ if (! $cart) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ($cart->billing_address) {
|
|
|
+ $billingCountry = $cart->billing_address->country;
|
|
|
+ $allowedCountries = ['AU', 'AT', 'BE', 'CA', 'CZ', 'DK', 'FI', 'FR', 'DE', 'GR', 'IE',
|
|
|
+ 'IT', 'NL', 'NO', 'PL', 'PT', 'ES', 'SE', 'CH', 'GB', 'US'
|
|
|
+ ];
|
|
|
+ return in_array($billingCountry, $allowedCountries);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public function getDescription()
|