Skip to content

Commit

Permalink
Merge branch 'release/v6.2.0' into 'master'
Browse files Browse the repository at this point in the history
release/v6.2.0 into master

See merge request agence-dnd/marketplace/magento-2/external/module-checkout-magento2-plugin!213
  • Loading branch information
DnD-Behou committed Jun 12, 2024
2 parents be4c7c0 + 7f2ee0a commit 58d6db9
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Model/Methods/AlternativePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,10 @@ public function ideal(array $data)
{
if ($this->apiHandler->isPreviousMode()) {
$source = new PreviousRequestIdealSource();
$source->bic = $data['bic'];
} else {
$source = new RequestIdealSource();
}
$source->bic = $data['bic'];
$source->description = $data['description'];
$locale = explode('_', $this->shopperHandler->getCustomerLocale('nl_NL') ?? '');
$source->language = $locale[0];
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "checkoutcom/magento2",
"description": "Checkout.com Payment Gateway for Magento 2",
"require": {
"checkout/checkout-sdk-php": "3.0.21",
"checkout/checkout-sdk-php": "3.2.0",
"php": "~7.4.0||~8.1.0||~8.2.0",
"magento/framework": ">=100.0.1"
},
"type": "magento2-module",
"version": "6.1.1",
"version": "6.2.0",
"autoload": {
"files": [
"registration.php"
Expand Down
56 changes: 30 additions & 26 deletions view/frontend/templates/payment/apm/ideal.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,42 @@
<div data-role="content" class="apm-content">
<form id="cko-apm-form-<?= $block->escapeHtmlAttr($block->getData('apm_id'))?>">
<input type="hidden" name="source" value="<?= $block->escapeHtmlAttr($block->getData('apm_id'))?>" required>
<div class="input-group">
<label class="icon" for="bic">
<span class="ckojs ckojs-card"></label>
<select name="bic" id="bic" required>
<option value=""><?= $block->escapeHtml(__('BIC')); ?></option>
</select>
</div>
<?php if ($block->getData('service_previous_mode')): ?>
<div class="input-group">
<label class="icon" for="bic">
<span class="ckojs ckojs-card"></label>
<select name="bic" id="bic" required>
<option value=""><?= $block->escapeHtml(__('BIC')); ?></option>
</select>
</div>
<?php endif; ?>
<div class="input-group">
<label class="icon" for="description">
<span class="ckojs ckojs-card"></label>
<input type="text" id="description" name="description" placeholder="<?= $block->escapeHtmlAttr(__('Description')); ?>" class="input-control" required>
</div>
<br>
</form>
<script>
require([
'jquery'
], function ($) {
$.ajax({
url: '<?= $block->escapeUrl($block->getUrl("checkout_com/apm/displaybic")) ?>',
type:'GET',
success: function(response){
$.each( response, function(key, value) {
let bicID = value.bic;
let nameValue = value.name;
$('#bic').append($('<option>').val(bicID).text(nameValue));
});
},
error: function(response){
console.log(response)
}
<?php if ($block->getData('service_previous_mode')): ?>
<script>
require([
'jquery'
], function ($) {
$.ajax({
url: '<?= $block->escapeUrl($block->getUrl("checkout_com/apm/displaybic")) ?>',
type:'GET',
success: function(response){
$.each( response, function(key, value) {
let bicID = value.bic;
let nameValue = value.name;
$('#bic').append($('<option>').val(bicID).text(nameValue));
});
},
error: function(response){
console.log(response)
}
});
});
});
</script>
</script>
<?php endif; ?>
</div>
59 changes: 59 additions & 0 deletions view/frontend/web/js/model/checkout-utilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Checkout.com
* Authorized and regulated as an electronic money institution
* by the UK Financial Conduct Authority (FCA) under number 900816.
*
* PHP version 7
*
* @category Magento2
* @package Checkout.com
* @author Platforms Development Team <[email protected]>
* @copyright 2010-present Checkout.com
* @license https://opensource.org/licenses/mit-license.html MIT License
* @link https://docs.checkout.com/
*/

define([
'jquery',
'CheckoutCom_Magento2/js/view/payment/utilities',
'Magento_Checkout/js/model/step-navigator',
'Magento_Checkout/js/action/set-payment-information'
], function ($, Utilities, StepNavigator, setPaymentInformationAction) {
'use strict';

const PAYMENT_STEP_CODE = 'payment';

return {

/**
* Workaround to refresh payment method information when guest customer
* go back to shipping step & change his email address
*
* @param {UiClass} Component
* @public
*/
initSubscribers: function (Component) {
const code = Component.getCode();

StepNavigator.steps.subscribe((steps) => {
if (this.getCurrentCheckoutStep(steps) === PAYMENT_STEP_CODE &&
Utilities.methodIsSelected(code)) {
setPaymentInformationAction(Component.messageContainer, {
method: code
});
}
});
},

/**
* Return current checkout step code
*
* @param {Array} steps
* @return string
* @public
*/
getCurrentCheckoutStep: function (steps) {
return steps[StepNavigator.getActiveItemIndex()]['code'];
}
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ define(
'jquery',
'Magento_Checkout/js/view/payment/default',
'CheckoutCom_Magento2/js/view/payment/utilities',
'CheckoutCom_Magento2/js/model/checkout-utilities',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote',
'mage/translate',
'jquery/ui'
],
function ($, Component, Utilities, FullScreenLoader, AdditionalValidators, Quote, __) {
function ($, Component, Utilities, CheckoutUtilities, FullScreenLoader, AdditionalValidators, Quote, __) {

'use strict';
window.checkoutConfig.reloadOnBillingAddress = true;
Expand All @@ -45,6 +46,7 @@ define(
initialize: function () {
this._super();
Utilities.loadCss('apm', 'apm');
CheckoutUtilities.initSubscribers(this);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ define(
'ko',
'Magento_Checkout/js/view/payment/default',
'CheckoutCom_Magento2/js/view/payment/utilities',
'CheckoutCom_Magento2/js/model/checkout-utilities',
"CheckoutCom_Magento2/js/view/payment/applepay-utilities",
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/payment/additional-validators',
Expand All @@ -30,6 +31,7 @@ define(
ko,
Component,
Utilities,
CheckoutUtilities,
ApplePayUtilities,
FullScreenLoader,
AdditionalValidators,
Expand All @@ -55,6 +57,7 @@ define(
initialize: function () {
this._super();
Utilities.setEmail();
CheckoutUtilities.initSubscribers(this);
Utilities.loadCss('apple-pay', 'apple-pay');
this.launchApplePay();

Expand Down Expand Up @@ -232,6 +235,8 @@ define(
let self = this;

if (Utilities.methodIsSelected(METHOD_ID)) {
Utilities.setEmail();

// Validate T&C submission
if (!AdditionalValidators.validate()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ define(
'ko',
'Magento_Checkout/js/view/payment/default',
'CheckoutCom_Magento2/js/view/payment/utilities',
'CheckoutCom_Magento2/js/model/checkout-utilities',
'CheckoutCom_Magento2/js/frames/multi',
'CheckoutCom_Magento2/js/frames/single',
'Magento_Checkout/js/model/payment/additional-validators',
Expand All @@ -27,7 +28,7 @@ define(
'Magento_Checkout/js/model/full-screen-loader',
'framesjs'
],
function ($, ko, Component, Utilities, FramesMulti, FramesSingle, AdditionalValidators, Customer, Quote, FullScreenLoader) {
function ($, ko, Component, Utilities, CheckoutUtilities, FramesMulti, FramesSingle, AdditionalValidators, Customer, Quote, FullScreenLoader) {
'use strict';
window.checkoutConfig.reloadOnBillingAddress = true;
const METHOD_ID = 'checkoutcom_card_payment';
Expand Down Expand Up @@ -60,6 +61,7 @@ define(
this._super();
Utilities.loadCss(this.getFormLayout(), 'frames');
Utilities.setEmail();
CheckoutUtilities.initSubscribers(this);

return this;
},
Expand Down Expand Up @@ -315,6 +317,8 @@ define(

placeOrder: function () {
if (Utilities.methodIsSelected(METHOD_ID)) {
Utilities.setEmail();

// Validate the order placement
if (AdditionalValidators.validate() && Frames.isCardValid()) {
// Start the loader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ define(
'jquery',
'Magento_Checkout/js/view/payment/default',
'CheckoutCom_Magento2/js/view/payment/utilities',
'CheckoutCom_Magento2/js/model/checkout-utilities',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/action/redirect-on-success',
'mage/translate',
'googlepayjs',
],
function(
$, Component, Utilities, FullScreenLoader, AdditionalValidators,
$, Component, Utilities, ChekcoutUtilities, FullScreenLoader, AdditionalValidators,
RedirectOnSuccessAction, __) {
'use strict';
window.checkoutConfig.reloadOnBillingAddress = true;
Expand All @@ -46,6 +47,7 @@ define(
initialize: function() {
this._super();
Utilities.setEmail();
ChekcoutUtilities.initSubscribers(this);
Utilities.loadCss('google-pay', 'google-pay');

return this;
Expand Down Expand Up @@ -95,6 +97,8 @@ define(
$(self.button_target).click(
function(evt) {
if (Utilities.methodIsSelected(METHOD_ID)) {
Utilities.setEmail();

// Validate T&C submission
if (!AdditionalValidators.validate()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ define([
'knockout',
'Magento_Checkout/js/view/payment/default',
'CheckoutCom_Magento2/js/view/payment/utilities',
'CheckoutCom_Magento2/js/model/checkout-utilities',
'CheckoutCom_Magento2/js/view/payment/paypal-utilities',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote',
'mage/translate',
'mage/url',
], function ($, ko, Component, Utilities, PaypalUtilities, FullScreenLoader, AdditionalValidators, Quote, __, Url) {
], function ($, ko, Component, Utilities, CheckoutUtilities, PaypalUtilities, FullScreenLoader, AdditionalValidators, Quote, __, Url) {
'use strict';

window.checkoutConfig.reloadOnBillingAddress = true;
Expand Down Expand Up @@ -64,6 +65,8 @@ define([
}).catch((error) => {
Utilities.log(error);
});

CheckoutUtilities.initSubscribers(this);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
* @link https://docs.checkout.com/
*/

define(
[
define([
'jquery',
'Magento_Checkout/js/view/payment/default',
'CheckoutCom_Magento2/js/view/payment/utilities',
'CheckoutCom_Magento2/js/model/checkout-utilities',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/full-screen-loader',
'mage/translate'
],
function ($, Component, Utilities, AdditionalValidators, FullScreenLoader, __) {
], function ($, Component, Utilities, CheckoutUtilities, AdditionalValidators, FullScreenLoader, __) {
'use strict';
window.checkoutConfig.reloadOnBillingAddress = true;
const METHOD_ID = 'checkoutcom_vault';
Expand All @@ -44,6 +43,7 @@ define(
initialize: function () {
this._super();
Utilities.setEmail();
CheckoutUtilities.initSubscribers(this);
Utilities.loadCss('vault', 'vault');

return this;
Expand Down Expand Up @@ -251,6 +251,8 @@ define(
*/
placeOrder: function () {
if (Utilities.methodIsSelected(METHOD_ID)) {
Utilities.setEmail();

if (AdditionalValidators.validate()) {
// Prepare the payload
var payload = {
Expand Down
5 changes: 3 additions & 2 deletions view/frontend/web/js/view/payment/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ define(
const KEY_DATA = 'checkoutcom_data';

return {

/**
* Gets a field value.
*
Expand Down Expand Up @@ -398,7 +399,7 @@ define(
methodIsSelected: function (idSelector) {
var id = idSelector.replace('#', '');
var selected = CheckoutData.getSelectedPaymentMethod();
return id == selected || selected == null;
return id === selected;
},

/**
Expand Down Expand Up @@ -446,7 +447,7 @@ define(
*/
cleanCustomerShippingAddress: function() {
CheckoutData.setNewCustomerShippingAddress(null);
}
},
};
}
);

0 comments on commit 58d6db9

Please sign in to comment.