Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SW-366: bugfix: klarna payments fail after setting klarna to default … #439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Frontend/MoptPaymentPayone/Components/Classes/PayoneConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Mopt_PayoneConfig
'mopt_payone__fin_paypal_installment',
];

// only paypal express
const PAYMENTS_ADDRESSCHECK_EXCLUDED = [
'mopt_payone__ewallet_amazon_pay',
'mopt_payone__ewallet_paypal',
Expand Down Expand Up @@ -110,6 +109,20 @@ class Mopt_PayoneConfig
'mopt_payone__fin_paypal_installment',
];

const PAYMENTS_EXCLUDED_FROM_ACCOUNTPAGE = [
'mopt_payone__ewallet_amazon_pay',
'mopt_payone__ewallet_paypal',
'mopt_payone__fin_payolution_installment',
'mopt_payone__fin_ratepay_installment',
'mopt_payone__ewallet_paydirekt_express',
'mopt_payone__ewallet_applepay',
'mopt_payone__fin_klarna_old',
'mopt_payone__fin_kis_klarna_installments',
'mopt_payone__fin_kiv_klarna_invoice',
'mopt_payone__fin_kdd_klarna_direct_debit',
'mopt_payone_klarna',
];

/**
* return array with configured valid IPs to accept transaction feedback from
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1828,4 +1828,24 @@ public function isKlarnaPersonalIdNeededByCountry()
$klarnaPersonalIdNeededCountries = array('NO', 'SE', 'DK'); // SE verified FI unsure
return in_array($billingCountryIso, $klarnaPersonalIdNeededCountries);
}

/**
* remove express and installment payments from
* payment lists on account page
*
* @param $payments array
* @return array
*/
public function filterPaymentsInAccount($payments)
{
foreach ($payments as $index => $payment) {
foreach (Mopt_PayoneConfig::PAYMENTS_EXCLUDED_FROM_ACCOUNTPAGE as $exludedPayment) {
if (strpos($payment['name'], $exludedPayment) !== false) {
unset($payments[$index]);
}
}
}

return $payments;
}
}
13 changes: 1 addition & 12 deletions Frontend/MoptPaymentPayone/Subscribers/FrontendPostDispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,7 @@ public function onPostDispatchFrontend(\Enlight_Controller_ActionEventArgs $args

// remove AmazonPay from Payment List
$payments = $view->getAssign('sPaymentMeans');

foreach ($payments as $index => $payment) {
if (strpos($payment['name'], 'mopt_payone__ewallet_amazon_pay') !== false ) {
$amazonPayIndex = $index;
}
if (strpos($payment['name'], 'mopt_payone__ewallet_applepay') !== false && $session->get('moptAllowApplePay', false) !== true ) {
$applepayIndex = $index;
}
}
unset ($payments[$amazonPayIndex]);
unset ($payments[$applepayIndex]);
$view->assign('sPaymentMeans', $payments);
$view->assign('sPaymentMeans', $moptPaymentHelper->filterPaymentsInAccount($payments));
}

if (($controllerName == 'checkout' && $request->getActionName() == 'confirm')) {
Expand Down