give
/
src
/
PaymentGateways
/
Gateways
/
Stripe
/
Actions
/
UpdateStripeAccountStatementDescriptor.php
CreateCheckoutSession.php
4 years ago
CreatePaymentIntent.php
4 years ago
GetOrCreateStripeCustomer.php
4 years ago
GetPaymentMethodFromRequest.php
4 years ago
SaveDonationSummary.php
4 years ago
UpdateStripeAccountStatementDescriptor.php
4 years ago
ValidatePaymentMethod.php
4 years ago
UpdateStripeAccountStatementDescriptor.php
42 lines
| 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 |