Skip to content

Commit

Permalink
Allow passing parameters as form data.
Browse files Browse the repository at this point in the history
  • Loading branch information
knit-pay committed Jan 11, 2024
1 parent 6192d00 commit b41b9c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Payments/PaymentRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PaymentRestController extends WP_REST_Controller {

// Here initialize our namespace and resource name.
public function __construct() {

Check failure on line 17 in src/Payments/PaymentRestController.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

You must use "/**" style comments for a function comment
$this->namespace = '/' . pronamic_pay_plugin()->rest_base . '/v1';
$this->namespace = '/' . pronamic_pay_plugin()->rest_base . '/v1';
$this->resource_name = 'payments';

Check failure on line 19 in src/Payments/PaymentRestController.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan

Access to an undefined property Pronamic\WordPress\Pay\Payments\PaymentRestController::$resource_name.
$this->post_type = 'pronamic_payment';

Check failure on line 20 in src/Payments/PaymentRestController.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan

Access to an undefined property Pronamic\WordPress\Pay\Payments\PaymentRestController::$post_type.
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public function create_item( $request ) {
}

try {
$json_param = $request->get_json_params();
$json_param = $request->get_params();
$req_object = json_decode( wp_json_encode( $json_param ) );

Check failure on line 121 in src/Payments/PaymentRestController.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan

Parameter #1 $json of function json_decode expects string, string|false given.

$payment = new Payment();
Expand Down Expand Up @@ -187,7 +187,7 @@ public function prepare_item_for_response( $payment, $request ) {
$fields = $this->get_fields_for_response( $request );

foreach ( $fields as $field ) {
if ( rest_is_field_included( $field, $fields ) ) {
if ( rest_is_field_included( $field, $fields ) && property_exists( $payment_json, $field ) ) {
$post_data[ $field ] = $payment_json->$field;
}
}
Expand Down Expand Up @@ -224,6 +224,7 @@ public function get_item_schema() {
],
'total_amount' => [
'type' => 'object',
'required' => true,
'properties' => [
'value' => [
'description' => esc_html__( 'Amount Value', 'my-textdomain' ),
Expand Down

0 comments on commit b41b9c6

Please sign in to comment.