Skip to content

Commit

Permalink
[3.0.x.x] PayPal upgrade
Browse files Browse the repository at this point in the history
Upgrade PayPal payment extension to version 3.0.0
  • Loading branch information
mhcwebdesign committed Feb 27, 2024
1 parent 3e8b7ef commit e922645
Show file tree
Hide file tree
Showing 23 changed files with 2,119 additions and 694 deletions.
250 changes: 215 additions & 35 deletions upload/admin/controller/extension/payment/paypal.php

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions upload/admin/language/en-gb/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
$_['text_tab_googlepay_button'] = 'Google Pay';
$_['text_tab_applepay_button'] = 'Apple Pay';
$_['text_tab_card'] = 'Advanced Cards';
$_['text_tab_message'] = 'Pay Later messaging';
$_['text_tab_message_configurator'] = 'Pay Later Messaging';
$_['text_tab_message_setting'] = 'Pay Later Message placement';
$_['text_tab_order_status'] = 'Order Statuses';
$_['text_tab_contact'] = 'Contact PayPal';
$_['text_all_sales'] = 'All Sales';
Expand Down Expand Up @@ -126,14 +127,15 @@
$_['text_mybank'] = 'MyBank';
$_['text_p24'] = 'Przelewy24';
$_['text_sepa'] = 'SEPA-Lastschrift';
$_['text_sofort'] = 'Sofort';
$_['text_venmo'] = 'Venmo';
$_['text_paylater'] = 'Pay Later';
$_['text_auto'] = 'Auto';
$_['text_text'] = 'Text Message';
$_['text_flex'] = 'Flexible Banner';
$_['text_accept'] = 'Accept';
$_['text_decline'] = 'Decline';
$_['text_sca_when_required'] = 'SCA When Required';
$_['text_sca_always'] = 'SCA Always';
$_['text_recommended'] = '(recommended)';
$_['text_3ds_failed_authentication'] = 'Failed authentication.';
$_['text_3ds_rejected_authentication'] = 'Rejected authentication.';
Expand Down Expand Up @@ -236,20 +238,13 @@
$_['entry_applepay_button_type'] = 'Button Type';
$_['entry_card_align'] = 'Card Align';
$_['entry_card_size'] = 'Card Size';
$_['entry_card_secure_status'] = 'Card 3D Secure Status';
$_['entry_card_secure_method'] = 'Card 3D Secure Method';
$_['entry_card_secure_scenario'] = 'Card 3D Secure Scenarios';
$_['entry_card_number'] = 'Card Number';
$_['entry_expiration_date'] = 'Expiration Date';
$_['entry_cvv'] = 'CVV';
$_['entry_message_insert_tag'] = 'Message Insert Tag';
$_['entry_message_insert_type'] = 'Message Insert Type';
$_['entry_message_align'] = 'Message Align';
$_['entry_message_size'] = 'Message Size';
$_['entry_message_layout'] = 'Message Layout';
$_['entry_message_text_color'] = 'Message Text Color';
$_['entry_message_text_size'] = 'Message Text Size';
$_['entry_message_flex_color'] = 'Message Banner Color';
$_['entry_message_flex_ratio'] = 'Message Banner Ratio';
$_['entry_contact_company'] = 'Company';
$_['entry_contact_first_name'] = 'First Name';
$_['entry_contact_last_name'] = 'Last Name';
Expand All @@ -270,7 +265,6 @@
$_['help_googlepay_button_status'] = 'PayPal verifies if you are eligible for Google Pay payment and will display this option on the checkout step if available.';
$_['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.';
$_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.';
$_['help_country_code'] = 'Select the default country for PayPal.';
Expand All @@ -279,7 +273,7 @@
$_['help_card_currency_code'] = 'Select the default currency for PayPal Card.';
$_['help_card_currency_value'] = 'Set to 1.00000 if this is your default currency.';
$_['help_cron_url'] = 'Set a cron to call this URL.';
$_['help_card_secure_status'] = '3D Secure enables you to authenticate card holders through card issuers. It reduces the likelihood of fraud when you use supported cards and improves transaction perfomance. A successful 3D Secure authentication can shift liability for chargebacks due to fraud from you -the merchant- to the card issuer.';
$_['help_card_secure_method'] = '3D Secure enables you to authenticate card holders through card issuers. \'SCA Always\' method trigger 3D Secure for every transaction, regardless of SCA requirements. \'SCA When Required\' method returns a 3D Secure contingency when it is a mandate in the region where you operate.';
$_['help_card_secure_scenario'] = '3D Secure authentication is perfomed only if the card is enrolled for the service. In scenarios where the 3D Secure authentication has not been successful, you have the option to complete the payment at your own risk, meaning that you -the merchant- will be liable in case of a chargeback.';

// Button
Expand Down
30 changes: 28 additions & 2 deletions upload/admin/model/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,20 @@ public function getCountryByCode($code) {

return $query->row;
}

public function deletePayPalCustomerTokens($customer_id) {
$query = $this->db->query("DELETE FROM `" . DB_PREFIX . "paypal_checkout_integration_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "'");
}

public function editPayPalOrder($data) {
$sql = "UPDATE `" . DB_PREFIX . "paypal_checkout_integration_order` SET";

$implode = array();

if (!empty($data['paypal_order_id'])) {
$implode[] = "`paypal_order_id` = '" . $this->db->escape($data['paypal_order_id']) . "'";
}

if (!empty($data['transaction_id'])) {
$implode[] = "`transaction_id` = '" . $this->db->escape($data['transaction_id']) . "'";
}
Expand All @@ -170,6 +178,22 @@ public function editPayPalOrder($data) {
$implode[] = "`vault_customer_id` = '" . $this->db->escape($data['vault_customer_id']) . "'";
}

if (!empty($data['card_type'])) {
$implode[] = "`card_type` = '" . $this->db->escape($data['card_type']) . "'";
}

if (!empty($data['card_nice_type'])) {
$implode[] = "`card_nice_type` = '" . $this->db->escape($data['card_nice_type']) . "'";
}

if (!empty($data['card_last_digits'])) {
$implode[] = "`card_last_digits` = '" . $this->db->escape($data['card_last_digits']) . "'";
}

if (!empty($data['card_expiry'])) {
$implode[] = "`card_expiry` = '" . $this->db->escape($data['card_expiry']) . "'";
}

if (!empty($data['environment'])) {
$implode[] = "`environment` = '" . $this->db->escape($data['environment']) . "'";
}
Expand Down Expand Up @@ -200,7 +224,7 @@ public function getPayPalOrder($order_id) {
public function editOrderRecurringStatus($order_recurring_id, $status) {
$this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = '" . (int)$status . "' WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'");
}

public function setAgreeStatus() {
$this->db->query("UPDATE " . DB_PREFIX . "country SET status = '0' WHERE (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')");
$this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '0' WHERE country_id = '220' AND (`code` = '43' OR `code` = '14' OR `code` = '09')");
Expand Down Expand Up @@ -282,11 +306,13 @@ public function log($data, $title = null) {
}

public function install() {
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order` (`order_id` INT(11) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NULL, `payment_method` VARCHAR(20) NULL, `vault_id` VARCHAR(50) NULL, `vault_customer_id` VARCHAR(50) NULL, `environment` VARCHAR(20) NULL, PRIMARY KEY (`order_id`, `transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci");
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token` (`customer_id` INT(11) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `main_token_status` TINYINT(1) NOT NULL, PRIMARY KEY (`customer_id`, `payment_method`, `vault_id`), KEY `vault_customer_id` (`vault_customer_id`), KEY `main_token_status` (`main_token_status`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci");
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order` (`order_id` INT(11) NOT NULL, `paypal_order_id` VARCHAR(20) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `environment` VARCHAR(20) NOT NULL, PRIMARY KEY (`order_id`), KEY `paypal_order_id` (`paypal_order_id`), KEY `transaction_id` (`transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci");
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` (`paypal_order_recurring_id` INT(11) NOT NULL AUTO_INCREMENT, `order_id` INT(11) NOT NULL, `order_recurring_id` INT(11) NOT NULL, `date_added` DATETIME NOT NULL, `date_modified` DATETIME NOT NULL, `next_payment` DATETIME NOT NULL, `trial_end` DATETIME DEFAULT NULL, `subscription_end` DATETIME DEFAULT NULL, `currency_code` CHAR(3) NOT NULL, `total` DECIMAL(10, 2) NOT NULL, PRIMARY KEY (`paypal_order_recurring_id`), KEY (`order_id`), KEY (`order_recurring_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci");
}

public function uninstall() {
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token`");
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order`");
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring`");
}
Expand Down
44 changes: 40 additions & 4 deletions upload/admin/view/stylesheet/paypal/paypal.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,13 @@
width: 33px;
background-image: url('../../image/payment/paypal/icon-card.svg');
}
.payment-paypal .panel-default .tab .tab-icon-message {
.payment-paypal .panel-default .tab .tab-icon-message-setting {
width: 37px;
background-image: url('../../image/payment/paypal/icon-message.svg');
background-image: url('../../image/payment/paypal/icon-message-setting.svg');
}
.payment-paypal .panel-default .tab .tab-icon-message-configurator {
width: 37px;
background-image: url('../../image/payment/paypal/icon-message-configurator.svg');
}
.payment-paypal .panel-default .tab .tab-icon-order-status {
width: 28px;
Expand Down Expand Up @@ -656,10 +660,37 @@
background-size: contain;
background-repeat: no-repeat;
}
.payment-paypal .panel-default #messaging-configurator * {
font-size: 13px;
line-height: 1.4;
-webkit-box-sizing: revert;
-moz-box-sizing: revert;
box-sizing: revert;
}
.payment-paypal .panel-default #messaging-configurator > div {
margin: 0 !important;
justify-content: flex-start !important;
}
.payment-paypal .panel-default #configurator-eligibleContainer{
width: 100% !important;
max-width: 110rem !important;
padding: 0 !important;
}
.payment-paypal .panel-default #messaging-configurator .headerOverride {
font-size: 15px;
font-weight: 700;
color: #000000;
}
.payment-paypal .panel-default #messaging-configurator .buttonOverride {
display: none;
}
.payment-paypal .panel-default #messaging-configurator input {
position: absolute;
}
.payment-paypal .panel-default #messaging-configurator .css-15yf9ku {
.payment-paypal .panel-default #messaging-configurator [accordionname] button:not([id^="dropdownMenuButton"]) {
padding: 8px 16px 16px 16px;
}
.payment-paypal .card #messaging-configurator #configurator-previewSectionContainer > div + div {
height: auto;
}
@media (max-width: 767px) {
Expand Down Expand Up @@ -870,6 +901,11 @@
.payment-paypal .panel-dashboard .col {
padding: 0px 7px;
}
@media (min-width: 1200px) {
.payment-paypal .panel-dashboard .col-tab {
width: 20%;
}
}
.payment-paypal .panel-dashboard .paypal-sale {
padding: 11px 0px;
}
Expand All @@ -893,7 +929,7 @@
.payment-paypal .panel-dashboard .tab {
position: relative;
display: block;
padding: 37px 7px 30px 7px;
padding: 37px 10px 30px 10px;
text-align: center;
background: #FFFFFF;
box-shadow: 0px 2px 6px #00000029;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<li class="nav-tab"><a href="{{ href_googlepay_button }}" class="tab"><i class="tab-icon tab-icon-googlepay-button"></i><span class="tab-title">{{ text_tab_googlepay_button }}</span></a></li>
<li class="nav-tab active"><a href="{{ href_applepay_button }}" class="tab"><i class="tab-icon tab-icon-applepay-button"></i><span class="tab-title">{{ text_tab_applepay_button }}</span></a></li>
<li class="nav-tab"><a href="{{ href_card }}" class="tab"><i class="tab-icon tab-icon-card"></i><span class="tab-title">{{ text_tab_card }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message }}" class="tab"><i class="tab-icon tab-icon-message"></i><span class="tab-title">{{ text_tab_message }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_configurator }}" class="tab"><i class="tab-icon tab-icon-message-configurator"></i><span class="tab-title">{{ text_tab_message_configurator }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_setting }}" class="tab"><i class="tab-icon tab-icon-message-setting"></i><span class="tab-title">{{ text_tab_message_setting }}</span></a></li>
<li class="nav-tab"><a href="{{ href_order_status }}" class="tab"><i class="tab-icon tab-icon-order-status"></i><span class="tab-title">{{ text_tab_order_status }}</span></a></li>
<li class="nav-tab"><a href="{{ href_contact }}" class="tab"><i class="tab-icon tab-icon-contact"></i><span class="tab-title">{{ text_tab_contact }}</span></a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<li class="nav-tab"><a href="{{ href_googlepay_button }}" class="tab"><i class="tab-icon tab-icon-googlepay-button"></i><span class="tab-title">{{ text_tab_googlepay_button }}</span></a></li>
<li class="nav-tab"><a href="{{ href_applepay_button }}" class="tab"><i class="tab-icon tab-icon-applepay-button"></i><span class="tab-title">{{ text_tab_applepay_button }}</span></a></li>
<li class="nav-tab"><a href="{{ href_card }}" class="tab"><i class="tab-icon tab-icon-card"></i><span class="tab-title">{{ text_tab_card }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message }}" class="tab"><i class="tab-icon tab-icon-message"></i><span class="tab-title">{{ text_tab_message }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_configurator }}" class="tab"><i class="tab-icon tab-icon-message-configurator"></i><span class="tab-title">{{ text_tab_message_configurator }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_setting }}" class="tab"><i class="tab-icon tab-icon-message-setting"></i><span class="tab-title">{{ text_tab_message_setting }}</span></a></li>
<li class="nav-tab"><a href="{{ href_order_status }}" class="tab"><i class="tab-icon tab-icon-order-status"></i><span class="tab-title">{{ text_tab_order_status }}</span></a></li>
<li class="nav-tab"><a href="{{ href_contact }}" class="tab"><i class="tab-icon tab-icon-contact"></i><span class="tab-title">{{ text_tab_contact }}</span></a></li>
</ul>
Expand Down
18 changes: 12 additions & 6 deletions upload/admin/view/template/extension/payment/paypal/card.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<li class="nav-tab"><a href="{{ href_googlepay_button }}" class="tab"><i class="tab-icon tab-icon-googlepay-button"></i><span class="tab-title">{{ text_tab_googlepay_button }}</span></a></li>
<li class="nav-tab"><a href="{{ href_applepay_button }}" class="tab"><i class="tab-icon tab-icon-applepay-button"></i><span class="tab-title">{{ text_tab_applepay_button }}</span></a></li>
<li class="nav-tab active"><a href="{{ href_card }}" class="tab"><i class="tab-icon tab-icon-card"></i><span class="tab-title">{{ text_tab_card }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message }}" class="tab"><i class="tab-icon tab-icon-message"></i><span class="tab-title">{{ text_tab_message }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_configurator }}" class="tab"><i class="tab-icon tab-icon-message-configurator"></i><span class="tab-title">{{ text_tab_message_configurator }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_setting }}" class="tab"><i class="tab-icon tab-icon-message-setting"></i><span class="tab-title">{{ text_tab_message_setting }}</span></a></li>
<li class="nav-tab"><a href="{{ href_order_status }}" class="tab"><i class="tab-icon tab-icon-order-status"></i><span class="tab-title">{{ text_tab_order_status }}</span></a></li>
<li class="nav-tab"><a href="{{ href_contact }}" class="tab"><i class="tab-icon tab-icon-contact"></i><span class="tab-title">{{ text_tab_contact }}</span></a></li>
</ul>
Expand Down Expand Up @@ -125,11 +126,16 @@
</select>
</div>
<div class="form-group">
<label class="control-label" for="input_card_secure_status"><span data-toggle="tooltip" title="{{ help_card_secure_status }}">{{ entry_card_secure_status }}</span></label>
<div id="input_secure_status">
<input type="hidden" name="payment_paypal_setting[card][secure_status]" value="0" />
<input type="checkbox" name="payment_paypal_setting[card][secure_status]" value="1" class="switch" {% if setting['card']['secure_status'] %}checked="checked"{% endif %} />
</div>
<label class="control-label" for="input_card_secure_method"><span data-toggle="tooltip" title="{{ help_card_secure_method }}">{{ entry_card_secure_method }}</span></label>
<select name="payment_paypal_setting[card][secure_method]" id="input_card_secure_method" class="form-control">
{% for card_secure_method in setting['card_secure_method'] %}
{% if (card_secure_method['code'] == setting['card']['secure_method']) %}
<option value="{{ card_secure_method['code'] }}" selected="selected">{{ attribute(_context, card_secure_method['name']) }}</option>
{% else %}
<option value="{{ card_secure_method['code'] }}">{{ attribute(_context, card_secure_method['name']) }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<hr class="hr" />
<button type="button" href="#all_settings" class="btn btn-default button-all-settings collapsed" data-toggle="collapse" role="button">{{ button_all_settings }}<i class="icon icon-all-settings"></i></button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<li class="nav-tab"><a href="{{ href_googlepay_button }}" class="tab"><i class="tab-icon tab-icon-googlepay-button"></i><span class="tab-title">{{ text_tab_googlepay_button }}</span></a></li>
<li class="nav-tab"><a href="{{ href_applepay_button }}" class="tab"><i class="tab-icon tab-icon-applepay-button"></i><span class="tab-title">{{ text_tab_applepay_button }}</span></a></li>
<li class="nav-tab"><a href="{{ href_card }}" class="tab"><i class="tab-icon tab-icon-card"></i><span class="tab-title">{{ text_tab_card }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message }}" class="tab"><i class="tab-icon tab-icon-message"></i><span class="tab-title">{{ text_tab_message }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_configurator }}" class="tab"><i class="tab-icon tab-icon-message-configurator"></i><span class="tab-title">{{ text_tab_message_configurator }}</span></a></li>
<li class="nav-tab"><a href="{{ href_message_setting }}" class="tab"><i class="tab-icon tab-icon-message-setting"></i><span class="tab-title">{{ text_tab_message_setting }}</span></a></li>
<li class="nav-tab"><a href="{{ href_order_status }}" class="tab"><i class="tab-icon tab-icon-order-status"></i><span class="tab-title">{{ text_tab_order_status }}</span></a></li>
<li class="nav-tab active"><a href="{{ href_contact }}" class="tab"><i class="tab-icon tab-icon-contact"></i><span class="tab-title">{{ text_tab_contact }}</span></a></li>
</ul>
Expand Down
Loading

0 comments on commit e922645

Please sign in to comment.