PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 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 All 255 releases
give / src / PaymentGateways / PayPalCommerce / AccountAdminNotices.php

AccountAdminNotices.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/PaymentGateways/PayPalCommerce/AccountAdminNotices.php

92 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\PaymentGateways\PayPalCommerce;
4
5 use Give\PaymentGateways\PayPalCommerce\Repositories\MerchantDetails;
6 use Give_Admin_Settings;
7
8 class AccountAdminNotices
9 {
10 /**
11 * @since 2.9.0
12 *
13 * @var MerchantDetails
14 */
15 private $merchantRepository;
16
17 /**
18 * AccountAdminNotices constructor.
19 *
20 * @param MerchantDetails $merchantRepository
21 */
22 public function __construct(MerchantDetails $merchantRepository)
23 {
24 $this->merchantRepository = $merchantRepository;
25 }
26
27 /**
28 * Displays the admin notices in the right conditions
29 *
30 * @since 2.9.0
31 */
32 public function displayNotices()
33 {
34 if (Utils::gatewayIsActive() && ! give_is_test_mode()) {
35 $this->checkForConnectedLiveAccount();
36 $this->checkForAccountReadiness();
37 }
38 }
39
40 /**
41 * Displays a notice if the account is not connected
42 *
43 * @since 2.9.0
44 */
45 public function checkForConnectedLiveAccount()
46 {
47 if ( ! $this->merchantRepository->accountIsConnected()) {
48 $connectUrl = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=paypal');
49 Give_Admin_Settings::add_message(
50 'paypal-commerce-not-connected',
51 sprintf(
52 "<strong>%1\$s</strong> %2\$s <a href='{$connectUrl}'>%3\$s</a>",
53 esc_html__('PayPal Donations:', 'give'),
54 esc_html__('Please connect to your account so donations may be processed.', 'give'),
55 esc_html__('Connect Account', 'give')
56 )
57 );
58 }
59 }
60
61 /**
62 * Displays a notice if the account is connected but not ready
63 *
64 * @since 2.9.0
65 */
66 public function checkForAccountReadiness()
67 {
68 if ( ! $this->merchantRepository->accountIsConnected()) {
69 return;
70 }
71
72 $merchantDetails = $this->merchantRepository->getDetails();
73 if ($merchantDetails->accountIsReady) {
74 return;
75 }
76
77 $connectUrl = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=paypal');
78 Give_Admin_Settings::add_message(
79 'paypal-commerce-account-not-ready',
80 sprintf(
81 "<strong>%1\$s</strong> %2\$s <a href='{$connectUrl}'>%3\$s</a>",
82 esc_html__('PayPal Donations:', 'give'),
83 esc_html__(
84 'Please check your account status as additional setup is needed before you may accept donations.',
85 'give'
86 ),
87 esc_html__('Account Status', 'give')
88 )
89 );
90 }
91 }
92