mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #641 from woocommerce/PCP-580-manual-orders-return-an-error-for-guest-users
Store order info in wc order meta to get if there is no session.
This commit is contained in:
commit
b7c4f23b62
4 changed files with 26 additions and 7 deletions
|
@ -209,12 +209,6 @@ class CreditCardRenderer {
|
||||||
const firstName = document.getElementById('billing_first_name') ? document.getElementById('billing_first_name').value : '';
|
const firstName = document.getElementById('billing_first_name') ? document.getElementById('billing_first_name').value : '';
|
||||||
const lastName = document.getElementById('billing_last_name') ? document.getElementById('billing_last_name').value : '';
|
const lastName = document.getElementById('billing_last_name') ? document.getElementById('billing_last_name').value : '';
|
||||||
|
|
||||||
if (!firstName || !lastName) {
|
|
||||||
this.spinner.unblock();
|
|
||||||
this.errorHandler.message(this.defaultConfig.hosted_fields.labels.cardholder_name_required);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hostedFieldsData.cardholderName = firstName + ' ' + lastName;
|
hostedFieldsData.cardholderName = firstName + ' ' + lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,13 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
$order = $this->create_paypal_order( $wc_order );
|
$order = $this->create_paypal_order( $wc_order );
|
||||||
|
|
||||||
|
if ( 'pay-now' === $data['context'] && is_a( $wc_order, \WC_Order::class ) ) {
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $order->id() );
|
||||||
|
$wc_order->update_meta_data( PayPalGateway::INTENT_META_KEY, $order->intent() );
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
}
|
||||||
|
|
||||||
wp_send_json_success( $order->to_array() );
|
wp_send_json_success( $order->to_array() );
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,8 @@ class OrderProcessor {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function process( \WC_Order $wc_order ): bool {
|
public function process( \WC_Order $wc_order ): bool {
|
||||||
$order = $this->session_handler->order();
|
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
|
||||||
|
$order = $this->session_handler->order() ?? $this->order_endpoint->order( $order_id );
|
||||||
if ( ! $order ) {
|
if ( ! $order ) {
|
||||||
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
|
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -89,6 +89,11 @@ class OrderProcessorTest extends TestCase
|
||||||
->shouldReceive('payment_source')
|
->shouldReceive('payment_source')
|
||||||
->andReturn(null);
|
->andReturn(null);
|
||||||
|
|
||||||
|
$wcOrder
|
||||||
|
->shouldReceive('get_meta')
|
||||||
|
->with(PayPalGateway::ORDER_ID_META_KEY)
|
||||||
|
->andReturn(1);
|
||||||
|
|
||||||
$sessionHandler = Mockery::mock(SessionHandler::class);
|
$sessionHandler = Mockery::mock(SessionHandler::class);
|
||||||
$sessionHandler
|
$sessionHandler
|
||||||
->expects('order')
|
->expects('order')
|
||||||
|
@ -208,6 +213,12 @@ class OrderProcessorTest extends TestCase
|
||||||
$currentOrder
|
$currentOrder
|
||||||
->shouldReceive('payment_source')
|
->shouldReceive('payment_source')
|
||||||
->andReturn(null);
|
->andReturn(null);
|
||||||
|
|
||||||
|
$wcOrder
|
||||||
|
->shouldReceive('get_meta')
|
||||||
|
->with(PayPalGateway::ORDER_ID_META_KEY)
|
||||||
|
->andReturn(1);
|
||||||
|
|
||||||
$sessionHandler = Mockery::mock(SessionHandler::class);
|
$sessionHandler = Mockery::mock(SessionHandler::class);
|
||||||
$sessionHandler
|
$sessionHandler
|
||||||
->expects('order')
|
->expects('order')
|
||||||
|
@ -313,6 +324,12 @@ class OrderProcessorTest extends TestCase
|
||||||
$currentOrder
|
$currentOrder
|
||||||
->shouldReceive('purchase_units')
|
->shouldReceive('purchase_units')
|
||||||
->andReturn([$purchaseUnit]);
|
->andReturn([$purchaseUnit]);
|
||||||
|
|
||||||
|
$wcOrder
|
||||||
|
->shouldReceive('get_meta')
|
||||||
|
->with(PayPalGateway::ORDER_ID_META_KEY)
|
||||||
|
->andReturn(1);
|
||||||
|
|
||||||
$sessionHandler = Mockery::mock(SessionHandler::class);
|
$sessionHandler = Mockery::mock(SessionHandler::class);
|
||||||
$sessionHandler
|
$sessionHandler
|
||||||
->expects('order')
|
->expects('order')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue