Skip to content

Commit

Permalink
Add Online Banking Finland payment method
Browse files Browse the repository at this point in the history
ISSUE: ADCRSET21I-4
  • Loading branch information
filipkojic committed Nov 19, 2024
1 parent 4e533f9 commit 613fc6a
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 46 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The plugin integrates card component (Secured Fields) using Adyen Checkout for a
- Vipps
- WeChat Pay
- Open Banking / Pay by Bank
- Online Banking Finland

## API Library
This module is using the Adyen APIs Library for PHP for all (API) connections to Adyen.
Expand Down
107 changes: 65 additions & 42 deletions src/AdyenPaymentShopware6.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public function update(UpdateContext $updateContext): void
if (\version_compare($currentVersion, '3.16.0', '<')) {
$this->updateTo3160($updateContext);
}

if (\version_compare($currentVersion, '3.17.0', '<')) {
$this->updateTo3170($updateContext);
}
}

private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $paymentMethod, Context $context): void
Expand Down Expand Up @@ -236,10 +240,11 @@ private function getPaymentMethodId(string $paymentMethodHandler): ?string
}

private function setPaymentMethodIsActive(
bool $active,
Context $context,
bool $active,
Context $context,
PaymentMethods\PaymentMethodInterface $paymentMethod
): void {
): void
{
/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');

Expand Down Expand Up @@ -321,11 +326,11 @@ private function updateTo160(UpdateContext $updateContext): void
{
//Version 1.6.0 introduces applepay, paywithgoogle, dotpay and bancontact
foreach ([
new PaymentMethods\ApplePayPaymentMethod,
new PaymentMethods\GooglePayPaymentMethod,
new PaymentMethods\DotpayPaymentMethod,
new PaymentMethods\BancontactCardPaymentMethod
] as $method) {
new PaymentMethods\ApplePayPaymentMethod,
new PaymentMethods\GooglePayPaymentMethod,
new PaymentMethods\DotpayPaymentMethod,
new PaymentMethods\BancontactCardPaymentMethod
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand All @@ -342,9 +347,9 @@ private function updateTo200(UpdateContext $updateContext): void
{
//Version 2.0.0 introduces amazonpay, blik
foreach ([
new PaymentMethods\AmazonPayPaymentMethod,
new PaymentMethods\BlikPaymentMethod,
] as $method) {
new PaymentMethods\AmazonPayPaymentMethod,
new PaymentMethods\BlikPaymentMethod,
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand All @@ -361,23 +366,23 @@ private function updateTo300(UpdateContext $updateContext): void
{
//Version 3.0.0 introduces the following payment methods
foreach ([
new PaymentMethods\AfterpayDefaultPaymentMethod,
new PaymentMethods\AlipayPaymentMethod,
new PaymentMethods\AlipayHkPaymentMethod,
new PaymentMethods\ClearpayPaymentMethod,
new PaymentMethods\EpsPaymentMethod,
new PaymentMethods\Facilypay3xPaymentMethod,
new PaymentMethods\Facilypay4xPaymentMethod,
new PaymentMethods\Facilypay6xPaymentMethod,
new PaymentMethods\Facilypay10xPaymentMethod,
new PaymentMethods\Facilypay12xPaymentMethod,
new PaymentMethods\PaysafecardPaymentMethod,
new PaymentMethods\RatepayPaymentMethod,
new PaymentMethods\RatepayDirectdebitPaymentMethod,
new PaymentMethods\SwishPaymentMethod,
new PaymentMethods\TrustlyPaymentMethod,
new PaymentMethods\TwintPaymentMethod,
] as $method) {
new PaymentMethods\AfterpayDefaultPaymentMethod,
new PaymentMethods\AlipayPaymentMethod,
new PaymentMethods\AlipayHkPaymentMethod,
new PaymentMethods\ClearpayPaymentMethod,
new PaymentMethods\EpsPaymentMethod,
new PaymentMethods\Facilypay3xPaymentMethod,
new PaymentMethods\Facilypay4xPaymentMethod,
new PaymentMethods\Facilypay6xPaymentMethod,
new PaymentMethods\Facilypay10xPaymentMethod,
new PaymentMethods\Facilypay12xPaymentMethod,
new PaymentMethods\PaysafecardPaymentMethod,
new PaymentMethods\RatepayPaymentMethod,
new PaymentMethods\RatepayDirectdebitPaymentMethod,
new PaymentMethods\SwishPaymentMethod,
new PaymentMethods\TrustlyPaymentMethod,
new PaymentMethods\TwintPaymentMethod,
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand Down Expand Up @@ -427,15 +432,15 @@ private function updateTo370(UpdateContext $updateContext): void
* MB Way, Multibanco, WeChat Pay, MobilePay, Vipps, Affirm & PayBright
*/
foreach ([
new PaymentMethods\MbwayPaymentMethod(),
new PaymentMethods\MultibancoPaymentMethod(),
new PaymentMethods\WechatpayqrPaymentMethod(),
new PaymentMethods\WechatpaywebPaymentMethod(),
new PaymentMethods\MobilePayPaymentMethod(),
new PaymentMethods\VippsPaymentMethod(),
new PaymentMethods\AffirmPaymentMethod(),
new PaymentMethods\PayBrightPaymentMethod()
] as $method) {
new PaymentMethods\MbwayPaymentMethod(),
new PaymentMethods\MultibancoPaymentMethod(),
new PaymentMethods\WechatpayqrPaymentMethod(),
new PaymentMethods\WechatpaywebPaymentMethod(),
new PaymentMethods\MobilePayPaymentMethod(),
new PaymentMethods\VippsPaymentMethod(),
new PaymentMethods\AffirmPaymentMethod(),
new PaymentMethods\PayBrightPaymentMethod()
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand All @@ -455,8 +460,8 @@ private function updateTo3100(UpdateContext $updateContext): void
* Open Banking / Pay by Bank
*/
foreach ([
new PaymentMethods\OpenBankingPaymentMethod(),
] as $method) {
new PaymentMethods\OpenBankingPaymentMethod(),
] as $method) {
$this->addPaymentMethod(
$method,
$updateContext->getContext()
Expand Down Expand Up @@ -522,6 +527,23 @@ private function updateTo3160(UpdateContext $updateContext): void
);
}

private function updateTo3170(UpdateContext $updateContext): void
{
// Version 3.17.0 introduces Online Banking Finland
$method = new PaymentMethods\OnlineBankingFinlandPaymentMethod();

$this->addPaymentMethod(
$method,
$updateContext->getContext()
);

$this->setPaymentMethodIsActive(
true,
$updateContext->getContext(),
$method
);
}

private function safeCopyAsset($source, $destination): bool
{
try {
Expand All @@ -539,9 +561,10 @@ private function safeCopyAsset($source, $destination): bool
*/
private function deactivateAndRemovePaymentMethod(
UpdateContext $updateContext,
string $paymentMethodHandler,
string $description = null
): void {
string $paymentMethodHandler,
string $description = null
): void
{
/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');
/** @var EntityRepository $salesChannelPaymentRepository */
Expand Down
11 changes: 11 additions & 0 deletions src/Handlers/OnlineBankingFinlandPaymentMethodHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);

namespace Adyen\Shopware\Handlers;

class OnlineBankingFinlandPaymentMethodHandler extends AbstractPaymentMethodHandler
{
public static function getPaymentMethodCode()
{
return 'ebanking_FI';
}
}
78 changes: 78 additions & 0 deletions src/PaymentMethods/OnlineBankingFinlandPaymentMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php declare(strict_types=1);

namespace Adyen\Shopware\PaymentMethods;

use Adyen\Shopware\Handlers\OnlineBankingFinlandPaymentMethodHandler;

class OnlineBankingFinlandPaymentMethod implements PaymentMethodInterface
{
/**
* {@inheritDoc}
*
* @return string
*/
public function getName(): string
{
return 'Online Banking Finland';
}

/**
* {@inheritDoc}
*
* @return string
*/
public function getDescription(): string
{
return 'Online Banking Finland';
}

/**
* {@inheritDoc}
*
* @return string
*/
public function getPaymentHandler(): string
{
return OnlineBankingFinlandPaymentMethodHandler::class;
}

/**
* {@inheritDoc}
*
* @return string
*/
public function getGatewayCode(): string
{
return 'ADYEN_EBANKING_FI';
}

/**
* {@inheritDoc}
*
* @return string|null
*/
public function getTemplate(): ?string
{
return null;
}

/**
* {@inheritDoc}
*
* @return string
*/
public function getLogo(): string
{
return 'ebanking_FI.png';
}

/**
* {@inheritDoc}
*
* @return string
*/
public function getType(): string
{
return 'redirect';
}
}
3 changes: 2 additions & 1 deletion src/PaymentMethods/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class PaymentMethods
VippsPaymentMethod::class,
MobilePayPaymentMethod::class,
OpenBankingPaymentMethod::class,
BilliePaymentMethod::class
BilliePaymentMethod::class,
OnlineBankingFinlandPaymentMethod::class,
];
}

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/Resources/app/storefront/src/configuration/adyen.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
'scheme', 'ideal', 'sepadirectdebit', 'oneclick', 'dotpay', 'bcmc', 'bcmc_mobile', 'blik', 'klarna_b2b', 'eps', 'facilypay_3x',
'facilypay_4x', 'facilypay_6x', 'facilypay_10x', 'facilypay_12x', 'afterpay_default', 'ratepay',
'ratepay_directdebit', 'giftcard', 'paybright', 'affirm', 'multibanco', 'mbway', 'vipps', 'mobilepay',
'wechatpayQR', 'wechatpayWeb', 'paybybank'
'wechatpayQR', 'wechatpayWeb', 'paybybank', 'ebanking_FI'
],
componentsWithPayButton: {
'applepay': {
Expand Down Expand Up @@ -156,6 +156,7 @@ export default {
'affirm': 'handler_adyen_affirmpaymentmethodhandler',
'paybright': 'handler_adyen_paybrightpaymentmethodhandler',
'paybybank': 'handler_adyen_openbankingpaymentmethodhandler',
'klarna_b2b': 'handler_adyen_billiepaymentmethodhandler'
'klarna_b2b': 'handler_adyen_billiepaymentmethodhandler',
'ebanking_FI': 'handler_adyen_onlinebankingfinlandpaymentmethodhandler'
}
}
4 changes: 4 additions & 0 deletions src/Resources/config/services/payment-handlers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
parent="Adyen\Shopware\Handlers\AbstractPaymentMethodHandler">
<tag name="shopware.payment.method.async"/>
</service>
<service id="Adyen\Shopware\Handlers\OnlineBankingFinlandPaymentMethodHandler"
parent="Adyen\Shopware\Handlers\AbstractPaymentMethodHandler">
<tag name="shopware.payment.method.async"/>
</service>
</services>
</container>

0 comments on commit 613fc6a

Please sign in to comment.