Skip to content

Commit

Permalink
Revert "[MIT-1911] Whitelabel installment" (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung authored Jul 24, 2024
1 parent f2b015f commit d936ae8
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 372 deletions.
21 changes: 7 additions & 14 deletions Gateway/Request/APMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@

class APMBuilder implements BuilderInterface
{
/**
* @var string
*/
const CARD = 'card';

/**
* @var string
*/
Expand Down Expand Up @@ -192,15 +187,13 @@ public function build(array $buildSubject)
];
break;
case Installment::CODE:
$card = $method->getAdditionalInformation(InstallmentDataAssignObserver::CARD);
if ($card !== null) {
$paymentInfo[self::CARD] = $card;
}

$source = $method->getAdditionalInformation(InstallmentDataAssignObserver::SOURCE);
if ($source !== null) {
$paymentInfo[self::SOURCE] = $source;
}
$installmentId = $method->getAdditionalInformation(InstallmentDataAssignObserver::OFFSITE);
$paymentInfo[self::SOURCE] = [
self::SOURCE_TYPE => $installmentId,
self::SOURCE_INSTALLMENT_TERMS => $method->getAdditionalInformation(
InstallmentDataAssignObserver::TERMS
)
];
break;
case Truemoney::CODE:
$paymentInfo[self::SOURCE] = $this->getTruemoneySourceData($method);
Expand Down
12 changes: 0 additions & 12 deletions Gateway/Request/PaymentDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,6 @@ public function build(array $buildSubject)
$requestBody[self::METADATA]['secure_form_enabled'] = $this->ccConfig->getSecureForm();
}

if (Installment::CODE === $method->getMethod()) {
$card = $method->getAdditionalInformation(InstallmentDataAssignObserver::CARD);
if ($card !== null) {
$requestBody['card'] = $card;
}

$source = $method->getAdditionalInformation(InstallmentDataAssignObserver::SOURCE);
if ($source !== null) {
$requestBody['source'] = $source;
}
}

return $requestBody;
}

Expand Down
6 changes: 1 addition & 5 deletions Observer/InstallmentDataAssignObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ class InstallmentDataAssignObserver extends OffsiteDataAssignObserver
* @var string
*/
const TERMS = 'terms';
const CARD = 'card';
const SOURCE = 'source';

/**
* @var array
*/
protected $additionalInformationList = [
self::OFFSITE,
self::TERMS,
self::CARD,
self::SOURCE,
self::TERMS
];
}

This file was deleted.

152 changes: 65 additions & 87 deletions view/frontend/web/js/view/payment/method-renderer/omise-cc-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ define(
'Magento_Payment/js/model/credit-card-validation/validator',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/redirect-on-success',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/action/select-payment-method'
'Magento_Checkout/js/model/quote'
],
function (
ko,
Expand All @@ -21,9 +19,7 @@ define(
validator,
fullScreenLoader,
redirectOnSuccessAction,
quote,
checkoutData,
selectPaymentMethodAction
quote
) {
'use strict'

Expand Down Expand Up @@ -89,98 +85,80 @@ define(
return this
},

selectPaymentMethod: function () {
this._super();
selectPaymentMethodAction(this.getData());
checkoutData.setSelectedPaymentMethod(this.item.method);
OmiseCard.destroy();
setTimeout(() => {
if (this.isSecureForm()) {
const element = document.querySelector('.omise-card-form')
if(element) {
this.applyOmiseJsToElement(this, element)
}
}
}, 300);

return true
},

isSecureForm: function () {
return window.checkoutConfig.payment.omise_cc.secureForm === 'yes'
},

openOmiseJs: function () {
const self = this
ko.bindingHandlers.omiseCardForm = {
init: (element) => this.applyOmiseJsToElement(this, element)
}
},

applyOmiseJsToElement: function (self, element) {
const hideRememberCard = !self.isCustomerLoggedIn()
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]
if (hideRememberCard) {
iframeElementHeight = iframeElementHeight - 25
}
element.style.height = iframeElementHeight + 'px'

OmiseCard.configure({
publicKey: self.getPublicKey(),
element,
locale: localeMatching[locale] ?? 'en',
customCardForm: true,
customCardFormTheme: theme,
style: {
fontFamily: font.name,
fontSize: font.size,
input: {
height: input.height,
borderRadius: input.border_radius,
border: `1.2px solid ${input.border_color}`,
focusBorder: `1.2px solid ${input.active_border_color}`,
background: input.background_color,
color: input.text_color,
labelColor: input.label_color,
placeholderColor: input.placeholder_color,
},
checkBox: {
textColor: checkbox.text_color,
themeColor: checkbox.theme_color,
border: `1.2px solid ${input.border_color}`,
init: function (element) {
const hideRememberCard = !self.isCustomerLoggedIn()
const iframeHeightMatching = {
'40px': 258,
'44px': 270,
'48px': 282,
'52px': 295,
}
},
customCardFormHideRememberCard: hideRememberCard
})

OmiseCard.open({
onCreateTokenSuccess: (payload) => {
self.createOrder(self, payload)
},
onError: (err) => {
if (err.length > 0) {
self.omiseCardError(err.length == 1 ? err[0] : 'Please enter required card information.')
const localeMatching = {
en_US: 'en',
ja_JP: 'ja',
th_TH: 'th'
}
else {
self.omiseCardError('Something went wrong. Please refresh the page and try again.')

const { theme, locale, formDesign } = window.checkoutConfig.payment.omise_cc
const { font, input, checkbox } = formDesign
let iframeElementHeight = iframeHeightMatching[input.height]
if (hideRememberCard) {
iframeElementHeight = iframeElementHeight - 25
}
self.stopPerformingPlaceOrderAction()
element.style.height = iframeElementHeight + 'px'

OmiseCard.configure({
publicKey: self.getPublicKey(),
element,
locale: localeMatching[locale] ?? 'en',
customCardForm: true,
customCardFormTheme: theme,
style: {
fontFamily: font.name,
fontSize: font.size,
input: {
height: input.height,
borderRadius: input.border_radius,
border: `1.2px solid ${input.border_color}`,
focusBorder: `1.2px solid ${input.active_border_color}`,
background: input.background_color,
color: input.text_color,
labelColor: input.label_color,
placeholderColor: input.placeholder_color,
},
checkBox: {
textColor: checkbox.text_color,
themeColor: checkbox.theme_color,
border: `1.2px solid ${input.border_color}`,
}
},
customCardFormHideRememberCard: hideRememberCard
})

OmiseCard.open({
onCreateTokenSuccess: (payload) => {
self.createOrder(self, payload)
},
onError: (err) => {
if (err.length > 0) {
self.omiseCardError(err.length == 1 ? err[0] : 'Please enter required card information.')
}
else {
self.omiseCardError('Something went wrong. Please refresh the page and try again.')
}
self.stopPerformingPlaceOrderAction()
}
})
}
})
}
},

createOrder: function (self, payload) {
Expand Down
Loading

0 comments on commit d936ae8

Please sign in to comment.