Skip to content

Commit

Permalink
Merge pull request #165 from getbread/pg-1311-fix
Browse files Browse the repository at this point in the history
Magento 2.4.4 compatibility update + bread pay branding
  • Loading branch information
KiprotichMaritim authored Jun 14, 2022
2 parents 18fedf0 + e2f3ba1 commit ea611e1
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 82 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "bread/module-breadcheckout",
"description": "Offers the Bread financing and checkout tools for your Magento store",
"description": "Offers Bread Pay financing and checkout tools for your Magento store",
"license": "MIT",
"minimum-stability": "stable",
"version": "1.1.19",
"version": "2.0.1",
"require": {
"php": "~7.0.13||~7.1.0||~7.1.3||~7.2.0||~7.3.0||~7.4.0"
"php": "~7.0.13||~7.1.0||~7.1.3||~7.2.0||~7.3.0||~7.4.0||~8.0.0||~8.1.0"
},
"type": "magento2-module",
"repositories": [{
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<system>
<section id="payment">
<group id="breadcheckout" type="text" sortOrder="305" showInDefault="1" showInWebsite="1" showInStore="1" translate="label">
<label>Bread Checkout</label>
<label>Bread Pay Checkout</label>
<fieldset_css>complex</fieldset_css>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group</frontend_model>
<comment>
<![CDATA[
<div>
<span class="bread-logo"></span>
Bread Payments by <a href="https://www.getbread.com/" target="_blank">getbread.com</a> - <b>Onsite Consumer Financing</b>.
<br/> Developers API reference: <a href="https://docs.getbread.com/docs/integration/magento-2/magento-2-overview/" target="_blank">Bread Developer API Reference</a>
Bread Pay by <a href="https://payments.breadfinancial.com/" target="_blank">payments.breadfinancial.com</a> - <b>Onsite Consumer Financing</b>.
<br/> Developers API reference: <a href="https://docs.breadpayments.com/bread-classic/docs/magento-2/" target="_blank">Bread Developer API Reference</a>
</div>
]]>
</comment>
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/templates/breadcheckout/css.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
height: 44px;
margin-bottom: 10px;
display: block;
background: url('<?= /* @noEscape */ $block->getViewFileUrl('Bread_BreadCheckout/bread/images/bread-logo.png'); ?>');
background: url('<?= /* @noEscape */ $block->getViewFileUrl('Bread_BreadCheckout/bread/images/bread-financial.png'); ?>');
background-repeat: no-repeat;
background-size: 155px 44px;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed view/adminhtml/web/bread/images/bread-logo.png
Binary file not shown.
151 changes: 76 additions & 75 deletions view/frontend/web/js/view/shipping.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,86 @@
*/
/*global define*/
define(
[
'Magento_Checkout/js/view/shipping',
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/full-screen-loader',
'buttonConfig',
],
function (Shipping, $, quote, fullScreenLoader, button) {
'use strict';
return Shipping.extend(
{
setShippingInformation: function () {
/**
* Call parent method
*/
Shipping.prototype.setShippingInformation.call(this);
[
'Magento_Checkout/js/view/shipping',
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/full-screen-loader',
'buttonConfig'
],
function (Shipping, $, quote, fullScreenLoader, button) {
'use strict';
return Shipping.extend(
{
setShippingInformation: function () {
/**
* Call parent method
*/
Shipping.prototype.setShippingInformation.call(this);

this.updateConfigData();
this.invalidateToken();
this.refreshBreadPaymentMethod();
},
this.updateConfigData();
this.invalidateToken();
this.refreshBreadPaymentMethod();
},

/**
* Add updated shipping option data to window.checkoutConfig global variable
*
* @see Bread\BreadCheckout\Model\Ui\ConfigProvider
*/
updateConfigData: function () {
window.checkoutConfig.payment.breadcheckout.breadConfig.shippingOptions = {
type: quote.shippingMethod().carrier_title + ' - ' + quote.shippingMethod().method_title,
typeId: quote.shippingMethod().carrier_code + '_' + quote.shippingMethod().method_code,
cost: this.round(quote.shippingMethod().base_amount)
};
},
/**
* Add updated shipping option data to window.checkoutConfig global variable
*
* @see Bread\BreadCheckout\Model\Ui\ConfigProvider
*/
updateConfigData: function () {
window.checkoutConfig.payment.breadcheckout.breadConfig.shippingOptions = {
type: quote.shippingMethod().carrier_title + ' - ' + quote.shippingMethod().method_title,
typeId: quote.shippingMethod().carrier_code + '_' + quote.shippingMethod().method_code,
cost: this.round(quote.shippingMethod().base_amount)
};
},

/**
* Invalidate existing transaction ID (in case user filled out payment
* form and then went back a step)
*/
invalidateToken: function () {
if (window.checkoutConfig.payment.breadcheckout.transactionId !== null) {
window.checkoutConfig.payment.breadcheckout.transactionId = null;
}
},

/**
*
* Refresh the payment method section if transactionId is not set
*/
refreshBreadPaymentMethod: function () {
var paymentMethod = quote.paymentMethod();
if (typeof paymentMethod !== 'undefined') {
if (typeof paymentMethod.method !== 'undefined') {
if (quote.paymentMethod().method === 'breadcheckout'
&& window.checkoutConfig.payment.breadcheckout.transactionId === null) {
button.embeddedCheckout();
}
}

}

},

/**
* Round float to 2 decimal plates and convert to integer
*
* @param value
* @returns {Number}
*/
round: function (value) {
if (isNaN(value)) {
return 0;
/**
* Invalidate existing transaction ID (in case user filled out payment
* form and then went back a step)
*/
invalidateToken: function () {
if (window.checkoutConfig.payment.breadcheckout.transactionId !== null) {
window.checkoutConfig.payment.breadcheckout.transactionId = null;
}
},

/**
*
* Refresh the payment method section if transactionId is not set
*/
refreshBreadPaymentMethod: function () {
var paymentMethod = quote.paymentMethod();
if ( paymentMethod !== null && typeof paymentMethod.method !== 'undefined') {
if (quote.paymentMethod().method === 'breadcheckout'
&& window.checkoutConfig.payment.breadcheckout.transactionId === null) {
//Check if embeddedCheckout is enabled
if(window.checkoutConfig.payment.breadcheckout.breadConfig.embeddedCheckout) {
button.embeddedCheckout();
} else {
button.init();
}
return parseInt(
Number(Math.round(parseFloat(value) + 'e' + 2) + 'e-' + 2)
* 100
);
}
}
},

/**
* Round float to 2 decimal plates and convert to integer
*
* @param value
* @returns {Number}
*/
round: function (value) {
if (isNaN(value)) {
return 0;
}
);
}
return parseInt(
Number(Math.round(parseFloat(value)+'e'+2)+'e-'+2)
* 100
);
}
}
);
}
);

0 comments on commit ea611e1

Please sign in to comment.