Skip to content

Commit

Permalink
Add WLB installment banks in providers in omise-offsite-installment-m…
Browse files Browse the repository at this point in the history
…ethod.js. Removed unnecesssary files from offsite-installment-form.html. Updated Model/Config/Installment.php. Few other minor improvements.
  • Loading branch information
aashishgurung committed Sep 13, 2024
1 parent 128bfab commit 2d062ea
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 84 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ define(
selectPaymentMethodAction
) {
'use strict';
const CAPTION = $.mage.__('Choose number of monthly payments');
const providers = [
{
id: "installment_ktc",
Expand Down Expand Up @@ -89,7 +88,64 @@ define(
logo: 'ttb',
active: true
},
]

{
id: "installment_wlb_ktc",
title: $.mage.__('Krungthai Card'),
code: 'ktc',
logo: 'ktc',
active: true
},
{
id: "installment_wlb_first_choice",
title: $.mage.__('First Choice'),
code: 'first_choice',
logo: 'fc',
active: true
},
{
id: "installment_wlb_kbank",
title: $.mage.__('Kasikorn Bank'),
code: 'kbank',
logo: 'kbank',
active: true
},
{
id: "installment_wlb_bbl",
title: $.mage.__('Bangkok Bank'),
code: 'bbl',
logo: 'bbl',
active: true
},
{
id: "installment_wlb_bay",
title: $.mage.__('Krungsri'),
code: 'bay',
logo: 'bay',
active: true
},
{
id: "installment_wlb_scb",
title: $.mage.__('Siam Commercial Bank'),
code: 'scb',
logo: 'scb',
active: true
},
{
id: "installment_wlb_uob",
title: $.mage.__('United Overseas Bank'),
code: 'uob',
logo: 'uob',
active: true
},
{
id: "installment_wlb_ttb",
title: $.mage.__('TMBThanachart Bank'),
code: 'ttb',
logo: 'ttb',
active: true
},
];

function convertToCents(dollarAmount) {
return Math.round(parseFloat(dollarAmount) * 100);
Expand Down Expand Up @@ -165,22 +221,13 @@ define(
},

applyOmiseJsToElement: function (self, element) {
const iframeHeightMatching = {
'40px': 258,
'44px': 270,
'48px': 282,
'52px': 295,
}

const localeMatching = {
en_US: 'en',
ja_JP: 'ja',
th_TH: 'th'
}

const { theme, locale, formDesign } = window.checkoutConfig.payment.omise_cc
const { font, input, checkbox } = formDesign
let iframeElementHeight = iframeHeightMatching[input.height]
const { locale } = window.checkoutConfig.payment.omise_cc
element.style.height = 500 + 'px';

OmiseCard.configure({
Expand Down Expand Up @@ -294,15 +341,6 @@ define(
return $.mage.__('Minimum order value is %amount').replace('%amount', this.getFormattedAmount(this.getInstallmentMinLimit()));
},

/**
* Get formatted message about installment caption
*
* @return {string}
*/
getCaptionText: function () {
return CAPTION
},

/**
* Get Installment minimum
* this function respects info from: https://www.omise.co/installment-payment
Expand Down
71 changes: 14 additions & 57 deletions view/frontend/web/template/payment/offsite-installment-form.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}, visible: isActive()">
<div class="payment-method-title field choice">
<input type="radio" name="payment[method]" class="radio" data-bind="attr: {
'id': getCode()
},
value: getCode(),
checked: isChecked,
click: selectPaymentMethod,
visible: isRadioButtonVisible(),
enable: isActive() && !orderValueTooLow()" />
'id': getCode()
},
value: getCode(),
checked: isChecked,
click: selectPaymentMethod,
visible: isRadioButtonVisible(),
enable: isActive() && !orderValueTooLow()" />
<label data-bind="attr: {'for': getCode()}" class="label">
<span data-bind="text: getTitle()"></span>
</label>
Expand Down Expand Up @@ -49,50 +49,6 @@
<!-- /ko -->

<!-- ko if: providers().length -->
<!-- <div class="omise-banking-fee-warn" data-bind="i18n: 'Choose your installment terms'"></div>
<form class="form" data-bind="attr: {
id: getCode() + 'Form',
}">
<fieldset data-bind="attr: {class: 'fieldset payment items ' + getCode(), id: 'payment_form_' + getCode()}">
<ul class="form-list" data-bind="foreach: providers">
<li class="items" data-bind="visible: active">
<input type="radio" name="offsite" data-bind="
attr: {
id: $parent.getCode() + '_' + code
, value: id
},
checked: $parent.omiseOffsite,
click: function(data, event) {
$parent.resetTerms();
return true;
};" />
<label data-bind="
attr:{
'for': 'omise_offsite_installment_'+logo
}">
<div class="omise-logo-wrapper" data-bind="css: logo">
<img data-bind="css: logo" />
</div>
<div class="omise-banking-text-wrapper">
<span class="title" data-bind="i18n: title"></span>
</div>
</label>
<select style="margin-top:10px" data-bind="options: $parent.getInstallmentTerms(code),
optionsText: function (item) {
return item.label
},
optionsValue: function (item) {
return item.key
},
valueAllowUnset:true,
value: $parent.getObservableTerm(id),
visible: $parent.omiseOffsite() === id,
optionsCaption: $parent.getCaptionText()"></select>
</li>
</ul>
</fieldset>
</form> -->
<input type="hidden"
name="payment[omise_token]"
data-bind="attr: {
Expand All @@ -101,12 +57,13 @@
},
value: omiseInstallmentToken"/>
<input type="hidden"
name="payment[omise_source]"
data-bind="attr: {
'id': getCode() + 'InstallmentSource',
'data-container': getCode() + '-cc-source',
},
value: omiseInstallmentSource"/>
name="payment[omise_source]"
data-bind="attr: {
'id': getCode() + 'InstallmentSource',
'data-container': getCode() + '-cc-source',
},
value: omiseInstallmentSource"
/>
<div class="omise-installment-form" data-bind="omiseInstallmentForm: true"></div>
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
Expand Down

0 comments on commit 2d062ea

Please sign in to comment.