PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.24.2
GiveWP – Donation Plugin and Fundraising Platform v2.24.2
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / src / PaymentGateways / Stripe / Admin / AccountManagerSettingField.php
give / src / PaymentGateways / Stripe / Admin Last commit date
AccountManagerSettingField.php 3 years ago CreditCardSettingField.php 4 years ago CustomizeAccountField.php 4 years ago
AccountManagerSettingField.php
702 lines
1 <?php
2
3 namespace Give\PaymentGateways\Stripe\Admin;
4
5 use Give\PaymentGateways\Stripe\Repositories\AccountDetail;
6 use Give\PaymentGateways\Stripe\Repositories\Settings;
7 use Give_Admin_Settings;
8
9 use function add_query_arg;
10 use function do_action;
11 use function esc_attr;
12 use function esc_html;
13 use function esc_html__;
14 use function esc_html_e;
15 use function esc_url_raw;
16 use function get_site_url;
17 use function give;
18 use function give_has_upgrade_completed;
19 use function give_stripe_connection_type_name;
20 use function give_stripe_is_premium_active;
21
22 /**
23 * Class AccountManagerSettingField
24 *
25 * @package Give\PaymentGateways\Stripe\Admin
26 * @since 2.13.0
27 */
28 class AccountManagerSettingField
29 {
30
31 /**
32 * @var AccountDetail
33 */
34 private $accountDetailRepository;
35
36 /**
37 * @var array
38 */
39 private $stripeAccounts;
40
41 /**
42 * @var string
43 */
44 private $defaultStripeAccountSlug;
45 /**
46 * @var Settings
47 */
48 private $settings;
49
50 /**
51 * AccountManagerSettingField constructor.
52 *
53 * @since 2.13.0
54 *
55 * @param AccountDetail $accountDetailRepository
56 * @param Settings $settings
57 */
58 public function __construct(AccountDetail $accountDetailRepository, Settings $settings)
59 {
60 $this->accountDetailRepository = $accountDetailRepository;
61 $this->settings = $settings;
62 }
63
64 /**
65 * @since 2.13.0
66 */
67 private function setUpProperties()
68 {
69 global $post;
70 $this->stripeAccounts = $this->settings->getAllStripeAccounts();
71 $this->defaultStripeAccountSlug = $this->isGlobalSettingPage() ?
72 $this->settings->getDefaultStripeAccountSlug() :
73 $this->settings->getDefaultStripeAccountSlugForDonationForm($post->ID);
74 }
75
76 /**
77 * Render Stripe account manager setting field.
78 *
79 * @since 2.13.0
80 *
81 * @param array $field
82 */
83 public function handle($field)
84 {
85 $this->setUpProperties();
86 $classes = ! empty($field['wrapper_class']) ? esc_attr($field['wrapper_class']) : ''
87 ?>
88 <div class="<?php
89 echo $classes; ?>">
90
91 <div id="give-stripe-account-manager-errors"></div>
92 <?php
93 $this->getIntroductionSectionMarkup(); ?>
94 <div class="give-stripe-account-manager-container">
95 <div class="main-heading">
96 <h2 class="give-stripe-setting-heading"><?php
97 esc_html_e('Connected Accounts', 'give'); ?></h2>
98 </div>
99 <?php
100 $this->getStripeAccountListSectionMarkup();
101 $this->getAddNewStripeAccountSectionMarkup();
102 ?>
103 </div>
104 <?php
105 $this->getDefaultStripeAccountNotice(); ?>
106 </div>
107 <?php
108 }
109
110 /**
111 * @since 2.13.0
112 */
113 private function getIntroductionSectionMarkup()
114 {
115 // Show introduction content only on global setting edit screen.
116 if ( ! $this->isGlobalSettingPage()) {
117 return;
118 }
119 ?>
120 <div id="give-stripe-account-manager-description">
121 <h2><?php
122 esc_html_e('Accept Donations with Stripe', 'give'); ?></h2>
123
124 <?php
125 if (give_stripe_is_premium_active()) : ?>
126 <div class="give-stripe-pro-badge">
127 <div class="give-tooltip" data-tooltip="
128 <?php
129 esc_html_e(
130 'You are using the Pro version of the GiveWP add-on which includes additional payment methods, zero additional fees, and premium support.',
131 'give'
132 );
133 ?>
134 ">
135 <span class="dashicons dashicons-yes"></span>
136 <?php
137 esc_html_e('Pro Version Active', 'give'); ?>
138 </div>
139 </div>
140 <?php
141 endif; ?>
142
143 <p class="give-stripe-subheading-description">
144 <?php
145 esc_html_e(
146 'Connect to the Stripe payment gateway using this section. Multiple Stripe accounts can be connected simultaneously. All donation forms will use the "Default Account" unless configured otherwise. To specify a different Stripe account for a form, configure the settings within the "Stripe Account" tab on the individual form edit screen.',
147 'give'
148 );
149 ?>
150 </p>
151 <?php
152 if ($this->canShowFreeStripeVersionNotice()) {
153 $this->getFreeStripeVersionNoticeMarkup();
154 }
155 ?>
156 <hr style="margin: 25px 0; display: block" />
157 </div>
158 <?php
159 }
160
161 /**
162 * @since 2.13.0
163 */
164 private function getStripeAccountListSectionMarkup()
165 {
166 $this->getStripeAccountOnBoardingModalMarkup();
167 if ( ! $this->stripeAccounts || ( ! $this->isGlobalSettingPage() && 1 === count($this->stripeAccounts))) :
168 $this->getNoStripeAccountMarkup();
169
170 return;
171 endif;
172 ?>
173
174 <div class="give-stripe-account-manager-list">
175 <?php
176 foreach ($this->stripeAccounts as $stripeAccountDetails) {
177 $this->getStripeAccountMarkup($stripeAccountDetails);
178 }
179 ?>
180 </div>
181 <?php
182 }
183
184 /**
185 * @since 2.13.0
186 */
187 private function getAddNewStripeAccountSectionMarkup()
188 {
189 if ($this->canShowCompatibilityNotice()) {
190 $this->getCompatibilityNoticeMarkup();
191
192 return;
193 }
194 ?>
195 <div class="give-stripe-account-manager-add-section<?php
196 echo give_stripe_is_premium_active() ? ' give-settings-premium-active' : ''; ?>">
197
198 <div class="stripe-logo-with-circle">
199 <svg width="21" height="31" viewBox="0 0 21 31" fill="none" xmlns="http://www.w3.org/2000/svg">
200 <path fill-rule="evenodd" clip-rule="evenodd"
201 d="M8.41683 9.55871C8.41683 8.29941 9.4501 7.81507 11.1614 7.81507C13.6155 7.81507 16.7153 8.55773 19.1693 9.8816V2.29355C16.4892 1.22799 13.8415 0.808228 11.1614 0.808228C4.60666 0.808228 0.247559 4.23093 0.247559 9.94618C0.247559 18.8581 12.5176 17.4374 12.5176 21.2798C12.5176 22.7652 11.226 23.2495 9.4178 23.2495C6.73777 23.2495 3.31507 22.1517 0.602744 20.6663V28.3513C3.60568 29.6428 6.6409 30.1918 9.4178 30.1918C16.134 30.1918 20.7515 26.8659 20.7515 21.0861C20.7192 11.4638 8.41683 13.1751 8.41683 9.55871Z"
202 fill="#6772E5" />
203 </svg>
204 </div>
205 <h3 class="give-stripe-heading"><?php
206 esc_html_e('Add a New Stripe Account', 'give'); ?></h3>
207
208 <div class="give-setting-tab-body-gateways">
209
210 <?php
211
212 // Output Stripe Connect Button.
213 echo $this->getStripeConnectButtonMarkup();
214
215 // Check if premium is active.
216 if (give_stripe_is_premium_active()) {
217 /**
218 * This action hook will be used to load Manual API fields for premium addon.
219 *
220 * @since 2.7.0
221 *
222 * @param array $stripeAccounts All Stripe accounts.
223 *
224 */
225 do_action('give_stripe_premium_manual_api_fields', $this->stripeAccounts);
226 }
227 ?>
228 </div>
229 </div>
230 <?php
231 }
232
233 /**
234 * @since 2.13.0
235 *
236 * @param array $stripeAccount
237 */
238 private function getStripeAccountMarkup($stripeAccount)
239 {
240 $accountName = $stripeAccount['account_name'];
241 $accountEmail = $stripeAccount['account_email'];
242 $stripeAccountId = $stripeAccount['account_id'];
243 $stripeAccountSlug = $stripeAccount['account_slug'];
244
245 // Do not print global default Stripe account in donation form setting.
246 if ($this->isGlobalDefaultStripeAccount($stripeAccountSlug)) {
247 return;
248 }
249
250 $disconnectUrl = esc_url_raw(add_query_arg(
251 [
252 'account_type' => $stripeAccount['type'],
253 'action' => 'disconnect_stripe_account',
254 'account_slug' => $stripeAccountSlug,
255 ],
256 wp_nonce_url(admin_url('admin-ajax.php'), 'give_disconnect_connected_stripe_account_' . $stripeAccountSlug)
257 ));
258
259 $editStatementDescriptorUrl = esc_url_raw(add_query_arg(
260 [
261 'action' => 'edit_stripe_account_statement_descriptor',
262 'account-slug' => $stripeAccountSlug,
263 ],
264 admin_url('admin-ajax.php')
265 ));
266
267 $classes = $stripeAccountSlug === $this->defaultStripeAccountSlug ? ' give-stripe-boxshadow-option-wrap__selected' : '';
268 ?>
269 <div
270 id="give-stripe-<?php
271 echo $stripeAccountSlug; ?>"
272 class="give-stripe-account-manager-list-item give-stripe-boxshadow-option-wrap<?php
273 echo $classes; ?>"
274 >
275 <input type="hidden" name="stripe-account-slug" value="<?php
276 echo $stripeAccountSlug; ?>" readonly>
277 <input type="hidden" name="setting-page" value="<?php
278 echo $this->isGlobalSettingPage() ? 'global' : 'form'; ?>" readonly>
279 <?php
280 if ($stripeAccountSlug === $this->defaultStripeAccountSlug) : ?>
281 <div class="give-stripe-account-default-checkmark">
282 <svg width="33" height="33" viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg">
283 <path
284 d="M32.375 16.1875C32.375 25.1276 25.1276 32.375 16.1875 32.375C7.24737 32.375 0 25.1276 0 16.1875C0 7.24737 7.24737 0 16.1875 0C25.1276 0 32.375 7.24737 32.375 16.1875ZM14.3151 24.7586L26.3252 12.7486C26.733 12.3407 26.733 11.6795 26.3252 11.2717L24.8483 9.79474C24.4404 9.38686 23.7792 9.38686 23.3713 9.79474L13.5766 19.5894L9.00371 15.0165C8.59589 14.6086 7.93462 14.6086 7.52673 15.0165L6.04982 16.4934C5.642 16.9012 5.642 17.5625 6.04982 17.9703L12.8381 24.7586C13.246 25.1665 13.9072 25.1665 14.3151 24.7586Z"
285 fill="#69B868" />
286 </svg>
287 </div>
288 <?php
289 endif; ?>
290
291 <div class="give-stripe-account-fieldset give-stripe-account-name">
292 <span class="give-stripe-label"><?php
293 esc_html_e('Account name:', 'give'); ?></span>
294 <span class="give-stripe-connect-data-field">
295 <?php
296 echo esc_html($accountName); ?>
297 </span>
298 </div>
299
300 <?php
301 if ( ! empty($accountEmail)) : ?>
302 <div class="give-stripe-account-fieldset give-stripe-account-email">
303 <span class="give-stripe-label"><?php
304 esc_html_e('Account email:', 'give'); ?></span>
305 <div class="give-stripe-connect-data-field">
306 <?php
307 echo esc_html($accountEmail); ?>
308 </div>
309 </div>
310 <?php
311 endif; ?>
312
313 <?php
314 if ( ! empty($stripeAccountId)) : ?>
315 <div class="give-stripe-account-fieldset give-stripe-account-id">
316 <span class="give-stripe-label"><?php
317 esc_html_e('Account ID:', 'give'); ?></span>
318 <div class="give-stripe-connect-data-field">
319 <?php
320 echo esc_html($stripeAccountId); ?>
321 </div>
322 </div>
323 <?php
324 endif; ?>
325
326 <div class="give-stripe-account-fieldset give-stripe-connection-method">
327 <span class="give-stripe-label">
328 <?php
329 esc_html_e('Connection Method:', 'give'); ?>
330 </span>
331 <div class="give-stripe-connect-data-field">
332 <?php
333 echo give_stripe_connection_type_name($stripeAccount['type']); ?>
334 </div>
335 </div>
336
337 <div class="give-stripe-account-fieldset give-stripe-statement-descriptor">
338 <span class="give-stripe-label">
339 <?php
340 esc_html_e('Statement Descriptor:', 'give'); ?>
341 <?php
342 echo sprintf(
343 '<a href="%s" target="_blank">%s</a>',
344 'https://stripe.com/docs/statement-descriptors#requirements',
345 Give()->tooltips->render_help([
346 'label' => esc_html__(
347 'This is the text that appears on your donor\'s bank statements. This is typically the name of your website or organization. Click on this icon to read more about Stripe statement text requirements.',
348 'give'
349 ),
350 'size' => 'medium',
351 ]
352 )
353 );
354 ?>
355 </span>
356 <div
357 class="give-stripe-connect-data-field"
358 data-action-url="<?php
359 echo $editStatementDescriptorUrl; ?>"
360 >
361 <?php
362 echo $stripeAccount['statement_descriptor']; ?>
363 <?php
364 if ($this->isGlobalSettingPage()): ?>
365 <span class="give-stripe-edit-statement-descriptor">
366 <a class="give-stripe-edit-statement-descriptor-btn" href="#">
367 <span class="dashicons dashicons-edit-page"></span>
368 <?php
369 esc_html_e('Edit', 'give'); ?>
370 </a>
371 </span>
372 <?php
373 endif; ?>
374 </div>
375 </div>
376
377 <?php
378 /**
379 * Filter fire.
380 *
381 * Developer can utilize this hook to add custom action to stripe account
382 *
383 * @since 2.13.3
384 */
385 $stripeAccountActionsHtml = apply_filters(
386 'give_stripe_manage_account_actions_html',
387 '',
388 $stripeAccount,
389 $this->stripeAccounts,
390 $this->defaultStripeAccountSlug
391 );
392
393 if ($stripeAccountActionsHtml) {
394 printf(
395 '<div class="give-stripe-account-fieldset give-stripe-account-edit">%s</div>',
396 $stripeAccountActionsHtml
397 );
398 }
399 ?>
400
401 <div class="give-stripe-account-fieldset">
402 <span class="give-stripe-label"><?php
403 esc_html_e('Connection Status:', 'give'); ?></span>
404 <div class="give-stripe-account-actions">
405 <span class="give-stripe-account-connected give-stripe-connect-data-field">
406 <?php
407 esc_html_e('Connected', 'give'); ?>
408 </span>
409 <?php
410 if (
411 $stripeAccountSlug !== $this->defaultStripeAccountSlug ||
412 1 === count($this->stripeAccounts)
413 ) :?>
414 <span class="give-stripe-account-disconnect">
415 <a class="give-stripe-disconnect-account-btn" href="<?php
416 echo $disconnectUrl; ?>">
417 <span class="dashicons dashicons-editor-unlink"></span>
418 <?php
419 esc_html_e('Disconnect', 'give'); ?>
420 </a>
421 </span>
422 <?php
423 endif; ?>
424 </div>
425 </div>
426
427 <?php
428 if ($stripeAccountSlug === $this->defaultStripeAccountSlug) : ?>
429 <div class="give-stripe-account-badge">
430 <?php
431 esc_html_e('Default Account', 'give'); ?>
432 </div>
433 <?php
434 else : ?>
435 <div class="give-stripe-account-default">
436 <a
437 data-account="<?php
438 echo $stripeAccountSlug; ?>"
439 class="give-stripe-account-set-default"
440 href="#"
441 ><?php
442 esc_html_e('Set as Default', 'give'); ?></a>
443 </div>
444 <?php
445 endif; ?>
446 </div>
447 <?php
448 }
449
450 /**
451 * @since 2.13.0
452 */
453 private function getStripeAccountOnBoardingModalMarkup()
454 {
455 global $post;
456
457 $site_url = get_site_url();
458 $redirectUrl = $this->isGlobalSettingPage() ?
459 admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=stripe-settings') :
460 admin_url("post.php?post=$post->ID&action=edit&give_tab=stripe_form_account_options");
461
462 $modal_title = sprintf(
463 '<strong>%1$s</strong>',
464 esc_html__(
465 'You are connected! Now this is important: Please configure your Stripe webhook to finalize the setup.',
466 'give'
467 )
468 );
469 $modal_first_detail = sprintf(
470 '%1$s %2$s',
471 esc_html__(
472 'In order for Stripe to function properly, you must add a new Stripe webhook endpoint. To do this please visit the <a href=\'https://dashboard.stripe.com/webhooks\' target=\'_blank\'>Webhooks Section of your Stripe Dashboard</a> and click the <strong>Add endpoint</strong> button and paste the following URL:',
473 'give'
474 ),
475 "<strong>{$site_url}?give-listener=stripe</strong>"
476 );
477 $modal_second_detail = esc_html__(
478 'Stripe webhooks are required so GiveWP can communicate properly with the payment gateway to confirm payment completion, renewals, and more.',
479 'give'
480 );
481 $can_display = ! empty($_GET['stripe_account']) ? '0' : '1';
482 ?>
483 <div
484 id="give-stripe-connected"
485 class="stripe-btn-disabled give-hidden"
486 data-status="connected"
487 data-title="<?php
488 echo $modal_title; ?>"
489 data-first-detail="<?php
490 echo $modal_first_detail; ?>"
491 data-second-detail="<?php
492 echo $modal_second_detail; ?>"
493 data-display="<?php
494 echo $can_display; ?>"
495 data-redirect-url="<?php
496 echo esc_url_raw($redirectUrl); ?>"
497 >
498 </div>
499 <?php
500 }
501
502 /**
503 * @since 2.13.0
504 */
505 private function getCompatibilityNoticeMarkup()
506 {
507 ?>
508 <div class="give-stripe-account-manager-add-section">
509 <?php
510 Give()->notices->print_admin_notices(
511 [
512 'description' => sprintf(
513 '%1$s <a href="%2$s">%3$s</a> %4$s',
514 esc_html__(
515 'Give 2.7.0 introduces the ability to connect a single site to multiple Stripe accounts. To use this feature, you need to complete database updates. ',
516 'give'
517 ),
518 esc_url(admin_url('edit.php?post_type=give_forms&page=give-updates')),
519 esc_html__('Click here', 'give'),
520 esc_html__('to complete your pending database updates.', 'give')
521 ),
522 'dismissible' => false,
523 ]
524 );
525 ?>
526 </div>
527 <?php
528 }
529
530 /**
531 * @since 2.13.0
532 */
533 private function getFreeStripeVersionNoticeMarkup()
534 {
535 ?>
536 <p class="give-stripe-subheading-description">
537 <?php
538 printf(
539 __(
540 'NOTE: You are using the free Stripe payment gateway integration. This includes an additional 2%% fee for processing one-time donations. This fee is removed by activating the premium <a href="%1$s" target="_blank">Stripe add-on</a> and never applies to subscription donations made through the <a href="%2$s" target="_blank">Recurring Donations add-on</a>. <a href="%3$s" target="_blank">Learn More ></a>',
541 'give'
542 ),
543 esc_url('http://docs.givewp.com/settings-stripe-addon'),
544 esc_url('http://docs.givewp.com/settings-stripe-recurring'),
545 esc_url('http://docs.givewp.com/settings-stripe-free')
546 );
547 ?>
548 </p>
549 <?php
550 }
551
552 /**
553 * @since 2.13.0
554 */
555 public function getNoStripeAccountMarkup()
556 {
557 ?>
558 <div class="no-stripe-account-connected">
559 <div class="no-stripe-account-connected-inner">
560 <span class="dashicons dashicons-info"></span>
561 <h3 class="give-stripe-settings-heading">
562 <?php
563 echo $this->isGlobalSettingPage() ?
564 esc_html__('No Stripe Accounts Connected', 'give') :
565 esc_html__('Connect a New Stripe Account', 'give');
566 ?>
567 </h3>
568 <p id="give-stripe-connect-invite">
569 <?php
570 echo $this->isGlobalSettingPage() ?
571 esc_html__('Connect an account to get started!', 'give') :
572 esc_html__(
573 'Add a new account to customize the Stripe account used for this donation form.',
574 'give'
575 )
576 ?>
577 </p>
578 <?php
579 echo $this->getStripeConnectButtonMarkup(); ?>
580 </div>
581 </div>
582 <?php
583 }
584
585 /**
586 * @since 2.13.0
587 * @return string
588 */
589 public function getStripeConnectButtonMarkup()
590 {
591 // Prepare Stripe Connect URL.
592 $link = add_query_arg(
593 [
594 'stripe_action' => 'connect',
595 'mode' => give_is_test_mode() ? 'test' : 'live',
596 'return_url' => ! $this->isGlobalSettingPage() ?
597 rawurlencode(
598 sprintf(
599 admin_url('post.php?post=%d&action=edit&give_tab=stripe_form_account_options'),
600 get_the_ID()
601 )
602 ) :
603 rawurlencode(
604 admin_url(
605 'edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=stripe-settings'
606 )
607 ),
608 'website_url' => get_bloginfo('url'),
609 'give_stripe_connected' => '0',
610 ],
611 esc_url_raw('https://connect.givewp.com/stripe/connect.php')
612 );
613
614 $stripeSvgIcon = '<svg width="15" height="21" viewBox="0 0 15 21" fill="none" xmlns="http://www.w3.org/2000/svg">
615 <path d="M6.05469 6.55469C6.05469 5.69531 6.75781 5.34375 7.92969 5.34375C9.64844 5.34375 11.7969 5.85156 13.4766 6.78906V1.55469C11.6406 0.8125 9.80469 0.5 7.92969 0.5C3.4375 0.5 0.429688 2.88281 0.429688 6.82812C0.429688 13 8.86719 11.9844 8.86719 14.6406C8.86719 15.6953 7.96875 16.0078 6.75781 16.0078C4.88281 16.0078 2.5 15.2656 0.664062 14.25V19.25C2.5 20.0703 4.57031 20.5 6.75781 20.5391C11.3672 20.5391 14.5703 18.5469 14.5703 14.5234C14.5703 7.88281 6.05469 9.05469 6.05469 6.55469Z" fill="white"/>
616 </svg>
617 ';
618
619 return sprintf(
620 '<a href="%1$s" class="give-stripe-connect" title="%2$s"><span class="stripe-logo">%3$s</span><span>%2$s</span></a>',
621 esc_url($link),
622 esc_html__('Connect with Stripe', 'give'),
623 $stripeSvgIcon
624 );
625 }
626
627 /**
628 * @since 2.13.0
629 */
630 private function getDefaultStripeAccountNotice()
631 {
632 ?>
633 <div class="give-stripe-default-account-notice">
634 <span class="dashicons dashicons-info"></span>
635 <div class="give-stripe-default-account-notice__inner">
636 <p class="give-stripe-default-account-notice__bold"><strong>
637 <?php
638 echo $this->isGlobalSettingPage() ?
639 esc_html__('All payments go to the default account', 'give') :
640 esc_html__('Stripe donations process through the account set above', 'give');
641 ?>
642 </strong></p>
643 <p>
644 <?php
645 echo $this->isGlobalSettingPage() ?
646 esc_html__(
647 'You can set this globally (for all donation forms) or override the Stripe account per donation form.',
648 'give'
649 ) :
650 esc_html__('This overrides the global default account setting for this donation form.', 'give');
651 ?>
652 </p>
653 </div>
654 </div>
655 <?php
656 }
657
658 /**
659 * @since 2.13.0
660 * @return bool
661 */
662 private function canShowFreeStripeVersionNotice()
663 {
664 return ! give_stripe_is_premium_active();
665 }
666
667 /**
668 * @return bool
669 */
670 private function canShowCompatibilityNotice()
671 {
672 return ! give_has_upgrade_completed('v270_store_stripe_account_for_donation');
673 }
674
675 /**
676 * @since 2.13.0
677 * @return bool
678 */
679 private function isGlobalSettingPage()
680 {
681 return Give_Admin_Settings::is_setting_page('gateways', 'stripe-settings');
682 }
683
684 /**
685 * @since 2.13.0
686 *
687 * @param string $accountSlug Stripe account slug
688 *
689 * @return bool
690 */
691 private function isGlobalDefaultStripeAccount($accountSlug)
692 {
693 $globalDefaultStripeAccountDetail = give_stripe_get_default_account();
694
695 if (empty($globalDefaultStripeAccountDetail)) {
696 return false;
697 }
698
699 return ! $this->isGlobalSettingPage() && $globalDefaultStripeAccountDetail['account_slug'] === $accountSlug;
700 }
701 }
702