diff --git a/Cron/OrderSyncStatus.php b/Cron/OrderSyncStatus.php index ac0d4d6f..41e6ccb2 100644 --- a/Cron/OrderSyncStatus.php +++ b/Cron/OrderSyncStatus.php @@ -34,6 +34,7 @@ class OrderSyncStatus "omise_offsite_mobilebanking", "omise_offsite_rabbitlinepay", "omise_offsite_ocbcpao", + "omise_offsite_ocbc_digital", "omise_offsite_grabpay", "omise_offsite_boost", "omise_offsite_duitnowobw", diff --git a/Gateway/Request/APMBuilder.php b/Gateway/Request/APMBuilder.php index 59beffdd..82d106d2 100644 --- a/Gateway/Request/APMBuilder.php +++ b/Gateway/Request/APMBuilder.php @@ -13,6 +13,7 @@ use Omise\Payment\Model\Config\Paynow; use Omise\Payment\Model\Config\Grabpay; use Omise\Payment\Model\Config\Ocbcpao; +use Omise\Payment\Model\Config\OcbcDigital; use Omise\Payment\Model\Config\Touchngo; use Omise\Payment\Helper\ReturnUrlHelper; use Omise\Payment\Model\Config\DuitnowQR; @@ -278,6 +279,12 @@ public function build(array $buildSubject) self::PLATFORM_TYPE => $this->helper->getPlatformType(), ]; break; + case OcbcDigital::CODE: + $paymentInfo[self::SOURCE] = [ + self::SOURCE_TYPE => OcbcDigital::ID, + self::PLATFORM_TYPE => $this->helper->getPlatformType(), + ]; + break; case Grabpay::CODE: $paymentInfo[self::SOURCE] = [ self::SOURCE_TYPE => 'grabpay', diff --git a/Helper/OmiseHelper.php b/Helper/OmiseHelper.php index 7d747dc8..2caa7bd4 100644 --- a/Helper/OmiseHelper.php +++ b/Helper/OmiseHelper.php @@ -20,6 +20,7 @@ use Magento\Store\Model\ScopeInterface; use Omise\Payment\Model\Config\Grabpay; use Omise\Payment\Model\Config\Ocbcpao; +use Omise\Payment\Model\Config\OcbcDigital; use Omise\Payment\Model\Config\Touchngo; use Omise\Payment\Model\Config\DuitnowQR; use Omise\Payment\Model\Config\MaybankQR; @@ -64,6 +65,7 @@ class OmiseHelper extends AbstractHelper Mobilebanking::CODE, Rabbitlinepay::CODE, Ocbcpao::CODE, + OcbcDigital::CODE, Grabpay::CODE, Boost::CODE, DuitnowOBW::CODE, @@ -130,6 +132,7 @@ class OmiseHelper extends AbstractHelper Touchngo::ID => Touchngo::CODE, Rabbitlinepay::ID => Rabbitlinepay::CODE, Ocbcpao::ID => Ocbcpao::CODE, + OcbcDigital::ID => OcbcDigital::CODE, Grabpay::ID => Grabpay::CODE, Boost::ID => Boost::CODE, DuitnowOBW::ID => DuitnowOBW::CODE, @@ -196,6 +199,7 @@ class OmiseHelper extends AbstractHelper Mobilebanking::CODE => "Mobile Banking Payment", Rabbitlinepay::CODE => "Rabbit LINE Pay Payment", Ocbcpao::CODE => "OCBC Pay Anyone Payment", + OcbcDigital::CODE => "OCBC Digital Payment", Grabpay::CODE => "GrabPay Payment", Boost::CODE => "Boost Payment", DuitnowOBW::CODE => "DuitNow Online Banking/Wallets Payment", diff --git a/Model/Config/OcbcDigital.php b/Model/Config/OcbcDigital.php new file mode 100644 index 00000000..d4b46b4b --- /dev/null +++ b/Model/Config/OcbcDigital.php @@ -0,0 +1,18 @@ +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\OcbcDigital + */ + public function testApmBuilder() + { + $this->infoMock->method('getMethod')->willReturn(OcbcDigital::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('mobile_banking_ocbc', $result['source']['type']); + $this->assertEquals('https://omise.co/complete', $result['return_uri']); + } + + /** + * @covers Omise\Payment\Model\Config\OcbcDigital + */ + public function testConstants() + { + $this->assertEquals('omise_offsite_ocbc_digital', OcbcDigital::CODE); + $this->assertEquals('mobile_banking_ocbc', OcbcDigital::ID); + } +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index daae14e5..30ae13f5 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -659,6 +659,35 @@ + + + Enable customers to pay using OCBC Digital payment method + + + Enable OCBC Digital payment method. + Magento\Config\Model\Config\Source\Yesno + payment/omise_offsite_ocbc_digital/active + + + + This controls the title which the user sees during checkout. + payment/omise_offsite_ocbc_digital/title + + + + payment/omise_offsite_ocbc_digital/allowspecific + Magento\Payment\Model\Config\Source\Allspecificcountries + If not set to all, guest customers will not have a billing country and may not be able to check out. + + + + payment/omise_offsite_ocbc_digital/specificcountry + Magento\Directory\Model\Config\Source\Country + + 1 + + + Enable customers to pay using GrabPay payment method diff --git a/etc/config.xml b/etc/config.xml index c8ebef14..3d5a1a6d 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -300,6 +300,20 @@ authorize_capture + + 0 + OCBC Digital + OmiseOcbcDigitalAdapter + 1 + 1 + 1 + 1 + 1 + 1 + 1 + authorize_capture + + 0 GrabPay diff --git a/etc/di.xml b/etc/di.xml index 002f90b1..ee3bdf37 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -863,6 +863,54 @@ + + + + + Omise\Payment\Model\Config\OcbcDigital::CODE + Magento\Payment\Block\Form + Magento\Payment\Block\Info + OmiseAPMOcbcDigitalValueHandlerPool + OmiseAPMOcbcDigitalValidatorPool + OmiseAPMCommandPool + + + + + + + + OmiseAPMOcbcDigitalConfigValueHandler + + + + + + + + OmiseAPMOcbcDigitalCountryValidator + + + + + + + OmiseAPMOcbcDigitalConfig + + + + + + OmiseAPMOcbcDigitalConfig + + + + + + Omise\Payment\Model\Config\OcbcDigital::CODE + + + diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 79a1d154..5137ae90 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -86,6 +86,9 @@ true + + true + true diff --git a/view/frontend/web/css/styles.css b/view/frontend/web/css/styles.css index 9768f6c8..4f072229 100644 --- a/view/frontend/web/css/styles.css +++ b/view/frontend/web/css/styles.css @@ -162,7 +162,16 @@ /** OCBC PAO **/ div.ocbc_pao { - background-image: url('../images/payment_ocbc_pao.png'); + background-image: url('../images/ocbc_pao.png'); + width: 30px; + height: 30px; + float: right; + background-size: contain; + background-repeat: no-repeat; +} + +div.ocbc_digital { + background-image: url('../images/ocbc_digital.png'); width: 30px; height: 30px; float: right; diff --git a/view/frontend/web/images/ocbc_digital.png b/view/frontend/web/images/ocbc_digital.png new file mode 100644 index 00000000..699b34bb Binary files /dev/null and b/view/frontend/web/images/ocbc_digital.png differ diff --git a/view/frontend/web/images/ocbc_pao.png b/view/frontend/web/images/ocbc_pao.png index 0c2d5a33..8324d3cc 100644 Binary files a/view/frontend/web/images/ocbc_pao.png and b/view/frontend/web/images/ocbc_pao.png differ diff --git a/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbc-digital-method.js b/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbc-digital-method.js new file mode 100644 index 00000000..862da171 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbc-digital-method.js @@ -0,0 +1,33 @@ +define( + [ + 'ko', + 'Omise_Payment/js/view/payment/omise-offsite-method-renderer', + 'Magento_Checkout/js/view/payment/default', + 'Magento_Checkout/js/model/quote', + ], + function ( + ko, + Base, + Component, + quote + ) { + 'use strict'; + + return Component.extend(Base).extend({ + defaults: { + template: 'Omise_Payment/payment/offsite-common-form' + }, + + isPlaceOrderActionAllowed: ko.observable(quote.billingAddress() != null), + + code: 'omise_offsite_ocbc_digital', + restrictedToCurrencies: ['sgd'], + logo: { + file: "images/ocbc_digital.png", + width: "80", + height: "30", + name: "ocbc_digital" + } + }); + } +); diff --git a/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbcpao-method.js b/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbcpao-method.js index 5d3fbc20..4d92c414 100644 --- a/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbcpao-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/omise-offsite-ocbcpao-method.js @@ -23,9 +23,9 @@ define( code: 'omise_offsite_ocbcpao', restrictedToCurrencies: ['sgd'], logo: { - file: "images/payment_ocbc_pao.png", - width: "80", - height: "32", + file: "images/ocbc_pao.png", + width: "30", + height: "30", name: "ocbcpao" } });