Skip to content

Commit

Permalink
support applepay
Browse files Browse the repository at this point in the history
  • Loading branch information
artembelfox committed May 31, 2023
1 parent dc0e157 commit fd5c7ef
Show file tree
Hide file tree
Showing 23 changed files with 1,126 additions and 176 deletions.
384 changes: 310 additions & 74 deletions admin/controller/payment/paypal.php

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion admin/language/en-gb/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$_['text_tab_dashboard'] = 'Back to the dashboard';
$_['text_tab_general'] = 'General';
$_['text_tab_button'] = 'Buttons';
$_['text_tab_applepay_button'] = 'ApplePay';
$_['text_tab_card'] = 'Advanced Cards';
$_['text_tab_message'] = 'Pay Later messaging';
$_['text_tab_order_status'] = 'Order Statuses';
Expand All @@ -23,6 +24,7 @@
$_['text_statistic_title'] = 'The platform that grows with you';
$_['text_statistic_description'] = 'The platform has 416 million customers';
$_['text_button_settings'] = 'Button settings';
$_['text_applepay_button_settings'] = 'ApplePay Button settings';
$_['text_card_settings'] = 'Card settings';
$_['text_message_settings'] = 'Message settings';
$_['text_day'] = 'Today';
Expand All @@ -36,12 +38,15 @@
$_['text_cart'] = 'Cart';
$_['text_checkout'] = 'Checkout';
$_['text_production'] = 'Production';
$_['text_sandbox'] = 'Sandbox';
$_['text_multi_button'] = 'Multi Button';
$_['text_one_button'] = 'One Button';
$_['text_sandbox'] = 'Sandbox';
$_['text_authorization'] = 'Authorization';
$_['text_sale'] = 'Sale';
$_['text_connect'] = 'Your seller account has been connected.<br /><strong>Client ID</strong> = %s<br /><strong>Secret</strong> = %s<br /><strong>Merchant ID</strong> = %s<br /><strong>Webhook ID</strong> = %s<br /><strong>Environment</strong> = %s<br />If you would like to connect another account, please, disconnect.';
$_['text_applepay_alert'] = '<strong>You need to verify any domain names in your environment that will show an Apple Pay button.</strong><br /><br />If Apple hasn’t verified a domain, they will reject any payments from that domain. The Apple Pay payment method won’t work if the domain isn’t registered.';
$_['text_applepay_step_1'] = '<strong>Download and host live domain association file</strong><br />1. Download the domain association file for your live environment.<br />2. Host the file on your production site at /.well-known/apple-developer-merchantid-domain-association.';
$_['text_applepay_step_2'] = '<strong>Register your live domain</strong><br />1. Go to the Payment Methods page on your PayPal account.<br />2. Register all high-level domains such as business.example.com, and subdomains such as checkout.business.example.com, that show the Apple Pay button.';
$_['text_message_alert_uk'] = '<strong>Turn browsers into buyers with Pay in 3.¹</strong> Help increase sales while giving your customers flexible payments and more buying power. With Pay in 3, customers can pay over time in three interest-free payments while you get paid in full, up front on purchases — at no additional cost.';
$_['text_message_footnote_uk'] = '¹Pay in 3 availability is subject to merchant status, sector and integration. Consumer eligibility is subject to status and approval. See <a href="https://www.paypal.com/uk/webapps/mpp/paypal-payin3/terms" target="_blank">product terms</a> for more details.';
$_['text_message_alert_us'] = '<strong>Help increase your sales with our built-in Pay Later options.</strong> With PayPal Pay Later, your business can offer Pay in 4 and Pay Monthly¹ — two valuable ways for your customers to make a purchase and pay for it over time while you get paid in full, up front. Both are included at no additional cost to your business.';
Expand Down Expand Up @@ -93,6 +98,7 @@
$_['text_blue'] = 'Blue';
$_['text_silver'] = 'Silver';
$_['text_white'] = 'White';
$_['text_white_outline'] = 'White Outline';
$_['text_black'] = 'Black';
$_['text_pill'] = 'Pill';
$_['text_rect'] = 'Rect';
Expand All @@ -101,6 +107,10 @@
$_['text_buy_now'] = 'Buy Now';
$_['text_pay_pal'] = 'PayPal';
$_['text_installment'] = 'Installment';
$_['text_buy'] = 'Buy';
$_['text_donate'] = 'Donate';
$_['text_plain'] = 'Plain';
$_['text_check_out'] = 'Check out';
$_['text_card'] = 'Credit or debit cards';
$_['text_credit'] = 'PayPal Credit';
$_['text_bancontact'] = 'Bancontact';
Expand Down Expand Up @@ -200,6 +210,11 @@
$_['entry_button_shape'] = 'Button Shape';
$_['entry_button_label'] = 'Button Label';
$_['entry_button_tagline'] = 'Button Tagline';
$_['entry_applepay_button_align'] = 'Button Align';
$_['entry_applepay_button_size'] = 'Button Size';
$_['entry_applepay_button_color'] = 'Button Color';
$_['entry_applepay_button_shape'] = 'Button Shape';
$_['entry_applepay_button_type'] = 'Button Type';
$_['entry_card_align'] = 'Card Align';
$_['entry_card_size'] = 'Card Size';
$_['entry_card_secure_status'] = 'Card 3D Secure Status';
Expand Down Expand Up @@ -233,6 +248,7 @@
// Help
$_['help_status'] = 'Enable/Disable extension.';
$_['help_button_status'] = 'When activated PayPal will display personalized Smart Buttons avalible to your customers based on their location.';
$_['help_applepay_button_status'] = 'PayPal verifies if you are eligible for Apple Pay payment and will display this option on the checkout step if available.';
$_['help_card_status'] = 'PayPal verifies if you are eligible for advanced card payment and will display this option on the checkout step if available.';
$_['help_message_status'] = 'Add pay later messaging to your site.';
$_['help_checkout_mode'] = 'If your checkout is incompatible with this payment, then we advise you to set the "One Button" mode.';
Expand All @@ -248,6 +264,8 @@
$_['button_connect'] = 'Connect';
$_['button_disconnect'] = 'Disconnect';
$_['button_all_settings'] = 'All Settings';
$_['button_download'] = 'Download';
$_['button_download_host'] = 'Download and host';
$_['button_send'] = 'Submit';
$_['button_cart'] = 'Add to cart';
$_['button_checkout'] = 'Checkout';
Expand All @@ -256,6 +274,7 @@
// Success
$_['success_save'] = 'Success: You have modified PayPal!';
$_['success_send'] = 'Success: Your contact details have been successfully sent to paypal!';
$_['success_download_host'] = 'Success: Association file has been successfully uploaded and hosted!';
$_['success_agree'] = 'Success: Deactivation was successful!';

// Error
Expand Down
29 changes: 29 additions & 0 deletions admin/view/image/payment/icon-applepay-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions admin/view/javascript/paypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ var PayPalAPI = (function () {
$('#paypal_button_' + paypal_data['page_code'] + '_container').addClass('paypal-spinner');
}

if (paypal_data['components'].includes('applepay')) {
$('#applepay_button_container').html('');
$('#applepay_button_container').addClass('paypal-spinner');
}

if (paypal_data['components'].includes('hosted-fields')) {
$('#paypal_card_container').find('iframe').remove();
$('#paypal_card_container').addClass('paypal-spinner');
Expand Down Expand Up @@ -119,6 +124,51 @@ var PayPalAPI = (function () {
$('#paypal_button_' + paypal_data['page_code'] + '_container').removeClass('paypal-spinner');
}

if (paypal_data['components'].includes('applepay') && $('#applepay_button').length && !$('#applepay_button_container').html()) {
$('#applepay_button').css('text-align', paypal_data['applepay_button_align']);

var applepay_button_style = [];

if (paypal_data['applepay_button_width']) {
$('#applepay_button_container').css('display', 'inline-block');
$('#applepay_button_container').css('width', paypal_data['applepay_button_width']);
} else {
$('#applepay_button_container').css('display', 'block');
$('#applepay_button_container').css('width', 'auto');
}

var applepay_button = document.createElement('apple-pay-button');

applepay_button.setAttribute('id', 'apple-pay-button');
applepay_button.setAttribute('buttonstyle', paypal_data['applepay_button_color']);
applepay_button.setAttribute('type', paypal_data['applepay_button_type']);
applepay_button.setAttribute('locale', paypal_data['locale']);

var applepay_button_style = [];

applepay_button_style.push('display: inline-block');

if (paypal_data['applepay_button_width']) {
applepay_button_style.push('--apple-pay-button-width: ' + paypal_data['applepay_button_width']);
} else {
applepay_button_style.push('--apple-pay-button-width: 100%');
}

applepay_button_style.push('--apple-pay-button-height: calc(var(--apple-pay-button-width) / 7.5)');

if (paypal_data['applepay_button_shape'] == 'pill') {
applepay_button_style.push('--apple-pay-button-border-radius: 1000px');
} else {
applepay_button_style.push('--apple-pay-button-border-radius: 4px');
}

applepay_button.setAttribute('style', applepay_button_style.join('; '));

document.querySelector('#applepay_button_container').appendChild(applepay_button);

$('#applepay_button_container').removeClass('paypal-spinner');
}

if (paypal_data['components'].includes('hosted-fields') && $('#paypal_card').length) {
$('#paypal_card').css('text-align', paypal_data['card_align']);

Expand Down
21 changes: 21 additions & 0 deletions admin/view/stylesheet/paypal.css
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@
width: 37px;
background-image: url('../image/payment/icon-button.svg');
}
.payment-paypal .card .tab .tab-icon-applepay-button {
width: 37px;
background-image: url('../image/payment/icon-applepay-button.svg');
}
.payment-paypal .card .tab .tab-icon-card {
width: 33px;
background-image: url('../image/payment/icon-card.svg');
Expand Down Expand Up @@ -403,6 +407,12 @@
.payment-paypal .card .section-button-setting .legend {
padding: 10px 0px;
}
.payment-paypal .card .section-applepay-button-setting {
padding: 0px 0px;
}
.payment-paypal .card .section-applepay-button-setting .legend {
padding: 10px 0px;
}
.payment-paypal .card .section-card-setting {
padding: 0px 0px;
}
Expand Down Expand Up @@ -688,6 +698,17 @@
width: 100% !important;
}
}
.payment-paypal .card .applepay-button {
position: relative;
}
@media (max-width: 476px) {
.payment-paypal .card .applepay-button .applepay-button-container {
width: 100% !important;
}
.payment-paypal .card .applepay-button #apple-pay-button {
width: 100% !important;
}
}
.payment-paypal .card .paypal-card {
position: relative;
}
Expand Down
Loading

0 comments on commit fd5c7ef

Please sign in to comment.