PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.10.0
GiveWP – Donation Plugin and Fundraising Platform v4.10.0
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 2.31.0 2.31.1 All 253 releases
give / src / PaymentGateways / Gateways / Stripe / Actions / UpdateStripeAccountStatementDescriptor.php
UpdateStripeAccountStatementDescriptor.php
42 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\Gateways\Stripe\Actions;
4
5 use Give\Framework\Exceptions\Primitives\InvalidArgumentException;
6 use Give\PaymentGateways\Exceptions\InvalidPropertyName;
7 use Give\PaymentGateways\Stripe\Models\AccountDetail;
8 use Give\PaymentGateways\Stripe\Repositories\Settings;
9
10 /**
11 * @since 2.19.0
12 */
13 class UpdateStripeAccountStatementDescriptor
14 {
15 /**
16 *
17 * @param string $stripeAccountId
18 * @param string $stripeStatementDescriptorText
19 *
20 * @return bool
21 * @throws InvalidArgumentException|InvalidPropertyName
22 */
23 public function __invoke($stripeAccountId, $stripeStatementDescriptorText)
24 {
25 $settingRepository = give(Settings::class);
26 $stripeAccount = $settingRepository->getStripeAccountById($stripeAccountId);
27
28 if ($stripeStatementDescriptorText === $stripeAccount->statementDescriptor) {
29 return true;
30 }
31
32 $newStripeAccount = AccountDetail::fromArray(
33 array_merge(
34 $stripeAccount->toArray(),
35 ['statement_descriptor' => $stripeStatementDescriptorText]
36 )
37 );
38
39 return $settingRepository->updateStripeAccount($newStripeAccount);
40 }
41 }
42