Skip to content

Commit

Permalink
Merge pull request #444 from omise/release-v3.3.0
Browse files Browse the repository at this point in the history
Bump v3.3.0
  • Loading branch information
ajzkk authored Sep 21, 2023
2 parents 35bc747 + 2a39e6b commit 6beafdd
Show file tree
Hide file tree
Showing 17 changed files with 249 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [v3.3.0 _(Sep, 21, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.3.0)
- Added OCBC Digital Payment. (PR: [#440](https://github.com/omise/omise-magento/pull/443))

## [v3.2.0 _(Aug, 22, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.2.0)
- Enabled AlipayHK, Kakaopay and Touch 'N Go for Thailand PSP. (PR: [#440](https://github.com/omise/omise-magento/pull/440))

Expand Down
1 change: 1 addition & 0 deletions Cron/OrderSyncStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions Gateway/Request/APMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions Helper/OmiseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,6 +65,7 @@ class OmiseHelper extends AbstractHelper
Mobilebanking::CODE,
Rabbitlinepay::CODE,
Ocbcpao::CODE,
OcbcDigital::CODE,
Grabpay::CODE,
Boost::CODE,
DuitnowOBW::CODE,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions Model/Config/OcbcDigital.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace Omise\Payment\Model\Config;

use Omise\Payment\Model\Config\Config;

class OcbcDigital extends Config
{
/**
* @var string
*/
const CODE = 'omise_offsite_ocbc_digital';

/**
* Backends identifier
* @var string
*/
const ID = "mobile_banking_ocbc";
}
74 changes: 74 additions & 0 deletions Test/Unit/OcbcDigitalAPMBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Omise\Payment\Test\Unit;

use Magento\Payment\Gateway\Data\OrderAdapterInterface;
use Magento\Payment\Gateway\Data\PaymentDataObject;
use Omise\Payment\Gateway\Request\APMBuilder;
use Omise\Payment\Helper\OmiseHelper;
use Omise\Payment\Helper\OmiseMoney;
use Omise\Payment\Helper\ReturnUrlHelper;
use Omise\Payment\Model\Capabilities;
use Omise\Payment\Model\Config\Config;
use Omise\Payment\Model\Config\OcbcDigital;
use PHPUnit\Framework\TestCase;
use Omise\Payment\Test\Mock\InfoMock;

class OcbcDigitalAPMBuilderTest extends TestCase
{
private $builder;
private $helper;
private $returnUrlHelper;
private $config;
private $capabilities;
private $orderMock;
private $infoMock;

protected function setUp(): void
{
$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->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);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"email": "[email protected]"
}
],
"version": "3.2.0",
"version": "3.3.0",
"minimum-stability": "stable",
"type": "magento2-module",
"license": "MIT",
Expand Down
29 changes: 29 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,35 @@
</depends>
</field>
</group>
<group id="omise_offsite_ocbc_digital" translate="label" sortOrder="495" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable OCBC Digital Payment</label>
<comment>Enable customers to pay using OCBC Digital payment method</comment>
<field id="active" translate="label comment" type="select" sortOrder="496" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable/Disable</label>
<comment>Enable OCBC Digital payment method.</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/omise_offsite_ocbc_digital/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="497" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<comment>This controls the title which the user sees during checkout.</comment>
<config_path>payment/omise_offsite_ocbc_digital/title</config_path>
</field>
<field id="allowspecific" translate="label comment" type="select" sortOrder="498" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allowed Countries</label>
<config_path>payment/omise_offsite_ocbc_digital/allowspecific</config_path>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<comment>If not set to all, guest customers will not have a billing country and may not be able to check out.</comment>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="499" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment from specific countries</label>
<config_path>payment/omise_offsite_ocbc_digital/specificcountry</config_path>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<depends>
<field id="allowspecific">1</field>
</depends>
</field>
</group>
<group id="omise_offsite_grabpay" translate="label" sortOrder="500" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable GrabPay Payment</label>
<comment>Enable customers to pay using GrabPay payment method</comment>
Expand Down
14 changes: 14 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@
<payment_action>authorize_capture</payment_action>
</omise_offsite_ocbcpao>

<omise_offsite_ocbc_digital>
<active>0</active>
<title>OCBC Digital</title>
<model>OmiseOcbcDigitalAdapter</model>
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<can_capture>1</can_capture>
<can_review_payment>1</can_review_payment>
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_refund>1</can_refund>
<payment_action>authorize_capture</payment_action>
</omise_offsite_ocbc_digital>

<omise_offsite_grabpay>
<active>0</active>
<title>GrabPay</title>
Expand Down
48 changes: 48 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,54 @@
</arguments>
</virtualType>
<!-- /Ocbc Pao :: Value Handler Pool-->

<!-- Ocbc Digital payment solution-->
<virtualType name="OmiseOcbcDigitalAdapter" type="Magento\Payment\Model\Method\Adapter">
<arguments>
<argument name="code" xsi:type="const">Omise\Payment\Model\Config\OcbcDigital::CODE</argument>
<argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
<argument name="infoBlockType" xsi:type="string">Magento\Payment\Block\Info</argument>
<argument name="valueHandlerPool" xsi:type="object">OmiseAPMOcbcDigitalValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">OmiseAPMOcbcDigitalValidatorPool</argument>
<argument name="commandPool" xsi:type="object">OmiseAPMCommandPool</argument>
</arguments>
</virtualType>

<!-- Ocbc Digital :: Value Handler Pool -->
<virtualType name="OmiseAPMOcbcDigitalValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="default" xsi:type="string">OmiseAPMOcbcDigitalConfigValueHandler</item>
</argument>
</arguments>
</virtualType>

<virtualType name="OmiseAPMOcbcDigitalValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
<arguments>
<argument name="validators" xsi:type="array">
<item name="country" xsi:type="string">OmiseAPMOcbcDigitalCountryValidator</item>
</argument>
</arguments>
</virtualType>

<virtualType name="OmiseAPMOcbcDigitalCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">OmiseAPMOcbcDigitalConfig</argument>
</arguments>
</virtualType>

<virtualType name="OmiseAPMOcbcDigitalConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">OmiseAPMOcbcDigitalConfig</argument>
</arguments>
</virtualType>

<virtualType name="OmiseAPMOcbcDigitalConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="const">Omise\Payment\Model\Config\OcbcDigital::CODE</argument>
</arguments>
</virtualType>
<!-- /Ocbc Digital :: Value Handler Pool-->

<!-- Grabpay payment solution -->
<virtualType name="OmiseGrabpayAdapter" type="Magento\Payment\Model\Method\Adapter">
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Omise_Payment" setup_version="3.2.0">
<module name="Omise_Payment" setup_version="3.3.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/layout/checkout_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<item name="omise_offsite_ocbcpao" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
<item name="omise_offsite_ocbc_digital" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
<item name="omise_offsite_grabpay" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
Expand Down
11 changes: 10 additions & 1 deletion view/frontend/web/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file added view/frontend/web/images/ocbc_digital.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified view/frontend/web/images/ocbc_pao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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"
}
});
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
});
Expand Down

0 comments on commit 6beafdd

Please sign in to comment.