PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.0.4
JetFormBuilder — Dynamic Blocks Form Builder v2.0.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / gateways / paypal / rest-endpoints / fetch-pay-now-editor.php
jetformbuilder / includes / gateways / paypal / rest-endpoints Last commit date
fetch-pay-now-editor.php 4 years ago
fetch-pay-now-editor.php
59 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Gateways\Paypal\Rest_Endpoints;
5
6 use Jet_Form_Builder\Exceptions\Gateway_Exception;
7 use Jet_Form_Builder\Rest_Api\Rest_Api_Endpoint_Base;
8 use Jet_Form_Builder\Gateways\Paypal;
9
10 class Fetch_Pay_Now_Editor extends Rest_Api_Endpoint_Base {
11
12 public static function get_rest_base() {
13 return 'paypal-base-fetch';
14 }
15
16 public static function get_methods() {
17 return \WP_REST_Server::CREATABLE;
18 }
19
20 public function check_permission(): bool {
21 return current_user_can( 'manage_options' );
22 }
23
24 /**
25 * @param \WP_REST_Request $request
26 *
27 * @return mixed|string
28 * @throws Gateway_Exception
29 */
30 public function get_token( \WP_REST_Request $request ): string {
31 $credits = $request->get_json_params();
32
33 list( $client_id, $secret ) = array( $credits['client_id'] ?? '', $credits['secret'] ?? '' );
34
35 return Paypal\Controller::get_token_with_credits( $client_id, $secret );
36 }
37
38 public function run_callback( \WP_REST_Request $request ) {
39 try {
40 $this->get_token( $request );
41
42 } catch ( Gateway_Exception $exception ) {
43 return new \WP_REST_Response(
44 array(
45 'message' => $exception->getMessage(),
46 'data' => $exception->get_additional(),
47 ),
48 500
49 );
50 }
51
52 return new \WP_REST_Response(
53 array(
54 'message' => __( 'Access key saved successfully!', 'jet-form-builder' ),
55 )
56 );
57 }
58 }
59