PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.19.4
GiveWP – Donation Plugin and Fundraising Platform v3.19.4
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 3 years ago CustomizeAccountField.php 4 years ago
AccountManagerSettingField.php
716 lines
1 <?php
2
3 namespace Give\PaymentGateways\Stripe\Admin;
4
5 use Give\Framework\Http\ConnectServer\Client\ConnectClient;
6 use Give\PaymentGateways\Stripe\Repositories\AccountDetail;
7 use Give\PaymentGateways\Stripe\Repositories\Settings;
8 use Give_Admin_Settings;
9
10 use function add_query_arg;
11 use function do_action;
12 use function esc_attr;
13 use function esc_html;
14 use function esc_html__;
15 use function esc_html_e;
16 use function esc_url_raw;
17 use function get_site_url;
18 use function give;
19 use function give_has_upgrade_completed;
20 use function give_stripe_connection_type_name;
21 use function give_stripe_is_premium_active;
22
23 /**
24 * Class AccountManagerSettingField
25 *
26 * @package Give\PaymentGateways\Stripe\Admin
27 * @since 2.13.0
28 */
29 class AccountManagerSettingField
30 {
31
32 /**
33 * @var AccountDetail
34 */
35 private $accountDetailRepository;
36
37 /**
38 * @var array
39 */
40 private $stripeAccounts;
41
42 /**
43 * @var string
44 */
45 private $defaultStripeAccountSlug;
46 /**
47 * @var Settings
48 */
49 private $settings;
50
51 /**
52 * @since 2.25.0
53 *
54 * @var ConnectClient
55 */
56 private $connectClient;
57
58 /**
59 * AccountManagerSettingField constructor.
60 *
61 * @since 2.25.0 Use 'ConnectClient' class
62 * @since 2.13.0
63 *
64 * @param AccountDetail $accountDetailRepository
65 * @param Settings $settings
66 */
67 public function __construct(
68 AccountDetail $accountDetailRepository,
69 Settings $settings,
70 ConnectClient $connectClient
71 ) {
72 $this->accountDetailRepository = $accountDetailRepository;
73 $this->settings = $settings;
74 $this->connectClient = $connectClient;
75 }
76
77 /**
78 * @since 2.13.0
79 */
80 private function setUpProperties()
81 {
82 global $post;
83 $this->stripeAccounts = $this->settings->getAllStripeAccounts();
84 $this->defaultStripeAccountSlug = $this->isGlobalSettingPage() ?
85 $this->settings->getDefaultStripeAccountSlug() :
86 $this->settings->getDefaultStripeAccountSlugForDonationForm($post->ID);
87 }
88
89 /**
90 * Render Stripe account manager setting field.
91 *
92 * @since 2.13.0
93 *
94 * @param array $field
95 */
96 public function handle($field)
97 {
98 $this->setUpProperties();
99 $classes = ! empty($field['wrapper_class']) ? esc_attr($field['wrapper_class']) : ''
100 ?>
101 <div class="<?php
102 echo $classes; ?>">
103
104 <div id="give-stripe-account-manager-errors"></div>
105 <?php
106 $this->getIntroductionSectionMarkup(); ?>
107 <div class="give-stripe-account-manager-container">
108 <div class="main-heading">
109 <h2 class="give-stripe-setting-heading"><?php
110 esc_html_e('Connected Accounts', 'give'); ?></h2>
111 </div>
112 <?php
113 $this->getStripeAccountListSectionMarkup();
114 $this->getAddNewStripeAccountSectionMarkup();
115 ?>
116 </div>
117 <?php
118 $this->getDefaultStripeAccountNotice(); ?>
119 </div>
120 <?php
121 }
122
123 /**
124 * @since 2.13.0
125 */
126 private function getIntroductionSectionMarkup()
127 {
128 // Show introduction content only on global setting edit screen.
129 if ( ! $this->isGlobalSettingPage()) {
130 return;
131 }
132 ?>
133 <div id="give-stripe-account-manager-description">
134 <h2><?php
135 esc_html_e('Accept Donations with Stripe', 'give'); ?></h2>
136
137 <?php
138 if (give_stripe_is_premium_active()) : ?>
139 <div class="give-stripe-pro-badge">
140 <div class="give-tooltip" data-tooltip="
141 <?php
142 esc_html_e(
143 'You are using the Pro version of the GiveWP add-on which includes additional payment methods, zero additional fees, and premium support.',
144 'give'
145 );
146 ?>
147 ">
148 <span class="dashicons dashicons-yes"></span>
149 <?php
150 esc_html_e('Pro Version Active', 'give'); ?>
151 </div>
152 </div>
153 <?php
154 endif; ?>
155
156 <p class="give-stripe-subheading-description">
157 <?php
158 esc_html_e(
159 '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.',
160 'give'
161 );
162 ?>
163 </p>
164 <?php
165 if ($this->canShowFreeStripeVersionNotice()) {
166 $this->getFreeStripeVersionNoticeMarkup();
167 }
168 ?>
169 <hr style="margin: 25px 0; display: block" />
170 </div>
171 <?php
172 }
173
174 /**
175 * @since 2.13.0
176 */
177 private function getStripeAccountListSectionMarkup()
178 {
179 $this->getStripeAccountOnBoardingModalMarkup();
180 if ( ! $this->stripeAccounts || ( ! $this->isGlobalSettingPage() && 1 === count($this->stripeAccounts))) :
181 $this->getNoStripeAccountMarkup();
182
183 return;
184 endif;
185 ?>
186
187 <div class="give-stripe-account-manager-list">
188 <?php
189 foreach ($this->stripeAccounts as $stripeAccountDetails) {
190 $this->getStripeAccountMarkup($stripeAccountDetails);
191 }
192 ?>
193 </div>
194 <?php
195 }
196
197 /**
198 * @since 2.13.0
199 */
200 private function getAddNewStripeAccountSectionMarkup()
201 {
202 if ($this->canShowCompatibilityNotice()) {
203 $this->getCompatibilityNoticeMarkup();
204
205 return;
206 }
207 ?>
208 <div class="give-stripe-account-manager-add-section<?php
209 echo give_stripe_is_premium_active() ? ' give-settings-premium-active' : ''; ?>">
210
211 <div class="stripe-logo-with-circle">
212 <svg width="21" height="31" viewBox="0 0 21 31" fill="none" xmlns="http://www.w3.org/2000/svg">
213 <path fill-rule="evenodd" clip-rule="evenodd"
214 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"
215 fill="#6772E5" />
216 </svg>
217 </div>
218 <h3 class="give-stripe-heading"><?php
219 esc_html_e('Add a New Stripe Account', 'give'); ?></h3>
220
221 <div class="give-setting-tab-body-gateways">
222
223 <?php
224
225 // Output Stripe Connect Button.
226 echo $this->getStripeConnectButtonMarkup();
227
228 // Check if premium is active.
229 if (give_stripe_is_premium_active()) {
230 /**
231 * This action hook will be used to load Manual API fields for premium addon.
232 *
233 * @since 2.7.0
234 *
235 * @param array $stripeAccounts All Stripe accounts.
236 *
237 */
238 do_action('give_stripe_premium_manual_api_fields', $this->stripeAccounts);
239 }
240 ?>
241 </div>
242 </div>
243 <?php
244 }
245
246 /**
247 * @since 2.13.0
248 *
249 * @param array $stripeAccount
250 */
251 private function getStripeAccountMarkup($stripeAccount)
252 {
253 $accountName = $stripeAccount['account_name'];
254 $accountEmail = $stripeAccount['account_email'];
255 $stripeAccountId = $stripeAccount['account_id'];
256 $stripeAccountSlug = $stripeAccount['account_slug'];
257
258 // Do not print global default Stripe account in donation form setting.
259 if ($this->isGlobalDefaultStripeAccount($stripeAccountSlug)) {
260 return;
261 }
262
263 $disconnectUrl = esc_url_raw(add_query_arg(
264 [
265 'account_type' => $stripeAccount['type'],
266 'action' => 'disconnect_stripe_account',
267 'account_slug' => $stripeAccountSlug,
268 ],
269 wp_nonce_url(admin_url('admin-ajax.php'), 'give_disconnect_connected_stripe_account_' . $stripeAccountSlug)
270 ));
271
272 $editStatementDescriptorUrl = esc_url_raw(add_query_arg(
273 [
274 'action' => 'edit_stripe_account_statement_descriptor',
275 'account-slug' => $stripeAccountSlug,
276 ],
277 admin_url('admin-ajax.php')
278 ));
279
280 $classes = $stripeAccountSlug === $this->defaultStripeAccountSlug ? ' give-stripe-boxshadow-option-wrap__selected' : '';
281 ?>
282 <div
283 id="give-stripe-<?php
284 echo $stripeAccountSlug; ?>"
285 class="give-stripe-account-manager-list-item give-stripe-boxshadow-option-wrap<?php
286 echo $classes; ?>"
287 >
288 <input type="hidden" name="stripe-account-slug" value="<?php
289 echo $stripeAccountSlug; ?>" readonly>
290 <input type="hidden" name="setting-page" value="<?php
291 echo $this->isGlobalSettingPage() ? 'global' : 'form'; ?>" readonly>
292 <?php
293 if ($stripeAccountSlug === $this->defaultStripeAccountSlug) : ?>
294 <div class="give-stripe-account-default-checkmark">
295 <svg width="33" height="33" viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg">
296 <path
297 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"
298 fill="#69B868" />
299 </svg>
300 </div>
301 <?php
302 endif; ?>
303
304 <div class="give-stripe-account-fieldset give-stripe-account-name">
305 <span class="give-stripe-label"><?php
306 esc_html_e('Account name:', 'give'); ?></span>
307 <span class="give-stripe-connect-data-field">
308 <?php
309 echo esc_html($accountName); ?>
310 </span>
311 </div>
312
313 <?php
314 if ( ! empty($accountEmail)) : ?>
315 <div class="give-stripe-account-fieldset give-stripe-account-email">
316 <span class="give-stripe-label"><?php
317 esc_html_e('Account email:', 'give'); ?></span>
318 <div class="give-stripe-connect-data-field">
319 <?php
320 echo esc_html($accountEmail); ?>
321 </div>
322 </div>
323 <?php
324 endif; ?>
325
326 <?php
327 if ( ! empty($stripeAccountId)) : ?>
328 <div class="give-stripe-account-fieldset give-stripe-account-id">
329 <span class="give-stripe-label"><?php
330 esc_html_e('Account ID:', 'give'); ?></span>
331 <div class="give-stripe-connect-data-field">
332 <?php
333 echo esc_html($stripeAccountId); ?>
334 </div>
335 </div>
336 <?php
337 endif; ?>
338
339 <div class="give-stripe-account-fieldset give-stripe-connection-method">
340 <span class="give-stripe-label">
341 <?php
342 esc_html_e('Connection Method:', 'give'); ?>
343 </span>
344 <div class="give-stripe-connect-data-field">
345 <?php
346 echo give_stripe_connection_type_name($stripeAccount['type']); ?>
347 </div>
348 </div>
349
350 <div class="give-stripe-account-fieldset give-stripe-statement-descriptor">
351 <span class="give-stripe-label">
352 <?php
353 esc_html_e('Statement Descriptor:', 'give'); ?>
354 <?php
355 echo sprintf(
356 '<a href="%s" target="_blank">%s</a>',
357 'https://stripe.com/docs/statement-descriptors#requirements',
358 Give()->tooltips->render_help([
359 'label' => esc_html__(
360 '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.',
361 'give'
362 ),
363 'size' => 'medium',
364 ]
365 )
366 );
367 ?>
368 </span>
369 <div
370 class="give-stripe-connect-data-field"
371 data-action-url="<?php
372 echo $editStatementDescriptorUrl; ?>"
373 >
374 <?php
375 echo $stripeAccount['statement_descriptor']; ?>
376 <?php
377 if ($this->isGlobalSettingPage()): ?>
378 <span class="give-stripe-edit-statement-descriptor">
379 <a class="give-stripe-edit-statement-descriptor-btn" href="#">
380 <span class="dashicons dashicons-edit-page"></span>
381 <?php
382 esc_html_e('Edit', 'give'); ?>
383 </a>
384 </span>
385 <?php
386 endif; ?>
387 </div>
388 </div>
389
390 <?php
391 /**
392 * Filter fire.
393 *
394 * Developer can utilize this hook to add custom action to stripe account
395 *
396 * @since 2.13.3
397 */
398 $stripeAccountActionsHtml = apply_filters(
399 'give_stripe_manage_account_actions_html',
400 '',
401 $stripeAccount,
402 $this->stripeAccounts,
403 $this->defaultStripeAccountSlug
404 );
405
406 if ($stripeAccountActionsHtml) {
407 printf(
408 '<div class="give-stripe-account-fieldset give-stripe-account-edit">%s</div>',
409 $stripeAccountActionsHtml
410 );
411 }
412 ?>
413
414 <div class="give-stripe-account-fieldset">
415 <span class="give-stripe-label"><?php
416 esc_html_e('Connection Status:', 'give'); ?></span>
417 <div class="give-stripe-account-actions">
418 <span class="give-stripe-account-connected give-stripe-connect-data-field">
419 <?php
420 esc_html_e('Connected', 'give'); ?>
421 </span>
422 <?php
423 if (
424 $stripeAccountSlug !== $this->defaultStripeAccountSlug ||
425 1 === count($this->stripeAccounts)
426 ) :?>
427 <span class="give-stripe-account-disconnect">
428 <a class="give-stripe-disconnect-account-btn" href="<?php
429 echo $disconnectUrl; ?>">
430 <span class="dashicons dashicons-editor-unlink"></span>
431 <?php
432 esc_html_e('Disconnect', 'give'); ?>
433 </a>
434 </span>
435 <?php
436 endif; ?>
437 </div>
438 </div>
439
440 <?php
441 if ($stripeAccountSlug === $this->defaultStripeAccountSlug) : ?>
442 <div class="give-stripe-account-badge">
443 <?php
444 esc_html_e('Default Account', 'give'); ?>
445 </div>
446 <?php
447 else : ?>
448 <div class="give-stripe-account-default">
449 <a
450 data-account="<?php
451 echo $stripeAccountSlug; ?>"
452 class="give-stripe-account-set-default"
453 href="#"
454 ><?php
455 esc_html_e('Set as Default', 'give'); ?></a>
456 </div>
457 <?php
458 endif; ?>
459 </div>
460 <?php
461 }
462
463 /**
464 * @since 2.13.0
465 */
466 private function getStripeAccountOnBoardingModalMarkup()
467 {
468 global $post;
469
470 $site_url = get_site_url();
471 $redirectUrl = $this->isGlobalSettingPage() ?
472 admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=stripe-settings') :
473 admin_url("post.php?post=$post->ID&action=edit&give_tab=stripe_form_account_options");
474
475 $modal_title = sprintf(
476 '<strong>%1$s</strong>',
477 esc_html__(
478 'You are connected! Now this is important: Please configure your Stripe webhook to finalize the setup.',
479 'give'
480 )
481 );
482 $modal_first_detail = sprintf(
483 '%1$s %2$s',
484 esc_html__(
485 '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:',
486 'give'
487 ),
488 "<strong>{$site_url}?give-listener=stripe</strong>"
489 );
490 $modal_second_detail = esc_html__(
491 'Stripe webhooks are required so GiveWP can communicate properly with the payment gateway to confirm payment completion, renewals, and more.',
492 'give'
493 );
494 $can_display = ! empty($_GET['stripe_account']) ? '0' : '1';
495 ?>
496 <div
497 id="give-stripe-connected"
498 class="stripe-btn-disabled give-hidden"
499 data-status="connected"
500 data-title="<?php
501 echo $modal_title; ?>"
502 data-first-detail="<?php
503 echo $modal_first_detail; ?>"
504 data-second-detail="<?php
505 echo $modal_second_detail; ?>"
506 data-display="<?php
507 echo $can_display; ?>"
508 data-redirect-url="<?php
509 echo esc_url_raw($redirectUrl); ?>"
510 >
511 </div>
512 <?php
513 }
514
515 /**
516 * @since 2.13.0
517 */
518 private function getCompatibilityNoticeMarkup()
519 {
520 ?>
521 <div class="give-stripe-account-manager-add-section">
522 <?php
523 Give()->notices->print_admin_notices(
524 [
525 'description' => sprintf(
526 '%1$s <a href="%2$s">%3$s</a> %4$s',
527 esc_html__(
528 '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. ',
529 'give'
530 ),
531 esc_url(admin_url('edit.php?post_type=give_forms&page=give-updates')),
532 esc_html__('Click here', 'give'),
533 esc_html__('to complete your pending database updates.', 'give')
534 ),
535 'dismissible' => false,
536 ]
537 );
538 ?>
539 </div>
540 <?php
541 }
542
543 /**
544 * @since 2.13.0
545 */
546 private function getFreeStripeVersionNoticeMarkup()
547 {
548 ?>
549 <p class="give-stripe-subheading-description">
550 <?php
551 printf(
552 __(
553 '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>',
554 'give'
555 ),
556 esc_url('http://docs.givewp.com/settings-stripe-addon'),
557 esc_url('http://docs.givewp.com/settings-stripe-recurring'),
558 esc_url('http://docs.givewp.com/settings-stripe-free')
559 );
560 ?>
561 </p>
562 <?php
563 }
564
565 /**
566 * @since 2.13.0
567 */
568 public function getNoStripeAccountMarkup()
569 {
570 ?>
571 <div class="no-stripe-account-connected">
572 <div class="no-stripe-account-connected-inner">
573 <span class="dashicons dashicons-info"></span>
574 <h3 class="give-stripe-settings-heading">
575 <?php
576 echo $this->isGlobalSettingPage() ?
577 esc_html__('No Stripe Accounts Connected', 'give') :
578 esc_html__('Connect a New Stripe Account', 'give');
579 ?>
580 </h3>
581 <p id="give-stripe-connect-invite">
582 <?php
583 echo $this->isGlobalSettingPage() ?
584 esc_html__('Connect an account to get started!', 'give') :
585 esc_html__(
586 'Add a new account to customize the Stripe account used for this donation form.',
587 'give'
588 )
589 ?>
590 </p>
591 <?php
592 echo $this->getStripeConnectButtonMarkup(); ?>
593 </div>
594 </div>
595 <?php
596 }
597
598 /**
599 * @since 2.25.0 Use 'ConnectClient' class
600 * @since 2.13.0
601 * @return string
602 */
603 public function getStripeConnectButtonMarkup()
604 {
605 // Prepare Stripe Connect URL.
606 $link = add_query_arg(
607 [
608 'stripe_action' => 'connect',
609 'mode' => give_is_test_mode() ? 'test' : 'live',
610 'return_url' => ! $this->isGlobalSettingPage() ?
611 rawurlencode(
612 sprintf(
613 admin_url('post.php?post=%d&action=edit&give_tab=stripe_form_account_options'),
614 get_the_ID()
615 )
616 ) :
617 rawurlencode(
618 admin_url(
619 'edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=stripe-settings'
620 )
621 ),
622 'website_url' => get_bloginfo('url'),
623 'give_stripe_connected' => '0',
624 ],
625 esc_url_raw($this->connectClient->getApiUrl('stripe/connect.php'))
626 );
627
628 $stripeSvgIcon = '<svg width="15" height="21" viewBox="0 0 15 21" fill="none" xmlns="http://www.w3.org/2000/svg">
629 <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"/>
630 </svg>
631 ';
632
633 return sprintf(
634 '<a href="%1$s" class="give-stripe-connect" title="%2$s"><span class="stripe-logo">%3$s</span><span>%2$s</span></a>',
635 esc_url($link),
636 esc_html__('Connect with Stripe', 'give'),
637 $stripeSvgIcon
638 );
639 }
640
641 /**
642 * @since 2.13.0
643 */
644 private function getDefaultStripeAccountNotice()
645 {
646 ?>
647 <div class="give-stripe-default-account-notice">
648 <span class="dashicons dashicons-info"></span>
649 <div class="give-stripe-default-account-notice__inner">
650 <p class="give-stripe-default-account-notice__bold"><strong>
651 <?php
652 echo $this->isGlobalSettingPage() ?
653 esc_html__('All payments go to the default account', 'give') :
654 esc_html__('Stripe donations process through the account set above', 'give');
655 ?>
656 </strong></p>
657 <p>
658 <?php
659 echo $this->isGlobalSettingPage() ?
660 esc_html__(
661 'You can set this globally (for all donation forms) or override the Stripe account per donation form.',
662 'give'
663 ) :
664 esc_html__('This overrides the global default account setting for this donation form.', 'give');
665 ?>
666 </p>
667 </div>
668 </div>
669 <?php
670 }
671
672 /**
673 * @since 2.13.0
674 * @return bool
675 */
676 private function canShowFreeStripeVersionNotice()
677 {
678 return ! give_stripe_is_premium_active();
679 }
680
681 /**
682 * @return bool
683 */
684 private function canShowCompatibilityNotice()
685 {
686 return ! give_has_upgrade_completed('v270_store_stripe_account_for_donation');
687 }
688
689 /**
690 * @since 2.13.0
691 * @return bool
692 */
693 private function isGlobalSettingPage()
694 {
695 return Give_Admin_Settings::is_setting_page('gateways', 'stripe-settings');
696 }
697
698 /**
699 * @since 2.13.0
700 *
701 * @param string $accountSlug Stripe account slug
702 *
703 * @return bool
704 */
705 private function isGlobalDefaultStripeAccount($accountSlug)
706 {
707 $globalDefaultStripeAccountDetail = give_stripe_get_default_account();
708
709 if (empty($globalDefaultStripeAccountDetail)) {
710 return false;
711 }
712
713 return ! $this->isGlobalSettingPage() && $globalDefaultStripeAccountDetail['account_slug'] === $accountSlug;
714 }
715 }
716