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 / DonationFormPaymentMethod.php

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

56 lines 1.2 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\Gateways\PayPalCommerce\PayPalCommerceGateway;
6
7 /**
8 * Class DonationFormPaymentMethod
9 * @package Give\PaymentGateways\PayPalCommerce
10 *
11 * @since 2.9.6
12 */
13 class DonationFormPaymentMethod
14 {
15 /**
16 * Setup filter hook.
17 *
18 * @since 2.9.6
19 */
20 public function handle()
21 {
22 // Exit.
23 if (! Utils::gatewayIsActive()) {
24 return;
25 }
26
27 add_filter('give_enabled_payment_gateways', [$this, 'filterEnabledPayments'], 99);
28 }
29
30 /**
31 * Disable PayPal payment option if gateway account is not setup.
32 *
33 * @since 3.0.0 Use new payment gateway class.
34 * @sicne 2.9.6
35 *
36 * @param array $gateways
37 *
38 * @return array
39 */
40 public function filterEnabledPayments($gateways)
41 {
42 /* @var PayPalCommerceGateway $paypalCommerce */
43 $paypalCommerce = give(PayPalCommerceGateway::class);
44
45 if (! array_key_exists($paypalCommerce->getId(), $gateways)) {
46 return $gateways;
47 }
48
49 if (! Utils::isAccountReadyToAcceptPayment()) {
50 unset($gateways[$paypalCommerce->getId()]);
51 }
52
53 return $gateways;
54 }
55 }
56