From 1b51251692f00165ffca16146cfb1eb69f21b63b Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Thu, 24 Oct 2024 22:40:24 +0100 Subject: [PATCH 1/5] chore: Bump version 1.6.0 -> 1.6.1 --- bumpver.toml | 2 +- composer.json | 2 +- etc/config.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bumpver.toml b/bumpver.toml index 1cc77b08..6548ff96 100644 --- a/bumpver.toml +++ b/bumpver.toml @@ -1,5 +1,5 @@ [tool.bumpver] -current_version = "1.6.0" +current_version = "1.6.1" version_pattern = "MAJOR.MINOR.PATCH[-TAGNUM]" commit_message = "chore: Bump version {old_version} -> {new_version}" commit = true diff --git a/composer.json b/composer.json index 75f3ade9..3a12e168 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "two-inc/magento2", "description": "Two B2B BNPL payments extension", "type": "magento2-module", - "version": "1.6.0", + "version": "1.6.1", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/config.xml b/etc/config.xml index 3a242fc0..5c38cf52 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -11,7 +11,7 @@ 1 - 1.6.0 + 1.6.1 Business invoice - 30 days sandbox FUNDED_INVOICE From 30d7658baec124b939d5cf1f2f3cc3c24d715549 Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Thu, 24 Oct 2024 22:56:06 +0100 Subject: [PATCH 2/5] chore: Update payment terms URL --- Model/Ui/ConfigProvider.php | 9 ++++--- .../payment/method-renderer/two_payment.js | 24 +++++++++++-------- .../web/template/payment/two_payment.html | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php index 2a2e7f1b..3bdb30bb 100755 --- a/Model/Ui/ConfigProvider.php +++ b/Model/Ui/ConfigProvider.php @@ -64,11 +64,11 @@ public function getConfig(): array $provider = $this->configRepository::PROVIDER; $tryAgainLater = __('Please try again later.'); $soleTraderaccountCouldNotBeVerified = __('Your sole trader account could not be verified.'); - // Set isTermsAndConditionsEnabled based on provider + // Set isPaymentTermsEnabled based on provider $paymentTerms = __("Payment Terms"); - $paymentTermsLink = $this->configRepository::PAYMENT_TERMS_LINK; + $paymentTermsLink = $this->configRepository->getCheckoutPageUrl() . '/terms'; // This check here is present to only enable the terms and conditions - $isTermsAndConditionsEnabled = !empty($paymentTermsLink); + $isPaymentTermsEnabled = !empty($paymentTermsLink); return [ 'payment' => [ @@ -87,8 +87,7 @@ public function getConfig(): array 'isOrderNoteFieldEnabled' => $this->configRepository->isOrderNoteEnabled(), 'isPONumberFieldEnabled' => $this->configRepository->isPONumberEnabled(), 'isTwoLinkEnabled' => $this->configRepository->isTwoLinkEnabled(), - 'isTermsAndConditionsEnabled' => $isTermsAndConditionsEnabled, - 'paymentTermsLink' => $paymentTermsLink, + 'isPaymentTermsEnabled' => $isPaymentTermsEnabled, 'redirectMessage' => __( 'You will be redirected to %1 when you place order.', $provider diff --git a/view/frontend/web/js/view/payment/method-renderer/two_payment.js b/view/frontend/web/js/view/payment/method-renderer/two_payment.js index 9fa16919..dae4d258 100755 --- a/view/frontend/web/js/view/payment/method-renderer/two_payment.js +++ b/view/frontend/web/js/view/payment/method-renderer/two_payment.js @@ -44,8 +44,8 @@ define([ redirectMessage: config.redirectMessage, paymentTermsMessage: config.paymentTermsMessage, termsNotAcceptedMessage: config.termsNotAcceptedMessage, - isTermsAndConditionsEnabled: config.isTermsAndConditionsEnabled, - termsAccepted: ko.observable(false), + isPaymentTermsEnabled: config.isPaymentTermsEnabled, + isPaymentTermsAccepted: ko.observable(false), orderIntentApprovedMessage: config.orderIntentApprovedMessage, orderIntentDeclinedMessage: config.orderIntentDeclinedMessage, generalErrorMessage: config.generalErrorMessage, @@ -86,10 +86,11 @@ define([ this.configureFormValidation(); this.popupMessageListener(); }, - checkTerms: function (data, event) { - // Update the termsAccepted observable based on the checkbox state - // And added logging - console.debug({ logger: 'checkTerms', termsAccepted: this.termsAccepted() }); + logIsPaymentsAccepted: function (data, event) { + console.debug({ + logger: 'logIsPaymentsAccepted', + isPaymentTermsAccepted: this.isPaymentTermsAccepted() + }); }, fillCompanyData: function ({ companyId, companyName }) { console.debug({ logger: 'twoPayment.fillCompanyData', companyId, companyName }); @@ -207,17 +208,20 @@ define([ } }, placeOrder: function (data, event) { - // Additional logging to check termsAccepted - console.debug({ logger: 'placeOrder', termsAccepted: this.termsAccepted() }); + // Additional logging to check isPaymentTermsAccepted + console.debug({ + logger: 'placeOrder', + isPaymentTermsAccepted: this.isPaymentTermsAccepted() + }); if (event) event.preventDefault(); - if (this.isTermsAndConditionsEnabled && !this.termsAccepted()) { + if (this.isPaymentTermsEnabled && !this.isPaymentTermsAccepted()) { this.processTermsNotAcceptedErrorResponse(); return; } if ( this.validate() && additionalValidators.validate() && - this.termsAccepted() === true && + this.isPaymentTermsAccepted() === true && this.isPlaceOrderActionAllowed() === true ) this.placeOrderBackend(); diff --git a/view/frontend/web/template/payment/two_payment.html b/view/frontend/web/template/payment/two_payment.html index d81c0e51..1c0a5cc5 100755 --- a/view/frontend/web/template/payment/two_payment.html +++ b/view/frontend/web/template/payment/two_payment.html @@ -236,12 +236,12 @@ /> - +
From 8586d6dadee9f831f2319cb4430f16192153cfb8 Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Thu, 24 Oct 2024 22:56:17 +0100 Subject: [PATCH 3/5] chore: Bump version 1.6.1 -> 1.6.2 --- bumpver.toml | 2 +- composer.json | 2 +- etc/config.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bumpver.toml b/bumpver.toml index 6548ff96..9f81bc96 100644 --- a/bumpver.toml +++ b/bumpver.toml @@ -1,5 +1,5 @@ [tool.bumpver] -current_version = "1.6.1" +current_version = "1.6.2" version_pattern = "MAJOR.MINOR.PATCH[-TAGNUM]" commit_message = "chore: Bump version {old_version} -> {new_version}" commit = true diff --git a/composer.json b/composer.json index 3a12e168..9def3eeb 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "two-inc/magento2", "description": "Two B2B BNPL payments extension", "type": "magento2-module", - "version": "1.6.1", + "version": "1.6.2", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/config.xml b/etc/config.xml index 5c38cf52..805bba04 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -11,7 +11,7 @@ 1 - 1.6.1 + 1.6.2 Business invoice - 30 days sandbox FUNDED_INVOICE From 85796b250e6d0337ae64381a7cc8a0651602cee3 Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Thu, 24 Oct 2024 23:26:21 +0100 Subject: [PATCH 4/5] fix: Two pending status --- Model/Two.php | 5 ++--- Model/Ui/ConfigProvider.php | 5 +---- Plugin/Model/Sales/AfterPlaceOrder.php | 2 +- Setup/Patch/Data/OrderStatuses.php | 5 +++-- Setup/Patch/Data/PendingPaymentStatus.php | 15 ++++++++++++--- i18n/en_US.csv | 2 -- i18n/nb_NO.csv | 2 -- i18n/nl_NL.csv | 2 -- i18n/sv_SE.csv | 2 -- 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Model/Two.php b/Model/Two.php index b1e93d99..ca7398e4 100755 --- a/Model/Two.php +++ b/Model/Two.php @@ -45,8 +45,7 @@ class Two extends AbstractMethod public const STATUS_NEW = 'two_new'; public const STATUS_FAILED = 'two_failed'; - public const STATUS_APPROVED = 'APPROVED'; - public const STATUS_TWO_PENDING = 'pending_two_payment'; + public const STATUS_PENDING = 'pending_two_payment'; /** * @var RequestInterface */ @@ -218,7 +217,7 @@ public function authorize(InfoInterface $payment, $amount) throw new LocalizedException($error); } - if ($response['status'] !== static::STATUS_APPROVED) { + if ($response['status'] !== 'APPROVED') { $this->logRepository->addDebugLog( sprintf('Order was not accepted by %s', $this->configRepository::PROVIDER), $response diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php index 3bdb30bb..103126a0 100755 --- a/Model/Ui/ConfigProvider.php +++ b/Model/Ui/ConfigProvider.php @@ -64,11 +64,8 @@ public function getConfig(): array $provider = $this->configRepository::PROVIDER; $tryAgainLater = __('Please try again later.'); $soleTraderaccountCouldNotBeVerified = __('Your sole trader account could not be verified.'); - // Set isPaymentTermsEnabled based on provider $paymentTerms = __("Payment Terms"); $paymentTermsLink = $this->configRepository->getCheckoutPageUrl() . '/terms'; - // This check here is present to only enable the terms and conditions - $isPaymentTermsEnabled = !empty($paymentTermsLink); return [ 'payment' => [ @@ -87,7 +84,7 @@ public function getConfig(): array 'isOrderNoteFieldEnabled' => $this->configRepository->isOrderNoteEnabled(), 'isPONumberFieldEnabled' => $this->configRepository->isPONumberEnabled(), 'isTwoLinkEnabled' => $this->configRepository->isTwoLinkEnabled(), - 'isPaymentTermsEnabled' => $isPaymentTermsEnabled, + 'isPaymentTermsEnabled' => true, 'redirectMessage' => __( 'You will be redirected to %1 when you place order.', $provider diff --git a/Plugin/Model/Sales/AfterPlaceOrder.php b/Plugin/Model/Sales/AfterPlaceOrder.php index 9017b51a..0b928455 100644 --- a/Plugin/Model/Sales/AfterPlaceOrder.php +++ b/Plugin/Model/Sales/AfterPlaceOrder.php @@ -33,7 +33,7 @@ public function afterPlace(Order $subject, Order $order) { if ($order->getPayment()->getMethod() == Two::CODE) { $order->setState(Order::STATE_PENDING_PAYMENT); - $order->setStatus(Two::STATUS_TWO_PENDING); + $order->setStatus(Two::STATUS_PENDING); $this->orderRepository->save($order); } return $order; diff --git a/Setup/Patch/Data/OrderStatuses.php b/Setup/Patch/Data/OrderStatuses.php index d6345429..22de6ce7 100755 --- a/Setup/Patch/Data/OrderStatuses.php +++ b/Setup/Patch/Data/OrderStatuses.php @@ -28,6 +28,7 @@ class OrderStatuses implements DataPatchInterface private $moduleDataSetup; /** + * @param ConfigRepository $configRepository * @param ModuleDataSetupInterface $moduleDataSetup */ public function __construct( @@ -47,8 +48,8 @@ public function apply() $data = []; $statuses = [ - Two::STATUS_NEW => __('%1 New Order', $this->configRepository::PROVIDER), - Two::STATUS_FAILED => __('%1 Failed', $this->configRepository::PROVIDER), + Two::STATUS_NEW => sprintf('%s New Order', $this->configRepository::PROVIDER), + Two::STATUS_FAILED => sprintf('%s Failed', $this->configRepository::PROVIDER), ]; foreach ($statuses as $code => $info) { diff --git a/Setup/Patch/Data/PendingPaymentStatus.php b/Setup/Patch/Data/PendingPaymentStatus.php index 28deaafb..06161459 100644 --- a/Setup/Patch/Data/PendingPaymentStatus.php +++ b/Setup/Patch/Data/PendingPaymentStatus.php @@ -10,23 +10,32 @@ use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\DataPatchInterface; use Two\Gateway\Model\Two; +use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository; /** * PendingPaymentStatus Data Patch */ class PendingPaymentStatus implements DataPatchInterface { + /** + * @var ConfigRepository + */ + private $configRepository; + /** * @var ModuleDataSetupInterface */ private $moduleDataSetup; /** + * @param ConfigRepository $configRepository * @param ModuleDataSetupInterface $moduleDataSetup */ public function __construct( + ConfigRepository $configRepository, ModuleDataSetupInterface $moduleDataSetup ) { + $this->configRepository = $configRepository; $this->moduleDataSetup = $moduleDataSetup; } @@ -44,13 +53,13 @@ public function apply() $this->moduleDataSetup->getConnection()->insert( $this->moduleDataSetup->getTable('sales_order_status'), - ['status' => Two::STATUS_TWO_PENDING, 'label' => 'Two Pending'] + ['status' => Two::STATUS_PENDING, 'label' => sprintf('%s Pending', $this->configRepository::PROVIDER)] ); $this->moduleDataSetup->getConnection()->insert( $this->moduleDataSetup->getTable('sales_order_status_state'), [ - 'status' => Two::STATUS_TWO_PENDING, + 'status' => Two::STATUS_PENDING, 'state' => 'pending_payment', 'is_default' => 1, 'visible_on_front' => 0 @@ -87,7 +96,7 @@ private function isStatusAdded(): bool $select = $this->moduleDataSetup->getConnection()->select() ->from($this->moduleDataSetup->getTable('sales_order_status'), 'status') ->where('status = :status'); - $bind = [':status' => Two::STATUS_TWO_PENDING]; + $bind = [':status' => Two::STATUS_PENDING]; return (bool)$this->moduleDataSetup->getConnection()->fetchOne($select, $bind); } } diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 7e9efecf..d160fc00 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 Credit Note" "%1 Decline reason: %2","%1 Decline reason: %2" "%1 Details","%1 Details" -"%1 Failed","%1 Failed" "%1 Invoice","%1 Invoice" -"%1 New Order","%1 New Order" "%1 Order ID","%1 Order ID" "%1 [Trace ID: %2]","%1 [Trace ID: %2]" "%1 order has been marked as cancelled","%1 order has been marked as cancelled" diff --git a/i18n/nb_NO.csv b/i18n/nb_NO.csv index ab205798..c382837c 100644 --- a/i18n/nb_NO.csv +++ b/i18n/nb_NO.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 kreditnota" "%1 Decline reason: %2","%1 Årsak til avvisning: %2" "%1 Details","%1 Detaljer" -"%1 Failed","%1 Mislyktes" "%1 Invoice","%1 Faktura" -"%1 New Order","%1 Ny ordre" "%1 Order ID","%1 Bestillings-ID" "%1 [Trace ID: %2]","%1 [Sporings-ID: %2]" "%1 order has been marked as cancelled","%1 ordre er merket som kansellert" diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index c0b5bd18..543ea195 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 Creditnota" "%1 Decline reason: %2","%1 Reden voor afwijzing: %2" "%1 Details","%1 Gegevens" -"%1 Failed","%1 Mislukt" "%1 Invoice","%1 Factuur" -"%1 New Order","%1 Nieuwe bestelling" "%1 Order ID","%1 Bestelnummer" "%1 [Trace ID: %2]","%1 [Trace-ID: %2]" "%1 order has been marked as cancelled","%1 bestelling is gemarkeerd als geannuleerd" diff --git a/i18n/sv_SE.csv b/i18n/sv_SE.csv index 52b6aea4..0ea3c2c5 100644 --- a/i18n/sv_SE.csv +++ b/i18n/sv_SE.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 Kreditnota" "%1 Decline reason: %2","%1 Orsak till avslag: %2" "%1 Details","%1 Detaljer" -"%1 Failed","%1 Misslyckades" "%1 Invoice","%1 Faktura" -"%1 New Order","%1 Ny beställning" "%1 Order ID","%1 Beställnings-ID" "%1 [Trace ID: %2]","%1 [Spår-ID: %2]" "%1 order has been marked as cancelled","%1 beställning har markerats som avbruten" From 80d9af453039e03d495ff57a322dbc0414d8256a Mon Sep 17 00:00:00 2001 From: Bharat Kunwar Date: Thu, 24 Oct 2024 23:42:17 +0100 Subject: [PATCH 5/5] chore: Bump version 1.6.2 -> 1.6.3 --- bumpver.toml | 2 +- composer.json | 2 +- etc/config.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bumpver.toml b/bumpver.toml index 9f81bc96..85fadc13 100644 --- a/bumpver.toml +++ b/bumpver.toml @@ -1,5 +1,5 @@ [tool.bumpver] -current_version = "1.6.2" +current_version = "1.6.3" version_pattern = "MAJOR.MINOR.PATCH[-TAGNUM]" commit_message = "chore: Bump version {old_version} -> {new_version}" commit = true diff --git a/composer.json b/composer.json index 9def3eeb..026b7518 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "two-inc/magento2", "description": "Two B2B BNPL payments extension", "type": "magento2-module", - "version": "1.6.2", + "version": "1.6.3", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/config.xml b/etc/config.xml index 805bba04..e2f1c709 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -11,7 +11,7 @@ 1 - 1.6.2 + 1.6.3 Business invoice - 30 days sandbox FUNDED_INVOICE