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 / Stripe / ApplicationFee.php

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

76 lines 1.9 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\Stripe;
4
5 use Give\License\Repositories\LicenseRepository;
6 use Give\PaymentGateways\Stripe\Models\AccountDetail as AccountDetailModel;
7
8 /**
9 * Class ApplicationFee
10 * @package Give\PaymentGateways\Stripe
11 *
12 * @see https://github.com/impress-org/givewp/issues/5555#issuecomment-759596226
13 *
14 * @since 2.10.2
15 */
16 class ApplicationFee
17 {
18 /**
19 * @since 2.10.2
20 */
21 protected AccountDetailModel $accountDetail;
22
23 /**
24 * @since 4.3.0
25 */
26 protected LicenseRepository $licenseRepository;
27
28 /**
29 * @since 4.3.0 added LicenseRepository
30 * @since 2.10.2
31 */
32 public function __construct(AccountDetailModel $accountDetail)
33 {
34 $this->accountDetail = $accountDetail;
35 $this->licenseRepository = give(LicenseRepository::class);
36 }
37
38 /**
39 * Returns true or false based on whether the Stripe fee should be applied or not
40 *
41 * @since 4.3.0 updated logic to check license for gateway fee
42 * @since 2.10.2
43 */
44 public static function canAddFee(): bool
45 {
46 /* @var self $gate */
47 $gate = give(static::class);
48
49 if (!$gate->doesCountrySupportApplicationFee()) {
50 return false;
51 }
52
53 return $gate->licenseRepository->hasPlatformFeePercentage();
54 }
55
56 /**
57 * Return whether country support application fee.
58 *
59 * @since 4.5.0 Add India, Malaysia, Mexico, Singapore, Thailand to the list of unsupported countries
60 * @since 2.10.2
61 */
62 public function doesCountrySupportApplicationFee(): bool
63 {
64 $unsupportedCountries = [
65 'BR', // Brazil
66 'IN', // India
67 'MY', // Malaysia
68 'MX', // Mexico
69 'SG', // Singapore
70 'TH', // Thailand
71 ];
72
73 return !in_array($this->accountDetail->accountCountry, $unsupportedCountries);
74 }
75 }
76