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

Revert "[MIT-1911] Whitelabel installment" #487

Merged
merged 1 commit into from
Jul 24, 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
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
Loading