PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 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 All 257 releases
give / src / PaymentGateways / Stripe / Controllers / GetStripeAccountDetailsController.php

GetStripeAccountDetailsController.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/PaymentGateways/Stripe/Controllers/GetStripeAccountDetailsController.php

61 lines 1.4 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\Controllers;
4
5 use Give\Framework\Exceptions\Primitives\InvalidArgumentException;
6 use Give\PaymentGateways\Stripe\DataTransferObjects\GetStripeAccountDetailsDto;
7 use Give\PaymentGateways\Stripe\Repositories\AccountDetail;
8
9 /**
10 * Class GetStripeAccountDetailsController
11 * @package Give\PaymentGateways\Stripe\Controllers
12 *
13 * @since 2.13.0
14 */
15 class GetStripeAccountDetailsController
16 {
17 /**
18 * @var AccountDetail
19 */
20 private $accountDetailServiceProvider;
21
22 /**
23 * @since 2.13.3
24 *
25 * @param AccountDetail $accountDetailServiceProvider
26 */
27 public function __construct(AccountDetail $accountDetailServiceProvider)
28 {
29 $this->accountDetailServiceProvider = $accountDetailServiceProvider;
30 }
31
32 /**
33 * @since 2.13.3
34 */
35 public function __invoke()
36 {
37 $this->validateRequest();
38 $requestedData = GetStripeAccountDetailsDto::fromArray(give_clean($_POST));
39
40 try {
41 wp_send_json_success(
42 $this->accountDetailServiceProvider
43 ->getAccountDetailBySlug($requestedData->accountSlug)
44 ->toArray()
45 );
46 } catch (InvalidArgumentException $e) {
47 wp_send_json_error();
48 }
49 }
50
51 /**
52 * @since 2.13.0
53 */
54 private function validateRequest()
55 {
56 if ( ! current_user_can('manage_give_settings')) {
57 die();
58 }
59 }
60 }
61