Skip to content

Commit

Permalink
Merge branch 'feature/CHECMAG2003-102' into 'develop'
Browse files Browse the repository at this point in the history
feature/CHECMAG2003-102 into develop

See merge request agence-dnd/marketplace/magento-2/external/module-checkout-magento2-plugin!64
  • Loading branch information
Rémi V committed Sep 28, 2022
2 parents 8ca0ff8 + 3979465 commit ad1923c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Model/Methods/CardPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ public function sendPaymentRequest(
if (!$quote->getIsVirtual()) {
$request->shipping = $api->createShippingAddress($quote);
}
// Preferred scheme
if (isset($data['preferredScheme']) && $data['preferredScheme'] !== '') {
$request->processing = ['preferred_scheme' => strtolower($data['preferredScheme'])];
}

// Save card check
if ($isApiOrder) {
Expand Down
6 changes: 6 additions & 0 deletions view/adminhtml/templates/payment/moto.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ use CheckoutCom\Magento2\Block\Adminhtml\Payment\Moto;
<!-- form will be added here -->
</div>
</div>
<div class="scheme-choice-frame">
<!-- form will be added here -->
</div>
<form id="motoCardForm" method="POST">
<!-- Saved cards -->
<div id="vault-container">
Expand Down Expand Up @@ -81,6 +84,9 @@ use CheckoutCom\Magento2\Block\Adminhtml\Payment\Moto;
{
publicKey: '<?= $block->escapeHtml($block->getConfig()->getAccountKeys('checkoutcom_moto')['public_key']) ?>',
debug: Boolean(<?= $block->escapeHtml($block->getConfig()->getValue('debug')) ?>),
schemeChoice: {
frameSelector: ".scheme-choice-frame"
},
cardValidationChanged: function(event) {
var cardholderName = $('#order-billing_address_firstname').val() + ' ' + $('#order-billing_address_lastname').val();

Expand Down
6 changes: 6 additions & 0 deletions view/frontend/templates/account/add-card.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ use CheckoutCom\Magento2\Block\Account\AddCard;
<!-- form will be added here -->
</div>
</div>
<div class="scheme-choice-frame">
<!-- form will be added here -->
</div>
<form class="widget-container" id="saveCardForm" method="POST">
<?= $block->getBlockHtml('formkey') ?>
<input type="hidden" id="ckoCardToken" name="ckoCardToken">
Expand Down Expand Up @@ -59,6 +62,9 @@ use CheckoutCom\Magento2\Block\Account\AddCard;
{
publicKey: ckoPublicKey,
debug: Boolean(<?= $block->escapeHtml(($block->getConfig()->getValue('debug') && $block->getConfig()->getValue('console_logging'))); ?>),
schemeChoice: {
frameSelector: ".scheme-choice-frame"
},
cardValidationChanged: function() {
if (Frames.isCardValid()) {
Frames.submitCard();
Expand Down
2 changes: 2 additions & 0 deletions view/frontend/web/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
.frames-container {
margin-bottom: 15px;
max-width: 650px;
position: relative;
z-index: 1;
}

.save-card-option {
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/css/main.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* @link https://docs.checkout.com/
*/

@import url(https://cdn.checkout.com/v2/css/cko-fonts-jsicons.css?v=1.1.9);.frames-container{margin-bottom:15px;max-width: 650px}.save-card-option{margin-bottom:10px}.clr{clear:both;visibility:hidden;height:0;width:0}.checkout-agreement label{background-image:url(../images/icon-link.png);background-repeat:no-repeat;background-position:top right;padding-right:20px;background-size:13px 13px}.message.notice{overflow-wrap:break-word}
@import url(https://cdn.checkout.com/v2/css/cko-fonts-jsicons.css?v=1.1.9);.frames-container{margin-bottom:15px;max-width: 650px;position: relative;z-index: 1;}.save-card-option{margin-bottom:10px}.clr{clear:both;visibility:hidden;height:0;width:0}.checkout-agreement label{background-image:url(../images/icon-link.png);background-repeat:no-repeat;background-position:top right;padding-right:20px;background-size:13px 13px}.message.notice{overflow-wrap:break-word}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define(
cardToken: null,
cardBin: null,
saveCard: false,
preferredScheme: false,
supportedCards: null,
redirectAfterPlaceOrder: false,
allowPlaceOrder: ko.observable(false)
Expand Down Expand Up @@ -136,11 +137,11 @@ define(
});

// Clear frames after update billing event
$(document).on('click', '.action-update', function () {
$(document).on('click', '.action-update', function () {
if ($('#checkoutcom_card_payment').is(':checked')) {
Frames.init()
Frames.init()
}
})
})
},

/**
Expand Down Expand Up @@ -217,6 +218,9 @@ define(
{
publicKey: self.getValue('public_key'),
debug: Boolean(self.getValue('debug') && self.getValue('console_logging')),
schemeChoice: {
frameSelector: ".scheme-choice-frame"
},
localization: Utilities.getShopLanguage(),
style: (formStyles) ? formStyles : {}
}
Expand Down Expand Up @@ -276,7 +280,7 @@ define(
function() {
var valid = Utilities.getBillingAddress() != null;

if(valid) {
if(valid) {
cardholderName = Utilities.getCustomerName();
}
}
Expand Down Expand Up @@ -315,6 +319,7 @@ define(
// Store the card token and the card bin
self.cardToken = event.token;
self.cardBin = event.bin;
self.preferredScheme = event.preferred_scheme;

// Enable the submit form
Frames.enableSubmitForm();
Expand All @@ -323,6 +328,14 @@ define(
self.allowPlaceOrder(true);
}
);

// Card bin event
Frames.addEventHandler(
Frames.Events.CARD_BIN_CHANGED,
function (event) {
self.preferredScheme = event.scheme;
}
);
},

/**
Expand All @@ -338,6 +351,7 @@ define(
cardToken: this.cardToken,
cardBin: this.cardBin,
saveCard: this.saveCard,
preferredScheme: this.preferredScheme,
source: METHOD_ID
};

Expand Down
11 changes: 7 additions & 4 deletions view/frontend/web/template/payment/checkoutcom_card_payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<div class="message message-cko" data-bind="attr: {'id': (getCode()+'_message')}"></div>
<div class="message message-response-code" data-bind="attr: {'id': (getCode()+'_message')}"></div>
<div class="message debug-message" data-bind="attr: {'id': (getCode()+'_message')}"></div>

<!-- Card form -->
<div class="frames-container">
<form method="POST" data-bind="attr: {'id': formId}">
Expand All @@ -49,6 +49,9 @@
<!-- Form will be added here -->
</div>
</div>
<div class="scheme-choice-frame">
<!-- form will be added here -->
</div>
<p class="error-message"></p>
<!-- /ko -->
<!-- ko if: (getFormLayout() == 'multi') -->
Expand Down Expand Up @@ -120,7 +123,7 @@
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>

<!-- ko if: (isVaultEnabled() && isSaveCardEnabled() && isLoggedIn()) -->
<div class="field choice save-card-option">
<input type="checkbox" name="saveCard" class="checkbox"/>
Expand All @@ -129,14 +132,14 @@
</label>
</div>
<!-- /ko -->

<!-- Agreements form -->
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>

<!-- Actions -->
<div class="actions-toolbar">
<div class="primary">
Expand Down

0 comments on commit ad1923c

Please sign in to comment.