Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review and add White Label Installments #492

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Helper/OmiseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,18 @@ class OmiseHelper extends AbstractHelper
Installment::UOB_ID => Installment::CODE,
Installment::MBB_ID => Installment::CODE,

// offsite installment banking payment
// offsite wlb installment banking payment
Installment::WLB_BAY_ID => Installment::CODE,
Installment::WLB_BBL_ID => Installment::CODE,
Installment::WLB_UOB_ID => Installment::CODE,
Installment::WLB_FIRST_CHOICE_ID => Installment::CODE,
Installment::WLB_KBANK_ID => Installment::CODE,
Installment::WLB_KTC_ID => Installment::CODE,
Installment::WLB_SCB_ID => Installment::CODE,
Installment::WLB_TTB_ID => Installment::CODE,
Installment::WLB_UOB_ID => Installment::CODE,

// offsite mobile banking payment
Mobilebanking::BAY_ID => Mobilebanking::CODE,
Mobilebanking::BBL_ID => Mobilebanking::CODE,
Mobilebanking::KBANK_ID => Mobilebanking::CODE,
Expand Down
2 changes: 1 addition & 1 deletion Model/Api/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ public function getTokenizationMethods()
*/
public function getInstallmentMinLimit()
{
return $this->capabilities['limits']['installment_amount']['min'];
return $this->capabilities ? $this->capabilities['limits']['installment_amount']['min'] : 0;
}
}
19 changes: 19 additions & 0 deletions Model/Config/Installment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,23 @@ class Installment extends Config
const UOB_ID = "installment_uob";

const MBB_ID = "installment_mbb";

/**
* WLB Installments
*/
const WLB_BAY_ID = "installment_wlb_bay";

const WLB_BBL_ID = "installment_wlb_bbl";

const WLB_FIRST_CHOICE_ID = "installment_wlb_first_choice";

const WLB_KBANK_ID = "installment_wlb_kbank";

const WLB_KTC_ID = "installment_wlb_ktc";

const WLB_SCB_ID = "installment_wlb_scb";

const WLB_TTB_ID = "installment_wlb_ttb";

const WLB_UOB_ID = "installment_wlb_uob";
}
4 changes: 0 additions & 4 deletions Observer/InstallmentDataAssignObserver.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php
namespace Omise\Payment\Observer;

use Magento\Framework\Event\Observer;
use Magento\Payment\Observer\AbstractDataAssignObserver;
use Magento\Quote\Api\Data\PaymentInterface;

class InstallmentDataAssignObserver extends OffsiteDataAssignObserver
{
/**
Expand Down
57 changes: 57 additions & 0 deletions Test/Unit/Model/Api/CapabilitiesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Omise\Payment\Test\Unit\Model\Api;

use PHPUnit\Framework\TestCase;
use Omise\Payment\Model\Api\Capabilities;
use Omise\Payment\Model\Config\Config;
use Mockery as m;

class CapabilitiesTest extends TestCase
{
private $configMock;
private $omiseCapabilitiesMock;

protected function setUp(): void
{
$this->configMock = m::mock(Config::class);
$this->configMock->shouldReceive('canInitialize')->andReturn(true);
$this->omiseCapabilitiesMock = m::mock('alias:OmiseCapabilities');
}

protected function tearDown(): void
{
m::close();
}

/**
* @covers Omise\Payment\Model\Api\Capabilities
*/
public function testGetInstallmentMinLimit()
{
$data = [
'limits' => [
'installment_amount' => [
'min' => 3000
]
]
];
$this->omiseCapabilitiesMock->shouldReceive('retrieve')->andReturn($data);
$capabilities = new Capabilities($this->configMock);
$result = $capabilities->getInstallmentMinLimit();

$this->assertEquals($data['limits']['installment_amount']['min'], $result);
}

/**
* @covers Omise\Payment\Model\Api\Capabilities
*/
public function testGetInstallmentMinLimitReturnsZeroIfCapabilitiesIsNotSet()
{
$this->omiseCapabilitiesMock->shouldReceive('retrieve')->andReturn(null);
$capabilities = new Capabilities($this->configMock);
$result = $capabilities->getInstallmentMinLimit();

$this->assertEquals(0, $result);
}
}
Loading
Loading