PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.19.8
GiveWP – Donation Plugin and Fundraising Platform v2.19.8
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 4 years ago CreditCardSettingField.php 4 years ago CustomizeAccountField.php 4 years ago
AccountManagerSettingField.php
691 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 $this- >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 = 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 = 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 echo esc_html($accountName); ?>
296 </span>
297 </div>
298
299 <?php
300 if ( ! empty($accountEmail)) : ?>
301 <div class="give-stripe-account-fieldset give-stripe-account-email">
302 <span class="give-stripe-label"><?php
303 esc_html_e('Account email:', 'give'); ?></span>
304 <div class="give-stripe-connect-data-field">
305 <?php
306 echo esc_html($accountEmail); ?>
307 </div>
308 </div>
309 <?php
310 endif; ?>
311
312 <?php
313 if ( ! empty($stripeAccountId)) : ?>
314 <div class="give-stripe-account-fieldset give-stripe-account-id">
315 <span class="give-stripe-label"><?php
316 esc_html_e('Account ID:', 'give'); ?></span>
317 <div class="give-stripe-connect-data-field">
318 <?php
319 echo esc_html($stripeAccountId); ?>
320 </div>
321 </div>
322 <?php
323 endif; ?>
324
325 <div class="give-stripe-account-fieldset give-stripe-connection-method">
326 <span class="give-stripe-label">
327 <?php esc_html_e('Connection Method:', 'give'); ?>
328 </span>
329 <div class="give-stripe-connect-data-field">
330 <?php
331 echo give_stripe_connection_type_name($stripeAccount['type']); ?>
332 </div>
333 </div>
334
335 <div class="give-stripe-account-fieldset give-stripe-statement-descriptor">
336 <span class="give-stripe-label">
337 <?php esc_html_e('Statement Descriptor:', 'give'); ?>
338 <?php
339 echo sprintf(
340 '<a href="%s" target="_blank">%s</a>',
341 'https://stripe.com/docs/statement-descriptors#requirements',
342 Give()->tooltips->render_help([
343 'label' => esc_html__(
344 '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.',
345 'give'
346 ),
347 'size' => 'medium'
348 ]
349 )
350 );
351 ?>
352 </span>
353 <div
354 class="give-stripe-connect-data-field"
355 data-action-url="<?php echo $editStatementDescriptorUrl; ?>"
356 >
357 <?php echo $stripeAccount['statement_descriptor']; ?>
358 <?php if ($this->isGlobalSettingPage()): ?>
359 <span class="give-stripe-edit-statement-descriptor">
360 <a class="give-stripe-edit-statement-descriptor-btn" href="#">
361 <span class="dashicons dashicons-edit-page"></span>
362 <?php esc_html_e('Edit', 'give'); ?>
363 </a>
364 </span>
365 <?php endif; ?>
366 </div>
367 </div>
368
369 <?php
370 /**
371 * Filter fire.
372 *
373 * Developer can utilize this hook to add custom action to stripe account
374 *
375 * @since 2.13.3
376 */
377 $stripeAccountActionsHtml = apply_filters(
378 'give_stripe_manage_account_actions_html',
379 '',
380 $stripeAccount,
381 $this->stripeAccounts,
382 $this->defaultStripeAccountSlug
383 );
384
385 if ($stripeAccountActionsHtml) {
386 printf(
387 '<div class="give-stripe-account-fieldset give-stripe-account-edit">%s</div>',
388 $stripeAccountActionsHtml
389 );
390 }
391 ?>
392
393 <div class="give-stripe-account-fieldset">
394 <span class="give-stripe-label"><?php
395 esc_html_e('Connection Status:', 'give'); ?></span>
396 <div class="give-stripe-account-actions">
397 <span class="give-stripe-account-connected give-stripe-connect-data-field">
398 <?php
399 esc_html_e('Connected', 'give'); ?>
400 </span>
401 <?php
402 if (
403 $stripeAccountSlug !== $this->defaultStripeAccountSlug ||
404 1 === count($this->stripeAccounts)
405 ) :?>
406 <span class="give-stripe-account-disconnect">
407 <a class="give-stripe-disconnect-account-btn" href="<?php echo $disconnectUrl; ?>">
408 <span class="dashicons dashicons-editor-unlink"></span>
409 <?php esc_html_e('Disconnect', 'give'); ?>
410 </a>
411 </span>
412 <?php endif; ?>
413 </div>
414 </div>
415
416 <?php
417 if ($stripeAccountSlug === $this->defaultStripeAccountSlug) : ?>
418 <div class="give-stripe-account-badge">
419 <?php
420 esc_html_e('Default Account', 'give'); ?>
421 </div>
422 <?php
423 else : ?>
424 <div class="give-stripe-account-default">
425 <a
426 data-account="<?php
427 echo $stripeAccountSlug; ?>"
428 class="give-stripe-account-set-default"
429 href="#"
430 ><?php
431 esc_html_e('Set as Default', 'give'); ?></a>
432 </div>
433 <?php
434 endif; ?>
435 </div>
436 <?php
437 }
438
439 /**
440 * @since 2.13.0
441 */
442 private function getStripeAccountOnBoardingModalMarkup()
443 {
444 global $post;
445
446 $site_url = get_site_url();
447 $redirectUrl = $this->isGlobalSettingPage() ?
448 admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=stripe-settings') :
449 admin_url("post.php?post=$post->ID&action=edit&give_tab=stripe_form_account_options");
450
451 $modal_title = sprintf(
452 '<strong>%1$s</strong>',
453 esc_html__(
454 'You are connected! Now this is important: Please configure your Stripe webhook to finalize the setup.',
455 'give'
456 )
457 );
458 $modal_first_detail = sprintf(
459 '%1$s %2$s',
460 esc_html__(
461 '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:',
462 'give'
463 ),
464 "<strong>{$site_url}?give-listener=stripe</strong>"
465 );
466 $modal_second_detail = esc_html__(
467 'Stripe webhooks are required so GiveWP can communicate properly with the payment gateway to confirm payment completion, renewals, and more.',
468 'give'
469 );
470 $can_display = ! empty($_GET['stripe_account']) ? '0' : '1';
471 ?>
472 <div
473 id="give-stripe-connected"
474 class="stripe-btn-disabled give-hidden"
475 data-status="connected"
476 data-title="<?php
477 echo $modal_title; ?>"
478 data-first-detail="<?php
479 echo $modal_first_detail; ?>"
480 data-second-detail="<?php
481 echo $modal_second_detail; ?>"
482 data-display="<?php
483 echo $can_display; ?>"
484 data-redirect-url="<?php
485 echo esc_url_raw($redirectUrl); ?>"
486 >
487 </div>
488 <?php
489 }
490
491 /**
492 * @since 2.13.0
493 */
494 private function getCompatibilityNoticeMarkup()
495 {
496 ?>
497 <div class="give-stripe-account-manager-add-section">
498 <?php
499 Give()->notices->print_admin_notices(
500 [
501 'description' => sprintf(
502 '%1$s <a href="%2$s">%3$s</a> %4$s',
503 esc_html__(
504 '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. ',
505 'give'
506 ),
507 esc_url(admin_url('edit.php?post_type=give_forms&page=give-updates')),
508 esc_html__('Click here', 'give'),
509 esc_html__('to complete your pending database updates.', 'give')
510 ),
511 'dismissible' => false,
512 ]
513 );
514 ?>
515 </div>
516 <?php
517 }
518
519 /**
520 * @since 2.13.0
521 */
522 private function getFreeStripeVersionNoticeMarkup()
523 {
524 ?>
525 <p class="give-stripe-subheading-description">
526 <?php
527 printf(
528 __(
529 '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>',
530 'give'
531 ),
532 esc_url('http://docs.givewp.com/settings-stripe-addon'),
533 esc_url('http://docs.givewp.com/settings-stripe-recurring'),
534 esc_url('http://docs.givewp.com/settings-stripe-free')
535 );
536 ?>
537 </p>
538 <?php
539 }
540
541 /**
542 * @since 2.13.0
543 */
544 public function getNoStripeAccountMarkup()
545 {
546 ?>
547 <div class="no-stripe-account-connected">
548 <div class="no-stripe-account-connected-inner">
549 <span class="dashicons dashicons-info"></span>
550 <h3 class="give-stripe-settings-heading">
551 <?php
552 echo $this->isGlobalSettingPage() ?
553 esc_html__('No Stripe Accounts Connected', 'give') :
554 esc_html__('Connect a New Stripe Account', 'give');
555 ?>
556 </h3>
557 <p id="give-stripe-connect-invite">
558 <?php
559 echo $this->isGlobalSettingPage() ?
560 esc_html__('Connect an account to get started!', 'give') :
561 esc_html__(
562 'Add a new account to customize the Stripe account used for this donation form.',
563 'give'
564 )
565 ?>
566 </p>
567 <?php
568 echo $this->getStripeConnectButtonMarkup(); ?>
569 </div>
570 </div>
571 <?php
572 }
573
574 /**
575 * @since 2.13.0
576 * @return string
577 */
578 public function getStripeConnectButtonMarkup()
579 {
580 // Prepare Stripe Connect URL.
581 $link = add_query_arg(
582 [
583 'stripe_action' => 'connect',
584 'mode' => give_is_test_mode() ? 'test' : 'live',
585 'return_url' => ! $this->isGlobalSettingPage() ?
586 rawurlencode(
587 sprintf(
588 admin_url('post.php?post=%d&action=edit&give_tab=stripe_form_account_options'),
589 get_the_ID()
590 )
591 ) :
592 rawurlencode(
593 admin_url(
594 'edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=stripe-settings'
595 )
596 ),
597 'website_url' => get_bloginfo('url'),
598 'give_stripe_connected' => '0',
599 ],
600 esc_url_raw('https://connect.givewp.com/stripe/connect.php')
601 );
602
603 $stripeSvgIcon = '<svg width="15" height="21" viewBox="0 0 15 21" fill="none" xmlns="http://www.w3.org/2000/svg">
604 <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"/>
605 </svg>
606 ';
607
608 return sprintf(
609 '<a href="%1$s" class="give-stripe-connect" title="%2$s"><span class="stripe-logo">%3$s</span><span>%2$s</span></a>',
610 esc_url($link),
611 esc_html__('Connect with Stripe', 'give'),
612 $stripeSvgIcon
613 );
614 }
615
616 /**
617 * @since 2.13.0
618 */
619 private function getDefaultStripeAccountNotice()
620 {
621 ?>
622 <div class="give-stripe-default-account-notice">
623 <span class="dashicons dashicons-info"></span>
624 <div class="give-stripe-default-account-notice__inner">
625 <p class="give-stripe-default-account-notice__bold"><strong>
626 <?php
627 echo $this->isGlobalSettingPage() ?
628 esc_html__('All payments go to the default account', 'give') :
629 esc_html__('Stripe donations process through the account set above', 'give');
630 ?>
631 </strong></p>
632 <p>
633 <?php
634 echo $this->isGlobalSettingPage() ?
635 esc_html__(
636 'You can set this globally (for all donation forms) or override the Stripe account per donation form.',
637 'give'
638 ) :
639 esc_html__('This overrides the global default account setting for this donation form.', 'give');
640 ?>
641 </p>
642 </div>
643 </div>
644 <?php
645 }
646
647 /**
648 * @since 2.13.0
649 * @return bool
650 */
651 private function canShowFreeStripeVersionNotice()
652 {
653 return ! give_stripe_is_premium_active();
654 }
655
656 /**
657 * @return bool
658 */
659 private function canShowCompatibilityNotice()
660 {
661 return ! give_has_upgrade_completed('v270_store_stripe_account_for_donation');
662 }
663
664 /**
665 * @since 2.13.0
666 * @return bool
667 */
668 private function isGlobalSettingPage()
669 {
670 return Give_Admin_Settings::is_setting_page('gateways', 'stripe-settings');
671 }
672
673 /**
674 * @since 2.13.0
675 *
676 * @param string $accountSlug Stripe account slug
677 *
678 * @return bool
679 */
680 private function isGlobalDefaultStripeAccount($accountSlug)
681 {
682 $globalDefaultStripeAccountDetail = give_stripe_get_default_account();
683
684 if (empty($globalDefaultStripeAccountDetail)) {
685 return false;
686 }
687
688 return ! $this->isGlobalSettingPage() && $globalDefaultStripeAccountDetail['account_slug'] === $accountSlug;
689 }
690 }
691