From ca3b08fe27800d7601c8e14ff51d7237e4bf35b9 Mon Sep 17 00:00:00 2001 From: Sushmita Thakur Date: Fri, 19 Jul 2024 17:01:17 +0200 Subject: [PATCH] [ECP-9277-v3] Add support for Billie Payment Method (#519) * [ECP-9277-v3] Billie basic structure - added payment method class, payment method handler, service injection, readme update etc. * [ECP-9277-v3] Added empty lines at the end of files, moved billie installation to plugin version 3.16.0 * [ECP-9277-v3] Remove extra line * [ECP-9277-v3] Update gateway code --------- Co-authored-by: sushmita --- README.md | 1 + src/AdyenPaymentShopware6.php | 20 +++++ src/Handlers/BilliePaymentMethodHandler.php | 37 ++++++++ src/PaymentMethods/BilliePaymentMethod.php | 87 +++++++++++++++++++ src/PaymentMethods/PaymentMethods.php | 3 +- .../app/storefront/src/configuration/adyen.js | 5 +- .../config/services/payment-handlers.xml | 4 + 7 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 src/Handlers/BilliePaymentMethodHandler.php create mode 100644 src/PaymentMethods/BilliePaymentMethod.php diff --git a/README.md b/README.md index 3d2ea905..567ec239 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ The plugin integrates card component (Secured Fields) using Adyen Checkout for a - Apple Pay - Bancontact - Blik + - Billie - Clearpay - Dotpay - Electronic Payment Service (EPS) diff --git a/src/AdyenPaymentShopware6.php b/src/AdyenPaymentShopware6.php index 0dae2971..ad47fd45 100644 --- a/src/AdyenPaymentShopware6.php +++ b/src/AdyenPaymentShopware6.php @@ -170,6 +170,10 @@ public function update(UpdateContext $updateContext): void if (\version_compare($currentVersion, '3.15.0', '<')) { $this->updateTo3150($updateContext); } + + if (\version_compare($currentVersion, '3.16.0', '<')) { + $this->updateTo3160($updateContext); + } } private function addPaymentMethod(PaymentMethods\PaymentMethodInterface $paymentMethod, Context $context): void @@ -501,6 +505,22 @@ private function updateTo3150(UpdateContext $updateContext): void } } + private function updateTo3160(UpdateContext $updateContext): void + { + /* Version 3.16.0 introduces following payment method. + * Billie + */ + $this->addPaymentMethod( + new PaymentMethods\BilliePaymentMethod(), + $updateContext->getContext() + ); + $this->setPaymentMethodIsActive( + true, + $updateContext->getContext(), + new PaymentMethods\BilliePaymentMethod() + ); + } + private function safeCopyAsset($source, $destination): bool { try { diff --git a/src/Handlers/BilliePaymentMethodHandler.php b/src/Handlers/BilliePaymentMethodHandler.php new file mode 100644 index 00000000..536e6d8a --- /dev/null +++ b/src/Handlers/BilliePaymentMethodHandler.php @@ -0,0 +1,37 @@ + + */ + +namespace Adyen\Shopware\Handlers; + +class BilliePaymentMethodHandler extends AbstractPaymentMethodHandler +{ + public static bool $isOpenInvoice = true; + public static bool $supportsManualCapture = true; + public static bool $supportsPartialCapture = true; + + public static function getPaymentMethodCode() + { + return 'klarna_b2b'; + } +} diff --git a/src/PaymentMethods/BilliePaymentMethod.php b/src/PaymentMethods/BilliePaymentMethod.php new file mode 100644 index 00000000..5e059763 --- /dev/null +++ b/src/PaymentMethods/BilliePaymentMethod.php @@ -0,0 +1,87 @@ + + */ + +namespace Adyen\Shopware\PaymentMethods; + +use Adyen\Shopware\Handlers\BilliePaymentMethodHandler; + +class BilliePaymentMethod implements PaymentMethodInterface +{ + + /** + * @inheritDoc + */ + public function getName(): string + { + return 'Billie'; + } + + /** + * @inheritDoc + */ + public function getDescription(): string + { + return 'Buy Now Pay Later with Billie'; + } + + /** + * @inheritDoc + */ + public function getPaymentHandler(): string + { + return BilliePaymentMethodHandler::class; + } + + /** + * @inheritDoc + */ + public function getGatewayCode(): string + { + return 'ADYEN_KLARNA_B2B'; + } + + /** + * @inheritDoc + */ + public function getTemplate(): ?string + { + return null; + } + + /** + * @inheritDoc + */ + public function getLogo(): string + { + return 'billie.png'; + } + + /** + * @inheritDoc + */ + public function getType(): string + { + return 'redirect'; + } +} diff --git a/src/PaymentMethods/PaymentMethods.php b/src/PaymentMethods/PaymentMethods.php index 0571f8d7..25ac411e 100644 --- a/src/PaymentMethods/PaymentMethods.php +++ b/src/PaymentMethods/PaymentMethods.php @@ -69,6 +69,7 @@ class PaymentMethods MbwayPaymentMethod::class, VippsPaymentMethod::class, MobilePayPaymentMethod::class, - OpenBankingPaymentMethod::class + OpenBankingPaymentMethod::class, + BilliePaymentMethod::class ]; } diff --git a/src/Resources/app/storefront/src/configuration/adyen.js b/src/Resources/app/storefront/src/configuration/adyen.js index 92e96cd0..73db72c0 100644 --- a/src/Resources/app/storefront/src/configuration/adyen.js +++ b/src/Resources/app/storefront/src/configuration/adyen.js @@ -22,7 +22,7 @@ export default { updatablePaymentMethods: [ - 'scheme', 'ideal', 'sepadirectdebit', 'oneclick', 'dotpay', 'bcmc', 'bcmc_mobile', 'blik', 'eps', 'facilypay_3x', + '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' @@ -155,6 +155,7 @@ export default { 'vipps': 'handler_adyen_vippspaymentmethodhandler', 'affirm': 'handler_adyen_affirmpaymentmethodhandler', 'paybright': 'handler_adyen_paybrightpaymentmethodhandler', - 'paybybank': 'handler_adyen_openbankingpaymentmethodhandler' + 'paybybank': 'handler_adyen_openbankingpaymentmethodhandler', + 'klarna_b2b': 'handler_adyen_billiepaymentmethodhandler' } } diff --git a/src/Resources/config/services/payment-handlers.xml b/src/Resources/config/services/payment-handlers.xml index bc36af0c..7fa8ee33 100644 --- a/src/Resources/config/services/payment-handlers.xml +++ b/src/Resources/config/services/payment-handlers.xml @@ -195,6 +195,10 @@ parent="Adyen\Shopware\Handlers\AbstractPaymentMethodHandler"> + + +