mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Do not send whole order in create order response
This commit is contained in:
parent
df81e5e411
commit
bee2a8d5ba
2 changed files with 17 additions and 4 deletions
|
@ -109,7 +109,7 @@ class CheckoutActionHandler {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.setAttribute('type', 'hidden');
|
input.setAttribute('type', 'hidden');
|
||||||
input.setAttribute('name', 'ppcp-resume-order');
|
input.setAttribute('name', 'ppcp-resume-order');
|
||||||
input.setAttribute('value', data.data.purchase_units[0].custom_id);
|
input.setAttribute('value', data.data.custom_id);
|
||||||
document.querySelector(formSelector).appendChild(input);
|
document.querySelector(formSelector).appendChild(input);
|
||||||
return data.data.id;
|
return data.data.id;
|
||||||
});
|
});
|
||||||
|
|
|
@ -292,7 +292,7 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
! $this->early_order_handler->should_create_early_order()
|
! $this->early_order_handler->should_create_early_order()
|
||||||
|| $this->registration_needed
|
|| $this->registration_needed
|
||||||
|| isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) {
|
|| isset( $data['createaccount'] ) && '1' === $data['createaccount'] ) {
|
||||||
wp_send_json_success( $order->to_array() );
|
wp_send_json_success( $this->make_response( $order ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->early_order_handler->register_for_order( $order );
|
$this->early_order_handler->register_for_order( $order );
|
||||||
|
@ -304,7 +304,7 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
$wc_order->save_meta_data();
|
$wc_order->save_meta_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_send_json_success( $order->to_array() );
|
wp_send_json_success( $this->make_response( $order ) );
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch ( ValidationException $error ) {
|
} catch ( ValidationException $error ) {
|
||||||
|
@ -362,7 +362,7 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
* during the "onApprove"-JS callback or the webhook listener.
|
* during the "onApprove"-JS callback or the webhook listener.
|
||||||
*/
|
*/
|
||||||
if ( ! $this->early_order_handler->should_create_early_order() ) {
|
if ( ! $this->early_order_handler->should_create_early_order() ) {
|
||||||
wp_send_json_success( $order->to_array() );
|
wp_send_json_success( $this->make_response( $order ) );
|
||||||
}
|
}
|
||||||
$this->early_order_handler->register_for_order( $order );
|
$this->early_order_handler->register_for_order( $order );
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -569,4 +569,17 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the response data for success response.
|
||||||
|
*
|
||||||
|
* @param Order $order The PayPal order.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function make_response( Order $order ): array {
|
||||||
|
return array(
|
||||||
|
'id' => $order->id(),
|
||||||
|
'custom_id' => $order->purchase_units()[0]->custom_id(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue