Skip to content

Commit

Permalink
Merge branch 'feat/paypal-standard-to-donations-migration-notice' int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
angelablake committed Aug 28, 2023
2 parents 78b7794 + bdde4ce commit c703d4d
Show file tree
Hide file tree
Showing 12 changed files with 412 additions and 14 deletions.
1 change: 1 addition & 0 deletions assets/src/css/admin/give-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
@import 'tabs';
@import 'upsells';
@import 'sale-banners';
@import 'paypal-donations-migration-banners';
@import '_components.admin-header';

@import '../../../../src/DonorDashboards/resources/styles/upgradenotice.scss';
74 changes: 74 additions & 0 deletions assets/src/css/admin/paypal-donations-migration-banners.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* PayPal Donations Migration Banners
* --------------------------------------------------
*/

// Banners.
.give-paypal-migration-banner{
padding: 8px 14px;
border-style: solid;
border-width: 1px;

// Common styles.
.message{
font-size: 15px;

.label{
border-radius: 4px;
font-weight: 600;
}

a{
text-decoration: underline;
font-weight: 600;
}

.icon, .label{
margin-right: 10px;
}
}

// Banner for gateways setting page.
&.gateway-settiing-page{
background-color: #F29718;
border-color: #E48100;

.message{
color: white;

a{
color: white;
}

.label{
text-transform: uppercase;
color: #F29718;
background-color: white;
padding: 3px 7px;
}
}
}

// Banner for PayPal Donations setting page.
&.paypal-donations-setting-page{
background-color: #FFF0A6;
color: #594B05;
border-color: #ffea82;

.icon{
vertical-align: middle;
background: url(../images/admin/alert-triangle.svg) no-repeat center center;
padding-right: 16px;
}

a{
color: #594B05;
}
}
}

.give-paypal-standard-to-donations-migration-banner{
p, strong{
font-size: 15px
}
}
3 changes: 3 additions & 0 deletions assets/src/images/admin/alert-triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions assets/src/js/plugins/give-api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,15 @@ const Give = {
/**
* Get global param
*
* @unreleased Return default value of global param if param not found.
* @since 2.2.4
*
* @return {object} WordPress localized global param.
*/
getGlobal: function() {
return ( 'undefined' === typeof give_global_vars ) ? give_vars : give_global_vars;
getGlobal: function () {
return ('undefined' === typeof give_global_vars)
? (window.give_vars || {})
: (window.give_global_vars || {});
},

/**
Expand Down
5 changes: 4 additions & 1 deletion assets/src/js/plugins/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ class GiveModal {
*/
static __closePopup( event ) {
event.preventDefault();
jQuery.magnificPopup.instance.close();

if( ! event.target.classList.contains( 'js-has-event-handler' )){
jQuery.magnificPopup.instance.close();
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/DonationForms/V2/DonationFormsAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function highlightAllFormsMenuItem()

/**
* Load scripts
*
* @unreleased Set admin script and style dependencies to display PayPal Standard to Donations Migration banner.
*/
public function loadScripts()
{
Expand All @@ -87,14 +89,15 @@ public function loadScripts()
];

EnqueueScript::make('give-admin-donation-forms', 'assets/dist/js/give-admin-donation-forms.js')
->dependencies(['give-admin-scripts'])
->loadInFooter()
->registerTranslations()
->registerLocalizeData('GiveDonationForms', $data)->enqueue();

wp_enqueue_style(
'give-admin-ui-font',
'https://fonts.googleapis.com/css2?family=Open+Sans:[email protected]&display=swap',
[],
['give-admin-styles'],
null
);
}
Expand Down
51 changes: 42 additions & 9 deletions src/PaymentGateways/PayPalCommerce/AdminSettingFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Give\PaymentGateways\PayPalCommerce;

use Give\PaymentGateways\PayPalCommerce\Banners\PayPalDonationsSettingPageBanner;
use Give\PaymentGateways\PayPalCommerce\Models\MerchantDetail;
use Give\PaymentGateways\PayPalCommerce\Repositories\MerchantDetails;
use Give\PaymentGateways\PayPalCommerce\Repositories\Settings;
Expand Down Expand Up @@ -132,7 +133,10 @@ public function payPalCommerceAccountManagerField()
'give'
);
$paypalSandboxSetting->isRecurringAddonActive = $isRecurringAddonActive;

echo $this->getPayPalConnectionSettingView($paypalSandboxSetting);

echo $this->getBanner();
}

/**
Expand All @@ -148,17 +152,20 @@ public function introductionSection()
<div>
<h2><?php
esc_html_e('Accept Donations with PayPal Donations', 'give'); ?></h2>
<p class="give-field-description"><?php
<p class="give-field-description">
<?php
esc_html_e(
'Allow your donors to give using Debit or Credit Cards directly on your website with no additional fees.',
'give'
); ?></p>
);
?>
</p>
</div>
<div class="paypal-logo">
<img src="<?php
echo GIVE_PLUGIN_URL . '/assets/dist/images/admin/paypal-logo.svg'; ?>" width="316" height="84"
alt="<?php
esc_attr_e('PayPal Logo Image', 'give'); ?>">
<img src="<?php echo GIVE_PLUGIN_URL . '/assets/dist/images/admin/paypal-logo.svg'; ?>"
width="316"
height="84"
alt="<?php esc_attr_e('PayPal Logo Image', 'give'); ?>">
</div>
</div>
<div class="feature-list">
Expand Down Expand Up @@ -263,7 +270,7 @@ public function getAdminGuidanceNotice($completeMessage = true)
*
* @since 2.9.6
*/
private function printErrors( MerchantDetails $merchantDetailsRepository )
private function printErrors(MerchantDetails $merchantDetailsRepository)
{
$accountErrors = $merchantDetailsRepository->getAccountErrors();

Expand All @@ -272,7 +279,8 @@ private function printErrors( MerchantDetails $merchantDetailsRepository )
<div>
<p class="error-message"><?php esc_html_e('Warning, your account is not ready to accept donations.', 'give'); ?></p>
<p>
<?php printf(
<?php
printf(
'%1$s %2$s',
esc_html__(
'There is an issue with your PayPal account that is preventing you from being able to accept donations.',
Expand Down Expand Up @@ -414,7 +422,7 @@ class="button-wrap connection-setting<?php echo $canShowAccountInformation ? ' g
<i class="fab fa-paypal"></i>&nbsp;&nbsp;
<?php echo $paypalSetting->connectButtonLabel; ?>
</button>
<?php if ('live' === $paypalSetting->mode): ?>
<?php if ('live' === $paypalSetting->mode) : ?>
<span class="tooltip">
<span class="left-arrow"></span>
<?php esc_html_e('Click to get started!', 'give'); ?>
Expand Down Expand Up @@ -477,4 +485,29 @@ class="js-give-paypal-disconnect-paypal-account"
<?php
return ob_get_clean();
}

/**
* @unreleased
*/
private function getBanner(): string
{
ob_start();

if (
give(MerchantDetail::class)->accountIsReady
&& give_is_gateway_active(PayPalCommerce::id())
) {
return '';
}
?>
<tr>
<th scope="row" class="titledesc">
</th>
<td class="give-forminp">
<?php echo give(PayPalDonationsSettingPageBanner::class)->render(); ?>
</td>
</tr>
<?php
return ob_get_clean();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Give\PaymentGateways\PayPalCommerce\Banners;

/**
* Class GatewaySettingPageBanner
*
* This class is used to render banner on gateway settings page.
*
* @unreleased
*/
class GatewaySettingPageBanner
{
/**
* Setup hook.
* @unreleased
* @return void
*/
public function setupHook()
{
// Set highest priority to render banner at the end.
add_action('give-settings_settings_gateways_page', [$this, 'render'], 999);
}

/**
* Render banner.
* @unreleased
* @return void
*/
public function render()
{
// Bailout if:
// - not on the gateway settings page, or
// - PayPal Standard is not active.
if (
'gateways-settings' !== give_get_current_setting_section() ||
! give_is_gateway_active('paypal')
) {
return;
}

printf(
'<div class="give-paypal-migration-banner gateway-settiing-page">
<p class="message">
<span class="label">%1$s</span>%2$s <a href="https://docs.givewp.com/paypal-migrate" target="_blank">%3$s</a>
<p>
</div>',
esc_html__('Important', 'give'),
esc_html__(
'PayPal Standard is no longer supported by PayPal. It is recommended to migrate to PayPal Donations.',
'give'
),
esc_html__('How to migrate safely', 'give')
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Give\PaymentGateways\PayPalCommerce\Banners;

/**
* Class GatewaySettingPageBanner
*
* @unreleased
*/
class PayPalDonationsSettingPageBanner
{
/**
* @unreleased
*/
public function render(): string
{
return sprintf(
'<div class="give-paypal-migration-banner paypal-donations-setting-page">
<p class="message">
<span class="icon"></span>%1$s <a href="%2$s">%3$s</a>
<p>
</div>',
esc_html__(
'Make sure you enable PayPal Donation in the gateway settings to receive payment on your form.',
'give'
),
esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways')),
esc_html__('Go to gateway settings', 'give')
);
}
}
Loading

0 comments on commit c703d4d

Please sign in to comment.