From b97605629604e89f1d007e097b82920811425cf9 Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:20:17 +0530 Subject: [PATCH 1/9] Delete .github/PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 51 -------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 9f2c48e15..000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,51 +0,0 @@ -#### 1. Objective - -Explain in non-technical terms **WHY this PR is required**. -E.g.: What feature it adds, what problem it solves... - -This section will be used in the release notes. - -**Related information**: -Related issue(s): #< GitHub ticket number > (optional) - -#### 2. Description of change - -A general description of **WHAT changed in the codebase**, but short of an English version of the diff. Assume that people reading this will also be looking at the output of `git diff` and guide them to the highlights. - -Additionally add the reasoning for change details if they're complex or abstract. - -#### 3. Quality assurance - -Specify where and how you tested this and what further testing it might need. - -**🔧 Environments:** - -Specify the details of your test environments, including, for each, the platform version (on which the plugin was run), the Omise plugin version, and the versions of your system software such as PHP or Ruby. - -i.e. -- **Platform version**: Magento CE 2.1.5. -- **Omise plugin version**: Omise-Magento 2.1. -- **PHP version**: 7.0.16. - -**✏ïļ Details:** - -Explain how to manually test this feature. -For example if changes were made in the UI or in the API, explain where and if any specific access is needed. - -#### 4. Impact of the change - -List the steps that must be taken for this PR to work. -E.g.: rake yak:shave, Add "yak_key" to environment variables, ... - -Be sure to include all systems that needs to be changed or which system is affected by the change -(Ex: Requires Elastic search to be installed and configured in secrets.yml). - -Note: Please provide a screenshot if your changed impact to UI. - -#### 5. Priority of change - -Normal, High or Immediate. - -#### 6. Additional Notes - -Any further information that you would like to add. \ No newline at end of file From d13bc0c03d72d8cb9dc869369945a16a51c95aff Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:20:34 +0530 Subject: [PATCH 2/9] Delete .github/CODEOWNERS --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 80dd3f8af..000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @omise/maintainers From e6b7b2238cdc2e38b60876ccf3613c60d9b46f3a Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:37:46 +0530 Subject: [PATCH 3/9] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3173be52..2cecc24f4 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -[![Omise](https://cdn.omise.co/assets/omise.png)](https://www.omise.co/developers) +[![Opn](https://www.opn.ooo/assets/svg/logo-opn-full.svg) ![Code Coverage Badge](./badge.svg) -[Omise](https://www.omise.co/) is a payment service provider operating in Thailand, Japan, and Singapore. +[Opn](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. Omise provides a set of APIs that help merchants of any size accept payments online. -**Omise Magento** is our official plugin providing support for processing payments on Magento through Omise. +**Omise Magento** is our official plugin providing support for processing payments on Magento through Opn. ## Usage -See our [official docs](https://www.omise.co/magento-plugin) for details on installation and configuration. +See our [official docs](https://docs.opn.ooo/magento-plugin) for details on installation and configuration. ## Contributing From b9f61a9d60cc457af3ae1a6da5c42cd5293d1636 Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:38:07 +0530 Subject: [PATCH 4/9] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 2cecc24f4..86fa60b55 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ [![Opn](https://www.opn.ooo/assets/svg/logo-opn-full.svg) -![Code Coverage Badge](./badge.svg) - [Opn](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. Omise provides a set of APIs that help merchants of any size accept payments online. From ac4c9345ea6fe500326b0d48666e135e817d4de8 Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:44:30 +0530 Subject: [PATCH 5/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86fa60b55..41a722365 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ [![Opn](https://www.opn.ooo/assets/svg/logo-opn-full.svg) [Opn](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. -Omise provides a set of APIs that help merchants of any size accept payments online. +Opn Payments provides a set of APIs that help merchants of any size accept payments online. -**Omise Magento** is our official plugin providing support for processing payments on Magento through Opn. +**Omise Magento** is our official plugin providing support for processing payments on Magento through Opn Payments. ## Usage From 0d37f918a6c74a0caf06d5361ab6ea0c7857844a Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:16:28 +0530 Subject: [PATCH 6/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41a722365..c555d4def 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Opn](https://www.opn.ooo/assets/svg/logo-opn-full.svg) +[![Opn Payments](https://www.opn.ooo/assets/svg/logo-opn-full.svg)](https://www.opn.ooo) [Opn](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. Opn Payments provides a set of APIs that help merchants of any size accept payments online. From 0379930228ea1f9e101723eac64551b14a22c8e8 Mon Sep 17 00:00:00 2001 From: muthuswamyopn <95462571+muthuswamyopn@users.noreply.github.com> Date: Thu, 21 Dec 2023 19:16:51 +0530 Subject: [PATCH 7/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c555d4def..8173c2738 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Opn Payments](https://www.opn.ooo/assets/svg/logo-opn-full.svg)](https://www.opn.ooo) -[Opn](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. +[Opn Payments](https://www.opn.ooo) is a payment service provider operating in Thailand, Japan, and Singapore. Opn Payments provides a set of APIs that help merchants of any size accept payments online. From d9a0c8b95a69ca3476f036e0e808b5c454968109 Mon Sep 17 00:00:00 2001 From: Aashish Gurung <101558497+aashishgurung@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:25:20 +0700 Subject: [PATCH 8/9] Add truemoney jumpapp (#466) * Added Truemoney jumpapp * Resolve M2 coding check issues. * Added tests. * Reverting magento version in dev to 2.4.4 * Added more tests. * Added missing @covers annotation * Refactored CapabilitiesConfigProvider and added tests. * Resolve M2 coding standard issue and update tests. * Refactored APMBuildter tests. * Removed Wallet keyword from admin html and translation. * Created new variables to hold the merged values from two different arrays. --------- Co-authored-by: Aashish --- Gateway/Request/APMBuilder.php | 39 ++++- Helper/OmiseHelper.php | 3 +- Model/Config/Truemoney.php | 2 + Model/Ui/CapabilitiesConfigProvider.php | 71 ++++++-- .../Request/APMBuilders/APMBuilderTest.php | 32 ++++ .../APMBuilders}/APMRequestValidatorTest.php | 2 +- .../APMBuilders}/AlipayAPMBuilderTest.php | 30 +--- .../APMBuilders}/AtomeAPMBuilderTest.php | 32 +--- .../APMBuilders}/PayPayAPMBuilderTest.php | 30 +--- .../APMBuilders/TruemoneyAPMBuilderTest.php | 75 +++++++++ Test/Unit/Helper/OmiseHelperTest.php | 14 -- .../Ui/CapabilitiesConfigProviderTest.php | 156 ++++++++++++++++++ etc/adminhtml/system.xml | 6 +- i18n/th_TH.csv | 2 +- .../omise-offsite-truemoney-method.js | 7 +- .../payment/offsite-truemoney-form.html | 33 ++-- 16 files changed, 395 insertions(+), 139 deletions(-) create mode 100644 Test/Unit/Gateway/Request/APMBuilders/APMBuilderTest.php rename Test/Unit/{ => Gateway/Request/APMBuilders}/APMRequestValidatorTest.php (98%) rename Test/Unit/{ => Gateway/Request/APMBuilders}/AlipayAPMBuilderTest.php (52%) rename Test/Unit/{ => Gateway/Request/APMBuilders}/AtomeAPMBuilderTest.php (78%) rename Test/Unit/{ => Gateway/Request/APMBuilders}/PayPayAPMBuilderTest.php (52%) create mode 100644 Test/Unit/Gateway/Request/APMBuilders/TruemoneyAPMBuilderTest.php create mode 100644 Test/Unit/Model/Ui/CapabilitiesConfigProviderTest.php diff --git a/Gateway/Request/APMBuilder.php b/Gateway/Request/APMBuilder.php index d8dee431c..69f6c6719 100644 --- a/Gateway/Request/APMBuilder.php +++ b/Gateway/Request/APMBuilder.php @@ -46,7 +46,6 @@ class APMBuilder implements BuilderInterface { - /** * @var string */ @@ -122,6 +121,16 @@ class APMBuilder implements BuilderInterface */ protected $money; + /** + * @var Capabilities + */ + protected $capabilities; + + /** + * @var Config + */ + protected $config; + /** * @param $helper \Omise\Payment\Helper\OmiseHelper * @param $returnUrl \Omise\Payment\Helper\ReturnUrl @@ -183,12 +192,7 @@ public function build(array $buildSubject) ]; break; case Truemoney::CODE: - $paymentInfo[self::SOURCE] = [ - self::SOURCE_TYPE => 'truemoney', - self::SOURCE_PHONE_NUMBER => $method->getAdditionalInformation( - TruemoneyDataAssignObserver::PHONE_NUMBER - ), - ]; + $paymentInfo[self::SOURCE] = $this->getTruemoneySourceData($method); break; case Conveniencestore::CODE: $paymentInfo[self::SOURCE] = [ @@ -404,4 +408,25 @@ private function getOrderItems($order) } return $itemArray; } + + public function getTruemoneySourceData($method) + { + $isJumpAppEnabled = $this->capabilities->isBackendEnabled(Truemoney::JUMPAPP_ID); + $isWalletEnabled = $this->capabilities->isBackendEnabled(Truemoney::ID); + + if (!$isJumpAppEnabled && $isWalletEnabled) { + return [ + self::SOURCE_TYPE => Truemoney::ID, + self::SOURCE_PHONE_NUMBER => $method->getAdditionalInformation( + TruemoneyDataAssignObserver::PHONE_NUMBER + ) + ]; + } + + // Returning JUMP APP for the following cases: + // Case 1: Both jumpapp and wallet are enabled + // Case 2: jumpapp is enabled and wallet is disabled + // Case 3: Both are disabled. + return [ self::SOURCE_TYPE => Truemoney::JUMPAPP_ID ]; + } } diff --git a/Helper/OmiseHelper.php b/Helper/OmiseHelper.php index 2caa7bd4d..7da7ff375 100644 --- a/Helper/OmiseHelper.php +++ b/Helper/OmiseHelper.php @@ -122,6 +122,7 @@ class OmiseHelper extends AbstractHelper // offsite payment Alipay::ID => Alipay::CODE, Truemoney::ID => Truemoney::CODE, + Truemoney::JUMPAPP_ID => Truemoney::CODE, Pointsciti::ID => Pointsciti::CODE, Fpx::ID => Fpx::CODE, Alipayplus::ALIPAY_ID => Alipayplus::ALIPAY_CODE, @@ -187,7 +188,7 @@ class OmiseHelper extends AbstractHelper Alipay::CODE => "Alipay", Internetbanking::CODE => "Internet Banking Payment", Installment::CODE => "Installment Payment", - Truemoney::CODE => "TrueMoney Wallet Payment", + Truemoney::CODE => "TrueMoney Payment", Pointsciti::CODE => "Citi Pay with Points", Fpx::CODE => "FPX Payment", Alipayplus::ALIPAY_CODE => "Alipay (Alipay+ Partner) Payment", diff --git a/Model/Config/Truemoney.php b/Model/Config/Truemoney.php index c358c29f5..d1d1beff9 100644 --- a/Model/Config/Truemoney.php +++ b/Model/Config/Truemoney.php @@ -15,4 +15,6 @@ class Truemoney extends Config * @var string */ const ID = 'truemoney'; + + const JUMPAPP_ID = 'truemoney_jumpapp'; } diff --git a/Model/Ui/CapabilitiesConfigProvider.php b/Model/Ui/CapabilitiesConfigProvider.php index f99fb1e59..f62b9e969 100644 --- a/Model/Ui/CapabilitiesConfigProvider.php +++ b/Model/Ui/CapabilitiesConfigProvider.php @@ -5,6 +5,7 @@ use Omise\Payment\Helper\OmiseHelper; use Omise\Payment\Model\Capabilities; use Omise\Payment\Model\Config\Shopeepay; +use Omise\Payment\Model\Config\Truemoney; use Omise\Payment\Model\Config\CcGooglePay; use Magento\Store\Model\StoreManagerInterface; use Magento\Checkout\Model\ConfigProviderInterface; @@ -33,7 +34,7 @@ public function __construct( $this->capabilities = $capabilities; $this->_paymentLists = $paymentLists; $this->_storeManager = $storeManager; - $this->helper = $helper; + $this->helper = $helper; } /** @@ -46,12 +47,8 @@ public function getConfig() $listOfActivePaymentMethods = $this->_paymentLists->getActiveList($this->_storeManager->getStore()->getId()); $currency = $this->_storeManager->getStore()->getCurrentCurrencyCode(); $configs = []; - - // Retrieve available backends & methods from capabilities api - $backends = $this->capabilities->getBackendsWithOmiseCode(); - $tokenization_methods = $this->capabilities->getTokenizationMethodsWithOmiseCode(); - $backends = array_merge($backends, $tokenization_methods); $configs['omise_installment_min_limit'] = $this->capabilities->getInstallmentMinLimit($currency); + $configs['omise_payment_list'] = []; foreach ($listOfActivePaymentMethods as $method) { $code = $method->getCode(); @@ -62,19 +59,40 @@ public function getConfig() $configs['card_brands'] = $this->capabilities->getCardBrands(); } - // filter only active backends - if (array_key_exists($code, $backends)) { - if ($code === 'omise_offsite_shopeepay') { - $configs['omise_payment_list'][$code] = $this->getShopeeBackendByType($backends[$code]); - } else { - $configs['omise_payment_list'][$code] = $backends[$code]; - } - } + $this->filterActiveBackends($code, $configs['omise_payment_list']); } return $configs; } + /** + * filter only active backends + * @param $code Payment method code + * @param $paymentList Reference of the payment list + */ + private function filterActiveBackends($code, &$paymentList) + { + // Retrieve available backends & methods from capabilities api + $paymentBackends = $this->capabilities->getBackendsWithOmiseCode(); + $tokenizationMethods = $this->capabilities->getTokenizationMethodsWithOmiseCode(); + $mergedBackends = array_merge($paymentBackends, $tokenizationMethods); + + // filter only active backends + if (!array_key_exists($code, $mergedBackends)) { + return; + } + + if ($code === Shopeepay::CODE) { + $backend = $this->getShopeeBackendByType($mergedBackends[$code]); + } elseif ($code === Truemoney::CODE) { + $backend = $this->getTruemoneyBackendByType($mergedBackends[$code]); + } else { + $backend = $configs['omise_payment_list'][$code] = $mergedBackends[$code]; + } + + $paymentList[$code] = $backend; + } + /** * Return the right ShopeePay backend depending on the platform and availability of * the backend in the capability @@ -116,4 +134,29 @@ private function getShopeeBackendByType($shopeeBackends) // execute if none of the shopee backends were disabled. return $isShopeepayEnabled ? $mpmBackend : $jumpAppBackend; } + + private function getTruemoneyBackendByType($truemoneyBackends) + { + $jumpAppBackend = []; + $walletBackend = []; + + // Since Truemoney will have two types i.e truemoney and truemoney_jumpapp, + // we split and store the type in separate variables. + foreach ($truemoneyBackends as $backend) { + if ($backend->type === Truemoney::JUMPAPP_ID) { + $jumpAppBackend[] = $backend; + } else { + $walletBackend[] = $backend; + } + } + + $isJumpAppEnabled = $this->capabilities->isBackendEnabled(Truemoney::JUMPAPP_ID); + $isWalletEnabled = $this->capabilities->isBackendEnabled(Truemoney::ID); + + if (!$isJumpAppEnabled && $isWalletEnabled) { + return $walletBackend; + } + + return $jumpAppBackend; + } } diff --git a/Test/Unit/Gateway/Request/APMBuilders/APMBuilderTest.php b/Test/Unit/Gateway/Request/APMBuilders/APMBuilderTest.php new file mode 100644 index 000000000..202e64ed5 --- /dev/null +++ b/Test/Unit/Gateway/Request/APMBuilders/APMBuilderTest.php @@ -0,0 +1,32 @@ +helper = $this->getMockBuilder(OmiseHelper::class)->disableOriginalConstructor()->getMock(); + $this->returnUrlHelper = $this->getMockBuilder(ReturnUrlHelper::class)->disableOriginalConstructor()->getMock(); + $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); + $this->capabilities = $this->getMockBuilder(Capabilities::class)->disableOriginalConstructor()->getMock(); + $this->orderMock = $this->getMockBuilder(OrderAdapterInterface::class)->getMock(); + $this->infoMock = $this->getMockBuilder(InfoMock::class)->getMock(); + } +} diff --git a/Test/Unit/APMRequestValidatorTest.php b/Test/Unit/Gateway/Request/APMBuilders/APMRequestValidatorTest.php similarity index 98% rename from Test/Unit/APMRequestValidatorTest.php rename to Test/Unit/Gateway/Request/APMBuilders/APMRequestValidatorTest.php index f263408d1..9f6722270 100644 --- a/Test/Unit/APMRequestValidatorTest.php +++ b/Test/Unit/Gateway/Request/APMBuilders/APMRequestValidatorTest.php @@ -1,6 +1,6 @@ helper = $this->getMockBuilder(OmiseHelper::class)->disableOriginalConstructor()->getMock(); - $this->returnUrlHelper = $this->getMockBuilder(ReturnUrlHelper::class)->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); - $this->capabilities = $this->getMockBuilder(Capabilities::class)->disableOriginalConstructor()->getMock(); - $this->orderMock = $this->getMockBuilder(OrderAdapterInterface::class)->getMock(); - $this->infoMock = $this->getMockBuilder(InfoMock::class)->getMock(); - } - /** * @covers Omise\Payment\Gateway\Request\APMBuilder * @covers Omise\Payment\Model\Config\Alipay diff --git a/Test/Unit/AtomeAPMBuilderTest.php b/Test/Unit/Gateway/Request/APMBuilders/AtomeAPMBuilderTest.php similarity index 78% rename from Test/Unit/AtomeAPMBuilderTest.php rename to Test/Unit/Gateway/Request/APMBuilders/AtomeAPMBuilderTest.php index d9fd44930..f2f11a446 100644 --- a/Test/Unit/AtomeAPMBuilderTest.php +++ b/Test/Unit/Gateway/Request/APMBuilders/AtomeAPMBuilderTest.php @@ -1,46 +1,26 @@ itemMock = $this->getMockBuilder(OrderItemInterface::class)->getMock(); $this->addressMock = $this->getMockBuilder(AddressAdapterInterface::class)->getMock(); - $this->helper = $this->getMockBuilder(OmiseHelper::class)->disableOriginalConstructor()->getMock(); - $this->returnUrlHelper = $this->getMockBuilder(ReturnUrlHelper::class)->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); - $this->capabilities = $this->getMockBuilder(Capabilities::class)->disableOriginalConstructor()->getMock(); - $this->orderMock = $this->getMockBuilder(OrderAdapterInterface::class)->getMock(); $this->orderMock->method('getShippingAddress')->willReturn($this->addressMock); $this->orderMock->method('getItems')->willReturn([$this->itemMock]); $this->orderMock->method('getCurrencyCode')->willReturn('THB'); - $this->infoMock = $this->getMockBuilder(InfoMock::class)->getMock(); } /** diff --git a/Test/Unit/PayPayAPMBuilderTest.php b/Test/Unit/Gateway/Request/APMBuilders/PayPayAPMBuilderTest.php similarity index 52% rename from Test/Unit/PayPayAPMBuilderTest.php rename to Test/Unit/Gateway/Request/APMBuilders/PayPayAPMBuilderTest.php index 51df77fec..4243582ae 100644 --- a/Test/Unit/PayPayAPMBuilderTest.php +++ b/Test/Unit/Gateway/Request/APMBuilders/PayPayAPMBuilderTest.php @@ -1,39 +1,15 @@ helper = $this->getMockBuilder(OmiseHelper::class)->disableOriginalConstructor()->getMock(); - $this->returnUrlHelper = $this->getMockBuilder(ReturnUrlHelper::class)->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); - $this->capabilities = $this->getMockBuilder(Capabilities::class)->disableOriginalConstructor()->getMock(); - $this->orderMock = $this->getMockBuilder(OrderAdapterInterface::class)->getMock(); - $this->infoMock = $this->getMockBuilder(InfoMock::class)->getMock(); - } - /** * @covers Omise\Payment\Gateway\Request\APMBuilder * @covers Omise\Payment\Model\Config\PayPay diff --git a/Test/Unit/Gateway/Request/APMBuilders/TruemoneyAPMBuilderTest.php b/Test/Unit/Gateway/Request/APMBuilders/TruemoneyAPMBuilderTest.php new file mode 100644 index 000000000..6590fb904 --- /dev/null +++ b/Test/Unit/Gateway/Request/APMBuilders/TruemoneyAPMBuilderTest.php @@ -0,0 +1,75 @@ +infoMock->method('getMethod')->willReturn(Truemoney::CODE); + $this->returnUrlHelper->method('create')->willReturn([ + 'url' => 'https://omise.co/complete', + 'token' => '1234' + ]); + + $this->builder = new APMBuilder( + $this->helper, + $this->returnUrlHelper, + $this->config, + $this->capabilities, + new OmiseMoney(), + ); + + $result = $this->builder->build(['payment' => new PaymentDataObject( + $this->orderMock, + $this->infoMock + )]); + + $this->assertEquals(Truemoney::JUMPAPP_ID, $result['source']['type']); + $this->assertEquals('https://omise.co/complete', $result['return_uri']); + } + + /** + * @covers Omise\Payment\Gateway\Request\APMBuilder + */ + public function testApmBuilderForTruemoneyWallet() + { + // isBackendEnabled is called twice in the actual method. Here, + // we are setting the return values on those consecutive calls + $this->capabilities->method('isBackendEnabled') + ->will($this->onConsecutiveCalls(false, true)); + + $this->capabilities->method('isBackendEnabled') + ->willReturn(true); + $this->infoMock->method('getMethod')->willReturn(Truemoney::CODE); + $this->returnUrlHelper->method('create')->willReturn([ + 'url' => 'https://omise.co/complete', + 'token' => '1234' + ]); + + $this->builder = new APMBuilder( + $this->helper, + $this->returnUrlHelper, + $this->config, + $this->capabilities, + new OmiseMoney(), + ); + + $result = $this->builder->build(['payment' => new PaymentDataObject( + $this->orderMock, + $this->infoMock + )]); + + $this->assertEquals(Truemoney::ID, $result['source']['type']); + $this->assertEquals('https://omise.co/complete', $result['return_uri']); + } +} diff --git a/Test/Unit/Helper/OmiseHelperTest.php b/Test/Unit/Helper/OmiseHelperTest.php index d0188ec85..4f7590d8b 100644 --- a/Test/Unit/Helper/OmiseHelperTest.php +++ b/Test/Unit/Helper/OmiseHelperTest.php @@ -2,23 +2,9 @@ namespace Omise\Payment\Test\Unit\Helper; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Omise\Payment\Helper\OmiseHelper; -use Omise\Payment\Model\Config\Internetbanking; -use Omise\Payment\Model\Config\Alipay; -use Omise\Payment\Model\Config\Pointsciti; -use Omise\Payment\Model\Config\Installment; use Omise\Payment\Model\Config\Truemoney; -use Omise\Payment\Model\Config\Fpx; use Omise\Payment\Model\Config\Paynow; -use Omise\Payment\Model\Config\Promptpay; -use Omise\Payment\Model\Config\Tesco; -use Omise\Payment\Model\Config\Alipayplus; -use Omise\Payment\Model\Config\Mobilebanking; -use Omise\Payment\Model\Config\Rabbitlinepay; -use Omise\Payment\Model\Config\Ocbcpao; -use Omise\Payment\Model\Config\Grabpay; -use Omise\Payment\Model\Config\Config; use Omise\Payment\Model\Config\CcGooglePay; use Omise\Payment\Model\Config\Conveniencestore; diff --git a/Test/Unit/Model/Ui/CapabilitiesConfigProviderTest.php b/Test/Unit/Model/Ui/CapabilitiesConfigProviderTest.php new file mode 100644 index 000000000..60b2a578d --- /dev/null +++ b/Test/Unit/Model/Ui/CapabilitiesConfigProviderTest.php @@ -0,0 +1,156 @@ +storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->capabilitiesMock = $this->getMockBuilder(Capabilities::class) + ->disableOriginalConstructor() + ->getMock(); + $this->helperMock = $this->getMockBuilder(OmiseHelper::class) + ->disableOriginalConstructor() + ->getMock(); + $this->paymentListsMock = $this->getMockBuilder(PaymentMethodListInterface::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @covers Omise\Payment\Model\Ui\CapabilitiesConfigProvider + */ + public function testGetTruemoneyBackendByType() + { + $provider = new CapabilitiesConfigProvider( + $this->capabilitiesMock, + $this->paymentListsMock, + $this->storeManagerMock, + $this->helperMock + ); + + $expected = [ + (object)[ + "type" => "truemoney_jumpapp", + "currencies" => [ "thb" ], + "amount" => [ + "min" => 2000, + "max" => 500000000000 + ] + ] + ]; + + $result = $this->invokeMethod($provider, 'getTruemoneyBackendByType', [$expected]); + + $this->assertEquals($expected, $result); + } + + /** + * @dataProvider activeBackends + * @covers Omise\Payment\Model\Ui\CapabilitiesConfigProvider + */ + public function testFilterActiveBackends($code, $backend) + { + $expected = [ $code => $backend ]; + $this->capabilitiesMock->method('getBackendsWithOmiseCode') + ->willReturn($expected); + + $this->capabilitiesMock->method('getTokenizationMethodsWithOmiseCode') + ->willReturn([]); + + $provider = new CapabilitiesConfigProvider( + $this->capabilitiesMock, + $this->paymentListsMock, + $this->storeManagerMock, + $this->helperMock + ); + + $paymentList = []; + $this->invokeMethod($provider, 'filterActiveBackends', [$code, &$paymentList]); + $this->assertEquals($expected, $paymentList); + } + + /** + * Call protected/private method of a class. + * + * @param object &$object Instantiated object that we will run method on. + * @param string $methodName Method name to call + * @param array $parameters Array of parameters to pass into method. + * + * @return mixed Method return. + */ + public function invokeMethod(&$object, $methodName, array $parameters) + { + $reflection = new \ReflectionClass(get_class($object)); + $method = $reflection->getMethod($methodName); + $method->setAccessible(true); + + return $method->invokeArgs($object, $parameters); + } + + /** + * Data provider for testFilterActiveBackends + */ + public function activeBackends() + { + return [ + [ + Truemoney::CODE, + [ + (object)[ + 'type' => Truemoney::JUMPAPP_ID, + 'currencies' => [ 'thb' ], + 'amount' => [ + 'min' => 2000, + 'max' => 500000000000 + ] + ] + ] + ], + [ + Shopeepay::CODE, + [ + (object)[ + 'type' => Shopeepay::JUMPAPP_ID, + 'currencies' => [ 'thb', 'sgd', 'myr' ], + 'amount' => [ + 'min' => 2000, + 'max' => 500000000000 + ] + ] + ] + ], + [ + Rabbitlinepay::CODE, + [ + (object)[ + 'type' => Rabbitlinepay::ID, + 'currencies' => [ 'thb' ], + 'amount' => [ + 'min' => 2000, + 'max' => 500000000000 + ] + ] + ] + ] + ]; + } +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index ebe8fc25b..3c3e2dd33 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -267,11 +267,11 @@ - - Enable customers to pay using TrueMoney wallet payment method + + Enable customers to pay using TrueMoney payment method - Enable TrueMoney wallet payment method. + Enable TrueMoney payment method. Magento\Config\Model\Config\Source\Yesno payment/omise_offsite_truemoney/active diff --git a/i18n/th_TH.csv b/i18n/th_TH.csv index 513831dc8..cb94ba5de 100644 --- a/i18n/th_TH.csv +++ b/i18n/th_TH.csv @@ -34,7 +34,7 @@ "Expiry date", "āļ§āļąāļ™āļŦāļĄāļ”āļ­āļēāļĒāļļ" "Security code", "āļĢāļŦāļąāļŠāļŦāļĨāļąāļ‡āļšāļąāļ•āļĢ" "Select a card to proceed", "āđ€āļĨāļ·āļ­āļāļšāļąāļ•āļĢāđ€āļžāļ·āđˆāļ­āļ”āļģāđ€āļ™āļīāļ™āļāļēāļĢāļ•āđˆāļ­" -"True Money Phone Number", "āđ€āļšāļ­āļĢāđŒāđ‚āļ—āļĢāļĻāļąāļžāļ—āđŒāļ—āļĩāđˆāđƒāļŠāđ‰āļŠāļĄāļąāļ„āļĢāļšāļąāļāļŠāļĩ TrueMoney Wallet" +"True Money Phone Number", "āđ€āļšāļ­āļĢāđŒāđ‚āļ—āļĢāļĻāļąāļžāļ—āđŒāļ—āļĩāđˆāđƒāļŠāđ‰āļŠāļĄāļąāļ„āļĢāļšāļąāļāļŠāļĩ TrueMoney" "Use a new card", "āđƒāļŠāđ‰āļšāļąāļ•āļĢāđƒāļŦāļĄāđˆ" "secure_form_banner_message", "Opn Payments : āļ­āļąāļ›āđ€āļ”āļ•āļ›āļĨāļąāđŠāļāļ­āļīāļ™āļ‚āļ­āļ‡āļ„āļļāļ“āđ€āļ›āđ‡āļ™āđ€āļ§āļ­āļĢāđŒāļŠāļąāļ™āļĨāđˆāļēāļŠāļļāļ”āđ€āļžāļ·āđˆāļ­āđ€āļ›āļīāļ”āđƒāļŠāđ‰āļ‡āļēāļ™ Secure Form āđāļĨāļ°āļĄāļ­āļšāļ„āļ§āļēāļĄāļ›āļĨāļ­āļ”āļ āļąāļĒāļŠāļđāļ‡āļŠāļļāļ”āđƒāļŦāđ‰āļāļąāļšāļ‚āđ‰āļ­āļĄāļđāļĨāļ‚āļ­āļ‡āļĨāļđāļāļ„āđ‰āļē āđ‚āļ”āļĒāļŦāļĨāļąāļ‡āļˆāļēāļāļ—āļģāļāļēāļĢāļ­āļąāļ›āđ€āļāļĢāļ” āļ„āļļāļ“āļˆāļ°āļ•āđ‰āļ­āļ‡āļ›āļĢāļąāļšāđāļ•āđˆāļ‡āđāļšāļšāļŸāļ­āļĢāđŒāļĄāļāļēāļĢāļŠāļģāļĢāļ°āđ€āļ‡āļīāļ™āļ”āđ‰āļ§āļĒāļšāļąāļ•āļĢāđ€āļ„āļĢāļ”āļīāļ•āđƒāļŦāļĄāđˆāļ­āļĩāļāļ„āļĢāļąāđ‰āļ‡ āđ€āļĢāļĩāļĒāļ™āļĢāļđāđ‰āđ€āļžāļīāđˆāļĄāđ€āļ•āļīāļĄāđ€āļāļĩāđˆāļĒāļ§āļāļąāļšāļāļēāļĢāđ€āļ›āļīāļ”āđƒāļŠāđ‰āļ‡āļēāļ™ Secure Form" "Complimentary products cannot be billed", "āļŠāļīāļ™āļ„āđ‰āļēāļ—āļĩāđˆāļĢāļ°āļĨāļķāļāđ„āļĄāđˆāļŠāļēāļĄāļēāļĢāļ–āđ€āļĢāļĩāļĒāļāđ€āļāđ‡āļšāđ€āļ‡āļīāļ™āđ„āļ”āđ‰" diff --git a/view/frontend/web/js/view/payment/method-renderer/omise-offsite-truemoney-method.js b/view/frontend/web/js/view/payment/method-renderer/omise-offsite-truemoney-method.js index 5a40d29b6..cfe134c7d 100644 --- a/view/frontend/web/js/view/payment/method-renderer/omise-offsite-truemoney-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/omise-offsite-truemoney-method.js @@ -59,8 +59,13 @@ define( getCustomerSavedPhoneNumber: function () { let q = quote && quote.billingAddress(); return q ? q.telephone : ''; - } + }, + isWalletEnabled: function () { + const truemoneyArrays = checkoutConfig.omise_payment_list['omise_offsite_truemoney'] + .map(truemoney => truemoney.type) + return !truemoneyArrays.includes('truemoney_jumpapp'); + } }); } ); diff --git a/view/frontend/web/template/payment/offsite-truemoney-form.html b/view/frontend/web/template/payment/offsite-truemoney-form.html index 5eb0f5fdf..9e17ef66d 100644 --- a/view/frontend/web/template/payment/offsite-truemoney-form.html +++ b/view/frontend/web/template/payment/offsite-truemoney-form.html @@ -2,13 +2,14 @@
+ 'id': getCode() + }, + value: getCode(), + checked: isChecked, + click: selectPaymentMethod, + visible: isRadioButtonVisible(), + enable: isActive()" + /> @@ -21,24 +22,22 @@
- - - - +
+ data-bind="attr: { + id: getCode() + 'phoneNumber', + placeholder: getCustomerSavedPhoneNumber() + }, + value: trueMoneyPhoneNumber, + "/>
+
From dbceab2222512b807f75f046f6d5814f2b9f5b3c Mon Sep 17 00:00:00 2001 From: Aashish Date: Tue, 23 Jan 2024 11:53:01 +0700 Subject: [PATCH 9/9] Updated metadata for v3.6.0 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb73a9b73..add828708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## [v3.6.0 _(Jan, 23, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.6.0) +- Add truemoney jumpapp. (PR: [#466](https://github.com/omise/omise-magento/pull/466)) +- Updated README.md. (PR: [#464](https://github.com/omise/omise-magento/pull/464)) + ## [v3.5.2 _(Dec, 7, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.5.2) - Updated installment interest rates. (PR: [#460](https://github.com/omise/omise-magento/pull/460)) diff --git a/composer.json b/composer.json index bf30c523b..364de48d6 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "email": "support@omise.co" } ], - "version": "3.5.2", + "version": "3.6.0", "minimum-stability": "stable", "type": "magento2-module", "license": "MIT", diff --git a/etc/module.xml b/etc/module.xml index e580a8506..f653edd42 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +