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

BP-2693 Credit Management / Paylink + Giftcards #750

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,56 @@ private function getAllowedServices($payment): string
{
$allowedServices = $this->configProvider->getPaymentMethod();

if($payment->getMethod() === PayPerEmail::PAYMENT_METHOD_CODE) {
return str_replace("p24,","",$allowedServices);
if (!is_string($allowedServices)) {
return '';
}

$allowedServices = $this->appendGiftcards($allowedServices);

if ($payment->getMethod() === PayPerEmail::PAYMENT_METHOD_CODE) {
return str_replace("p24,", "", $allowedServices);
}

return $allowedServices;
}

/**
* Append active giftcards if giftcard is enabled
*
* @param string $allowedServices
*
* @return string
*/
private function appendGiftcards(string $allowedServices): string
{
$services = explode(',', $allowedServices);
if (!in_array('giftcard', $services)) {
return $allowedServices;
}
$services = array_filter($services, function ($service) {
return $service !== 'giftcard';
});

$allowedServices = implode(",", $services);

/** @var \Buckaroo\Magento2\Model\ConfigProvider\Method\Giftcards */
$giftcardConfig = $this->configProviderMethodFactory->get('giftcards');

if (!method_exists($giftcardConfig, 'getAllowedCards')) {
return $allowedServices;
}
$activeGiftcardIssuers = $giftcardConfig->getAllowedCards();

if (!is_string($activeGiftcardIssuers) || strlen(trim($activeGiftcardIssuers)) === 0) {
return $allowedServices;
}

if(strlen($allowedServices) > 0) {
return $allowedServices . "," . $activeGiftcardIssuers;
}
return $activeGiftcardIssuers;
}

/**
* @param OrderPaymentInterface|InfoInterface $payment
*
Expand Down
Loading