mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #833 from woocommerce/PCP-784-pay-pal-order-created-twice-when-context-is-checkout
Refactor to remove second order creation part
This commit is contained in:
commit
b549f71d77
1 changed files with 11 additions and 13 deletions
|
@ -233,14 +233,18 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
|
||||
$this->set_bn_code( $data );
|
||||
|
||||
if ( 'checkout' === $data['context'] ) {
|
||||
try {
|
||||
$order = $this->create_paypal_order( $wc_order );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->error( 'Order creation failed: ' . $exception->getMessage() );
|
||||
throw $exception;
|
||||
}
|
||||
if ( 'pay-now' === $data['context'] && get_option( 'woocommerce_terms_page_id', '' ) !== '' ) {
|
||||
$this->validate_paynow_form( $data['form'] );
|
||||
}
|
||||
|
||||
try {
|
||||
$order = $this->create_paypal_order( $wc_order );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->error( 'Order creation failed: ' . $exception->getMessage() );
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
if ( 'checkout' === $data['context'] ) {
|
||||
if (
|
||||
! $this->early_order_handler->should_create_early_order()
|
||||
|| $this->registration_needed
|
||||
|
@ -251,12 +255,6 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
$this->early_order_handler->register_for_order( $order );
|
||||
}
|
||||
|
||||
if ( 'pay-now' === $data['context'] && get_option( 'woocommerce_terms_page_id', '' ) !== '' ) {
|
||||
$this->validate_paynow_form( $data['form'] );
|
||||
}
|
||||
|
||||
$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() );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue