Skip to content

Commit

Permalink
Made secure form mandatory.
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung committed Oct 16, 2024
1 parent b66bcd6 commit fbce959
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 407 deletions.

This file was deleted.

4 changes: 0 additions & 4 deletions Gateway/Request/PaymentDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ public function build(array $buildSubject)
$requestBody[self::ZERO_INTEREST_INSTALLMENTS] = true;
}

if (Cc::CODE === $method->getMethod()) {
$requestBody[self::METADATA]['secure_form_enabled'] = $this->ccConfig->getSecureForm();
}

if (Installment::CODE === $method->getMethod()) {
$card = $method->getAdditionalInformation(InstallmentDataAssignObserver::CARD);
if ($card !== null) {
Expand Down
5 changes: 0 additions & 5 deletions Model/Config/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,4 @@ public function getCardTheme()
{
return $this->getValue('card_form_theme', self::CODE);
}

public function getSecureForm()
{
return $this->getValue('secure_form', self::CODE);
}
}
22 changes: 0 additions & 22 deletions Model/Source/SecureForm.php

This file was deleted.

1 change: 0 additions & 1 deletion Model/Ui/CcConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function getConfig()
'isCustomerLoggedIn' => $this->customer->isLoggedIn(),
'cards' => $this->getCards(),
'locale' => $this->omiseCcConfig->getStoreLocale(),
'secureForm' => $this->omiseCcConfig->getSecureForm(),
'formDesign' => $theme->getFormDesign($selectedTheme, $customDesign),
'theme' => $selectedTheme
],
Expand Down
80 changes: 0 additions & 80 deletions Test/Unit/SecureFormBannerMessageTest.php

This file was deleted.

8 changes: 0 additions & 8 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,4 @@
<type name="\Magento\Config\Model\Config">
<plugin name="admin_system_config_save_plugin" type="Omise\Payment\Plugin\ConfigSectionPaymentPlugin" sortOrder="1" />
</type>

<type name="Magento\Framework\Notification\MessageList">
<arguments>
<argument name="messages" xsi:type="array">
<item name="opnPaymentsSecureFormBannerMessage" xsi:type="string">Omise\Payment\Block\Adminhtml\System\Config\CardFormCustomization\SecureFormBannerMessage</item>
</argument>
</arguments>
</type>
</config>
11 changes: 0 additions & 11 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,10 @@
<comment>This controls the title which the user sees during checkout.</comment>
<config_path>payment/omise_cc/title</config_path>
</field>
<field id="secure_form" translate="label" type="select" sortOrder="111" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Secure Form</label>
<config_path>payment/omise_cc/secure_form</config_path>
<source_model>Omise\Payment\Model\Source\SecureForm</source_model>
<comment>
<![CDATA[Try the new secure form to accept card payments. The new form features additional controls to ensure PCI-DSS compliance. Using this form will be <b>mandatory</b> in a future release.]]>
</comment>
</field>
<field id="card_form_theme" translate="label comment" type="select" sortOrder="112" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Secure Form Theme</label>
<config_path>payment/omise_cc/card_form_theme</config_path>
<source_model>Omise\Payment\Model\Source\CardFormTheme</source_model>
<depends>
<field id="secure_form">yes</field>
</depends>
<comment>
<![CDATA[Credit/debit card secure form design on checkout page. <a style="cursor:pointer" onclick="cardFormCustomization.showModal()"><b>Click here</b></a> for more secure card form customization.]]>
</comment>
Expand Down
1 change: 0 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<can_refund_partial_per_invoice>1</can_refund_partial_per_invoice>
<can_refund>1</can_refund>
<payment_action>authorize</payment_action>
<secure_form>no</secure_form>
<card_form_theme>light</card_form_theme>
<card_form_theme_config></card_form_theme_config>
</omise_cc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ define(
'omiseSaveCard',
'omiseCardError'
])
if (this.isSecureForm()) {
this.openOmiseJs()
}
this.openOmiseJs()
return this
},

Expand All @@ -95,21 +93,15 @@ define(
checkoutData.setSelectedPaymentMethod(this.item.method);
OmiseCard.destroy();
setTimeout(() => {
if (this.isSecureForm()) {
const element = document.querySelector('.omise-card-form')
if(element) {
this.applyOmiseJsToElement(this, element)
}
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 () {
ko.bindingHandlers.omiseCardForm = {
init: (element) => this.applyOmiseJsToElement(this, element)
Expand Down Expand Up @@ -287,43 +279,6 @@ define(
OmiseCard.requestCardToken(billingAddress)
},

/**
* Generate Omise token with omise.js before proceed the placeOrder process.
*
* @return {void}
*/
generateTokenWithOmiseJsAndPerformPlaceOrderAction: function () {
if (! this.validate()) {
return false;
}

const self = this
this.startPerformingPlaceOrderAction()

let card = {
number: this.omiseCardNumber(),
name: this.omiseCardHolderName(),
expiration_month: this.omiseCardExpirationMonth(),
expiration_year: this.omiseCardExpirationYear(),
security_code: this.omiseCardSecurityCode()
}
let selectedBillingAddress = quote.billingAddress()

if (self.billingAddressCountries.indexOf(selectedBillingAddress.countryId) > -1) {
Object.assign(card, this.getSelectedTokenBillingAddress(selectedBillingAddress))
}

Omise.setPublicKey(this.getPublicKey())
Omise.createToken('card', card, function (statusCode, response) {
if (statusCode === 200) {
self.createOrder(self, {token : response.id})
} else {
self.omiseCardError(response.message)
self.stopPerformingPlaceOrderAction()
}
})
},

/**
* Hook the placeOrder function.
* Original source: placeOrder(data, event); @ module-checkout/view/frontend/web/js/view/payment/default.js
Expand All @@ -346,36 +301,10 @@ define(
return true
}

if (this.isSecureForm()) {
this.generateTokenWithEmbeddedFormAndPerformPlaceOrderAction()
} else {
this.generateTokenWithOmiseJsAndPerformPlaceOrderAction()
}

this.generateTokenWithEmbeddedFormAndPerformPlaceOrderAction()
return true
},

/**
* Hook the validate function.
* Original source: validate(); @ module-checkout/view/frontend/web/js/view/payment/default.js
*
* @return {boolean}
*/
validate: function () {
let prefix = '#' + this.getCode(),
fields = [
'CardNumber',
'CardHolderName',
'CardExpirationMonth',
'CardExpirationYear',
'CardSecurityCode'
]


$(prefix + 'Form').validation()
return fields.map(f => $(prefix + f).valid()).every(valid => valid)
},

processOrderWithCard: function () {
const self = this
const failHandler = this.buildFailHandler(self, 300)
Expand Down
Loading

0 comments on commit fbce959

Please sign in to comment.