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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / api / class-wc-rest-payment-gateways-controller.php
woocommerce / includes / api Last commit date
legacy 7 years ago v1 7 years ago v2 6 years ago wc-blocks 7 years ago class-wc-rest-authentication.php 7 years ago class-wc-rest-coupons-controller.php 7 years ago class-wc-rest-customer-downloads-controller.php 7 years ago class-wc-rest-customers-controller.php 7 years ago class-wc-rest-data-continents-controller.php 7 years ago class-wc-rest-data-controller.php 7 years ago class-wc-rest-data-countries-controller.php 7 years ago class-wc-rest-data-currencies-controller.php 7 years ago class-wc-rest-exception.php 8 years ago class-wc-rest-network-orders-controller.php 7 years ago class-wc-rest-order-notes-controller.php 7 years ago class-wc-rest-order-refunds-controller.php 7 years ago class-wc-rest-orders-controller.php 7 years ago class-wc-rest-payment-gateways-controller.php 7 years ago class-wc-rest-product-attribute-terms-controller.php 7 years ago class-wc-rest-product-attributes-controller.php 7 years ago class-wc-rest-product-categories-controller.php 7 years ago class-wc-rest-product-reviews-controller.php 7 years ago class-wc-rest-product-shipping-classes-controller.php 7 years ago class-wc-rest-product-tags-controller.php 7 years ago class-wc-rest-product-variations-controller.php 7 years ago class-wc-rest-products-controller.php 7 years ago class-wc-rest-report-coupons-totals-controller.php 7 years ago class-wc-rest-report-customers-totals-controller.php 7 years ago class-wc-rest-report-orders-totals-controller.php 7 years ago class-wc-rest-report-products-totals-controller.php 7 years ago class-wc-rest-report-reviews-totals-controller.php 7 years ago class-wc-rest-report-sales-controller.php 7 years ago class-wc-rest-report-top-sellers-controller.php 7 years ago class-wc-rest-reports-controller.php 7 years ago class-wc-rest-setting-options-controller.php 7 years ago class-wc-rest-settings-controller.php 7 years ago class-wc-rest-shipping-methods-controller.php 7 years ago class-wc-rest-shipping-zone-locations-controller.php 7 years ago class-wc-rest-shipping-zone-methods-controller.php 7 years ago class-wc-rest-shipping-zones-controller.php 7 years ago class-wc-rest-system-status-controller.php 7 years ago class-wc-rest-system-status-tools-controller.php 7 years ago class-wc-rest-tax-classes-controller.php 7 years ago class-wc-rest-taxes-controller.php 7 years ago class-wc-rest-webhooks-controller.php 7 years ago
class-wc-rest-payment-gateways-controller.php
227 lines
1 <?php
2 /**
3 * REST API WC Payment gateways controller
4 *
5 * Handles requests to the /payment_gateways endpoint.
6 *
7 * @package WooCommerce/API
8 * @since 3.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Paymenga gateways controller class.
15 *
16 * @package WooCommerce/API
17 * @extends WC_REST_Payment_Gateways_V2_Controller
18 */
19 class WC_REST_Payment_Gateways_Controller extends WC_REST_Payment_Gateways_V2_Controller {
20
21 /**
22 * Endpoint namespace.
23 *
24 * @var string
25 */
26 protected $namespace = 'wc/v3';
27
28 /**
29 * Prepare a payment gateway for response.
30 *
31 * @param WC_Payment_Gateway $gateway Payment gateway object.
32 * @param WP_REST_Request $request Request object.
33 * @return WP_REST_Response $response Response data.
34 */
35 public function prepare_item_for_response( $gateway, $request ) {
36 $order = (array) get_option( 'woocommerce_gateway_order' );
37 $item = array(
38 'id' => $gateway->id,
39 'title' => $gateway->title,
40 'description' => $gateway->description,
41 'order' => isset( $order[ $gateway->id ] ) ? $order[ $gateway->id ] : '',
42 'enabled' => ( 'yes' === $gateway->enabled ),
43 'method_title' => $gateway->get_method_title(),
44 'method_description' => $gateway->get_method_description(),
45 'method_supports' => $gateway->supports,
46 'settings' => $this->get_settings( $gateway ),
47 );
48
49 $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
50 $data = $this->add_additional_fields_to_object( $item, $request );
51 $data = $this->filter_response_by_context( $data, $context );
52
53 $response = rest_ensure_response( $data );
54 $response->add_links( $this->prepare_links( $gateway, $request ) );
55
56 /**
57 * Filter payment gateway objects returned from the REST API.
58 *
59 * @param WP_REST_Response $response The response object.
60 * @param WC_Payment_Gateway $gateway Payment gateway object.
61 * @param WP_REST_Request $request Request object.
62 */
63 return apply_filters( 'woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request );
64 }
65
66 /**
67 * Return settings associated with this payment gateway.
68 *
69 * @param WC_Payment_Gateway $gateway Gateway instance.
70 *
71 * @return array
72 */
73 public function get_settings( $gateway ) {
74 $settings = array();
75 $gateway->init_form_fields();
76 foreach ( $gateway->form_fields as $id => $field ) {
77 // Make sure we at least have a title and type.
78 if ( empty( $field['title'] ) || empty( $field['type'] ) ) {
79 continue;
80 }
81
82 // Ignore 'enabled' and 'description' which get included elsewhere.
83 if ( in_array( $id, array( 'enabled', 'description' ), true ) ) {
84 continue;
85 }
86
87 $data = array(
88 'id' => $id,
89 'label' => empty( $field['label'] ) ? $field['title'] : $field['label'],
90 'description' => empty( $field['description'] ) ? '' : $field['description'],
91 'type' => $field['type'],
92 'value' => empty( $gateway->settings[ $id ] ) ? '' : $gateway->settings[ $id ],
93 'default' => empty( $field['default'] ) ? '' : $field['default'],
94 'tip' => empty( $field['description'] ) ? '' : $field['description'],
95 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'],
96 );
97 if ( ! empty( $field['options'] ) ) {
98 $data['options'] = $field['options'];
99 }
100 $settings[ $id ] = $data;
101 }
102 return $settings;
103 }
104
105 /**
106 * Get the payment gateway schema, conforming to JSON Schema.
107 *
108 * @return array
109 */
110 public function get_item_schema() {
111 $schema = array(
112 '$schema' => 'http://json-schema.org/draft-04/schema#',
113 'title' => 'payment_gateway',
114 'type' => 'object',
115 'properties' => array(
116 'id' => array(
117 'description' => __( 'Payment gateway ID.', 'woocommerce' ),
118 'type' => 'string',
119 'context' => array( 'view', 'edit' ),
120 'readonly' => true,
121 ),
122 'title' => array(
123 'description' => __( 'Payment gateway title on checkout.', 'woocommerce' ),
124 'type' => 'string',
125 'context' => array( 'view', 'edit' ),
126 ),
127 'description' => array(
128 'description' => __( 'Payment gateway description on checkout.', 'woocommerce' ),
129 'type' => 'string',
130 'context' => array( 'view', 'edit' ),
131 ),
132 'order' => array(
133 'description' => __( 'Payment gateway sort order.', 'woocommerce' ),
134 'type' => 'integer',
135 'context' => array( 'view', 'edit' ),
136 'arg_options' => array(
137 'sanitize_callback' => 'absint',
138 ),
139 ),
140 'enabled' => array(
141 'description' => __( 'Payment gateway enabled status.', 'woocommerce' ),
142 'type' => 'boolean',
143 'context' => array( 'view', 'edit' ),
144 ),
145 'method_title' => array(
146 'description' => __( 'Payment gateway method title.', 'woocommerce' ),
147 'type' => 'string',
148 'context' => array( 'view', 'edit' ),
149 'readonly' => true,
150 ),
151 'method_description' => array(
152 'description' => __( 'Payment gateway method description.', 'woocommerce' ),
153 'type' => 'string',
154 'context' => array( 'view', 'edit' ),
155 'readonly' => true,
156 ),
157 'method_supports' => array(
158 'description' => __( 'Supported features for this payment gateway.', 'woocommerce' ),
159 'type' => 'array',
160 'context' => array( 'view', 'edit' ),
161 'readonly' => true,
162 'items' => array(
163 'type' => 'string',
164 ),
165 ),
166 'settings' => array(
167 'description' => __( 'Payment gateway settings.', 'woocommerce' ),
168 'type' => 'object',
169 'context' => array( 'view', 'edit' ),
170 'properties' => array(
171 'id' => array(
172 'description' => __( 'A unique identifier for the setting.', 'woocommerce' ),
173 'type' => 'string',
174 'context' => array( 'view', 'edit' ),
175 'readonly' => true,
176 ),
177 'label' => array(
178 'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ),
179 'type' => 'string',
180 'context' => array( 'view', 'edit' ),
181 'readonly' => true,
182 ),
183 'description' => array(
184 'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ),
185 'type' => 'string',
186 'context' => array( 'view', 'edit' ),
187 'readonly' => true,
188 ),
189 'type' => array(
190 'description' => __( 'Type of setting.', 'woocommerce' ),
191 'type' => 'string',
192 'context' => array( 'view', 'edit' ),
193 'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ),
194 'readonly' => true,
195 ),
196 'value' => array(
197 'description' => __( 'Setting value.', 'woocommerce' ),
198 'type' => 'string',
199 'context' => array( 'view', 'edit' ),
200 ),
201 'default' => array(
202 'description' => __( 'Default value for the setting.', 'woocommerce' ),
203 'type' => 'string',
204 'context' => array( 'view', 'edit' ),
205 'readonly' => true,
206 ),
207 'tip' => array(
208 'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ),
209 'type' => 'string',
210 'context' => array( 'view', 'edit' ),
211 'readonly' => true,
212 ),
213 'placeholder' => array(
214 'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ),
215 'type' => 'string',
216 'context' => array( 'view', 'edit' ),
217 'readonly' => true,
218 ),
219 ),
220 ),
221 ),
222 );
223
224 return $this->add_additional_fields_schema( $schema );
225 }
226 }
227