Commit 0eecc937 by lmf

升级Klarna插件

parent 4cf86cc9
...@@ -68,7 +68,13 @@ class Redirect extends \Magento\Framework\View\Element\Template ...@@ -68,7 +68,13 @@ class Redirect extends \Magento\Framework\View\Element\Template
} }
public function getPayMode(){ public function getPayMode(){
return $this->_paymentMethod->getConfigData('pay_mode'); $billing_country = $this->_paymentMethod->getBillingCountry();
$pay_mode = $this->_paymentMethod->getConfigData('pay_mode');
if($pay_mode == 'redirect' || in_array($billing_country,array('BE','FR','IT','ES','CH'))){
return 'redirect';
}else{
return 'iframe';
}
} }
......
...@@ -90,7 +90,19 @@ class PaymentMethod extends AbstractMethod ...@@ -90,7 +90,19 @@ class PaymentMethod extends AbstractMethod
{ {
return $this->getConfigData('gateway_url'); return $this->getConfigData('gateway_url');
} }
/**
* billing country
*
* @return string billing country
*/
public function getBillingCountry()
{
$orderIncrementId = $this->checkoutSession->getLastRealOrderId();
$order = $this->_orderFactory->create()->loadByIncrementId($orderIncrementId);
$billing = $order->getBillingAddress();
return $billing->getCountryId();
}
public function canUseForCurrency($currencyCode) public function canUseForCurrency($currencyCode)
{ {
...@@ -222,8 +234,8 @@ class PaymentMethod extends AbstractMethod ...@@ -222,8 +234,8 @@ class PaymentMethod extends AbstractMethod
$itemList = '{ $itemList = '{
"0": { "0": {
"type": "1", "type": "1",
"title": "'.substr($productName,0,100).'", "title": "'.substr(str_replace(array("'",'"'),array("",""),$productName), 0,100).'",
"sku": "'.substr($productSku,0,100).'", "sku": "'.substr(str_replace(array("'",'"'),array("",""),$productSku), 0,100).'",
"price": "'.($order_amount-$order->getTaxAmount()-$order->getShippingAmount()).'", "price": "'.($order_amount-$order->getTaxAmount()-$order->getShippingAmount()).'",
"quantity": "1", "quantity": "1",
"total_amount": "'.($order_amount-$order->getTaxAmount()-$order->getShippingAmount()).'", "total_amount": "'.($order_amount-$order->getTaxAmount()-$order->getShippingAmount()).'",
...@@ -236,7 +248,7 @@ class PaymentMethod extends AbstractMethod ...@@ -236,7 +248,7 @@ class PaymentMethod extends AbstractMethod
"1": { "1": {
"type": "3", "type": "3",
"title": "折扣", "title": "折扣",
"sku": "'.substr($productSku,0,100).'", "sku": "'.substr(str_replace(array("'",'"'),array("",""),$productSku), 0,100).'",
"price": "0", "price": "0",
"quantity": "0", "quantity": "0",
"total_amount": "0", "total_amount": "0",
...@@ -249,7 +261,7 @@ class PaymentMethod extends AbstractMethod ...@@ -249,7 +261,7 @@ class PaymentMethod extends AbstractMethod
"2": { "2": {
"type": "4", "type": "4",
"title": "运费", "title": "运费",
"sku": "'.substr($productSku,0,100).'", "sku": "'.substr(str_replace(array("'",'"'),array("",""),$productSku), 0,100).'",
"price": "'.round($order->getShippingAmount(),2).'", "price": "'.round($order->getShippingAmount(),2).'",
"quantity": "1", "quantity": "1",
"total_amount": "'.round($order->getShippingAmount(),2).'", "total_amount": "'.round($order->getShippingAmount(),2).'",
...@@ -262,7 +274,7 @@ class PaymentMethod extends AbstractMethod ...@@ -262,7 +274,7 @@ class PaymentMethod extends AbstractMethod
"3": { "3": {
"type": "5", "type": "5",
"title": "税费", "title": "税费",
"sku": "'.substr($productSku,0,100).'", "sku": "'.substr(str_replace(array("'",'"'),array("",""),$productSku), 0,100).'",
"price": "'.round($order->getTaxAmount(),2).'", "price": "'.round($order->getTaxAmount(),2).'",
"quantity": "1", "quantity": "1",
"total_amount": "'.round($order->getTaxAmount(),2).'", "total_amount": "'.round($order->getTaxAmount(),2).'",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment