- | = $block->escapeHtml($item->getCardType()); ?> |
- = $block->escapeHtml($item->getMaskedPan()); ?> |
- = $block->escapeHtml($item->getExpires()); ?> |
-
+ | = $block->escapeHtml($item->getCardType()); ?> |
+ = $block->escapeHtml($item->getMaskedPan()); ?> |
+ = $block->escapeHtml($item->getExpires()); ?> |
+
getSize() > 0) {
getPrimary()): ?>checked="checked" />
|
-
+ |
@@ -57,5 +58,5 @@ if ($collection->getSize() > 0) {
- No saved credit cards.
+ = $block->escapeHtml(__('No saved credit cards.')); ?>
diff --git a/view/frontend/web/css/ordersummary.css b/view/frontend/web/css/ordersummary.css
index 0950d02e..1375c342 100755
--- a/view/frontend/web/css/ordersummary.css
+++ b/view/frontend/web/css/ordersummary.css
@@ -22,6 +22,10 @@ input#pensioCreditCardPaymentSubmitButton {
margin-bottom: 5%;
}
+#notice-cookie-block {
+ display: none;
+}
+
select#emonth {
width: 50%;
}
diff --git a/view/frontend/web/js/action/set-payment.js b/view/frontend/web/js/action/set-payment.js
index 524a88ae..7f625ca0 100755
--- a/view/frontend/web/js/action/set-payment.js
+++ b/view/frontend/web/js/action/set-payment.js
@@ -61,26 +61,33 @@ define(
tokenId = $(".payment-method._active select[name='ccToken']").val();
}
- $.ajax({
- method: "POST",
- url: window.checkoutConfig.payment['sdm_altapay'].url,
- data: {
- paytype: method,
- cartid: quote.getQuoteId(),
- orderid: data,
- tokenid: tokenId
- },
- dataType: 'json'
- }).done(function (jsonResponse) {
- if (jsonResponse.result == 'success') {
- window.location.href = jsonResponse.formurl;
- } else {
- fullScreenLoader.stopLoader();
- $(".payment-method._active").find('#altapay-error-message').css('display', 'block');
- $(".payment-method._active").find('#altapay-error-message').text(jsonResponse.message);
- return false;
+ var paymentMethod = window.checkoutConfig.payment['sdm_altapay'].terminaldata;
+ for (var obj in paymentMethod) {
+ if (obj === paymentData.method) {
+ if(paymentMethod[obj].isapplepay !== '1' ) {
+ $.ajax({
+ method: "POST",
+ url: window.checkoutConfig.payment['sdm_altapay'].url,
+ data: {
+ paytype: method,
+ cartid: quote.getQuoteId(),
+ orderid: data,
+ tokenid: tokenId
+ },
+ dataType: 'json'
+ }).done(function (jsonResponse) {
+ if (jsonResponse.result == 'success') {
+ window.location.href = jsonResponse.formurl;
+ } else {
+ fullScreenLoader.stopLoader();
+ $(".payment-method._active").find('#altapay-error-message').css('display', 'block');
+ $(".payment-method._active").find('#altapay-error-message').text(jsonResponse.message);
+ return false;
+ }
+ });
+ }
}
- });
+ }
}).fail(function (response) {
errorProcessor.process(response, messageContainer);
fullScreenLoader.stopLoader();
diff --git a/view/frontend/web/js/view/payment/method-renderer/terminal-abstract.js b/view/frontend/web/js/view/payment/method-renderer/terminal-abstract.js
index ec3d3a25..6e13372b 100755
--- a/view/frontend/web/js/view/payment/method-renderer/terminal-abstract.js
+++ b/view/frontend/web/js/view/payment/method-renderer/terminal-abstract.js
@@ -1,7 +1,7 @@
/**
* Altapay Module for Magento 2.x.
*
- * Copyright © 2020 Altapay. All rights reserved.
+ * Copyright © 2018 Altapay. All rights reserved.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@@ -14,9 +14,10 @@ define(
'jquery',
'Magento_Checkout/js/view/payment/default',
'Magento_Customer/js/customer-data',
- 'SDM_Altapay/js/action/set-payment'
+ 'SDM_Altapay/js/action/set-payment',
+ 'Magento_Checkout/js/action/redirect-on-success'
],
- function ($, Component, storage, Action) {
+ function ($, Component, storage, Action, redirectOnSuccessAction) {
'use strict';
return Component.extend({
@@ -28,6 +29,15 @@ define(
redirectAfterPlaceOrder: false,
placeOrder: function () {
+ var self = this;
+ var paymentMethod = window.checkoutConfig.payment['sdm_altapay'].terminaldata;
+ for (var obj in paymentMethod) {
+ if (obj === self.getCode()) {
+ if(paymentMethod[obj].isapplepay === '1' ) {
+ this.onApplePayButtonClicked();
+ }
+ }
+ }
$('#altapay-error-message').text('');
var auth = window.checkoutConfig.payment[this.getDefaultCode()].auth;
var connection = window.checkoutConfig.payment[this.getDefaultCode()].connection;
@@ -46,13 +56,35 @@ define(
);
}
},
+ termnialId: function () {
+ var self = this;
+ var terminalname;
+ var terminalinfo = [];
+ var paymentMethod = window.checkoutConfig.payment[this.getDefaultCode()].terminaldata;
+ var isSafari = (/^((?!chrome|android).)*safari/i.test(navigator.userAgent));
+ for (var obj in paymentMethod) {
+ if (obj === self.getCode()) {
+ if (paymentMethod[obj].isapplepay == 1 && isSafari === false) {
+ terminalname = "";
+ } else {
+ if (paymentMethod[obj].terminalname != " ") {
+ terminalname = paymentMethod[obj].terminalname;
+ }
+ }
+ }
+ }
+ terminalinfo.push(terminalname, paymentMethod[obj].applepaylabel);
+
+ return terminalinfo;
+ },
terminalName: function () {
var self = this;
var terminalname;
var paymentMethod = window.checkoutConfig.payment[this.getDefaultCode()].terminaldata;
+ var isSafari = (/^((?!chrome|android).)*safari/i.test(navigator.userAgent));
for (var obj in paymentMethod) {
if (obj === self.getCode()) {
- if (paymentMethod[obj].terminallogo != "" && paymentMethod[obj].showlogoandtitle == false) {
+ if (paymentMethod[obj].isapplepay == 1 && isSafari === false) {
terminalname = "";
} else {
if (paymentMethod[obj].terminalname != " ") {
@@ -81,6 +113,122 @@ define(
}
},
+ onApplePayButtonClicked: function() {
+ var terminalinfo = this.termnialId();
+ var applePayLabel = 'AltaPay ApplePay Charge';
+ var configData = window.checkoutConfig.payment[this.getDefaultCode()];
+ var baseurl = configData.baseUrl;
+ if (terminalinfo[1] !== null) {
+ applePayLabel = terminalinfo[1];
+ }
+ if (!ApplePaySession) {
+ return;
+ }
+
+ // Define ApplePayPaymentRequest
+ const request = {
+ "countryCode": configData.countryCode,
+ "currencyCode": configData.currencyCode,
+ "merchantCapabilities": [
+ "supports3DS"
+ ],
+ "supportedNetworks": [
+ "visa",
+ "masterCard",
+ "amex",
+ "discover"
+ ],
+ "total": {
+ "label": applePayLabel,
+ "type": "final",
+ "amount": configData.grandTotalAmount
+ }
+ };
+
+ // Create ApplePaySession
+ const session = new ApplePaySession(3, request);
+
+ session.onvalidatemerchant = async event => {
+ var url = baseurl+"sdmaltapay/index/applepay";
+ // Call your own server to request a new merchant session.
+ $.ajax({
+ url: url,
+ data: {
+ validationUrl: event.validationURL,
+ termminalid: terminalinfo[0]
+ },
+ type: 'post',
+ dataType: 'JSON',
+ success: function(response) {
+ var responsedata = jQuery.parseJSON(response);
+ session.completeMerchantValidation(responsedata);
+ }
+ });
+ };
+
+ session.onpaymentmethodselected = event => {
+ let total = {
+ "label": applePayLabel,
+ "type": "final",
+ "amount": configData.grandTotalAmount
+ }
+
+ const update = { "newTotal": total };
+ session.completePaymentMethodSelection(update);
+ };
+
+ session.onshippingmethodselected = event => {
+ // Define ApplePayShippingMethodUpdate based on the selected shipping method.
+ // No updates or errors are needed, pass an empty object.
+ const update = {};
+ session.completeShippingMethodSelection(update);
+ };
+
+ session.onshippingcontactselected = event => {
+ // Define ApplePayShippingContactUpdate based on the selected shipping contact.
+ const update = {};
+ session.completeShippingContactSelection(update);
+ };
+
+ session.onpaymentauthorized = event => {
+ var method = this.terminal.substr(this.terminal.indexOf(" ") + 1);
+ var url = baseurl + "sdmaltapay/index/applepayresponse";
+ $.ajax({
+ url: url,
+ data: {
+ providerData: JSON.stringify(event.payment.token),
+ paytype: method
+ },
+ type: 'post',
+ dataType: 'JSON',
+ complete: function(response) {
+ var status;
+ var responsestatus = response.responseJSON.Result.toLowerCase();
+ if (responsestatus === 'success') {
+ status = ApplePaySession.STATUS_SUCCESS;
+ session.completePayment(status);
+ redirectOnSuccessAction.execute();
+ } else {
+ status = ApplePaySession.STATUS_FAILURE;
+ session.completePayment(status);
+ }
+ }
+ });
+ };
+ session.oncancel = event => {
+ var url = baseurl + "sdmaltapay/index/cancel";
+ $.ajax({
+ url: url,
+ type: 'post',
+ success: function(data, status, xhr) {
+ window.location.reload();
+ }
+ });
+
+ };
+
+ session.begin();
+ },
getDefaultCode: function () {
return 'sdm_altapay';
},
@@ -91,7 +239,7 @@ define(
for (var obj in paymentMethod) {
if (obj === self.getCode()) {
- if (paymentMethod[obj].terminallogo != " ") {
+ if (paymentMethod[obj].terminallogo != " " && paymentMethod[obj].showlogoandtitle == true) {
if (paymentMethod[obj].terminallogo != null) {
terminallogo = paymentMethod[obj].terminallogo
}
@@ -132,4 +280,4 @@ define(
}
});
}
-);
+);
\ No newline at end of file
diff --git a/view/frontend/web/template/payment/terminal.html b/view/frontend/web/template/payment/terminal.html
index 04254861..b563f223 100755
--- a/view/frontend/web/template/payment/terminal.html
+++ b/view/frontend/web/template/payment/terminal.html
@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
-->
-
+
- ![]()
+
+ ![]()
+
|