mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Do not complete non-checkout button orders via webhooks
This commit is contained in:
parent
40371cbf67
commit
f811ea6a99
2 changed files with 15 additions and 0 deletions
|
@ -211,6 +211,15 @@ class PurchaseUnit {
|
||||||
return $this->custom_id;
|
return $this->custom_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the custom ID.
|
||||||
|
*
|
||||||
|
* @param string $custom_id The value to set.
|
||||||
|
*/
|
||||||
|
public function set_custom_id( string $custom_id ): void {
|
||||||
|
$this->custom_id = $custom_id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the invoice id.
|
* Returns the invoice id.
|
||||||
*
|
*
|
||||||
|
|
|
@ -258,6 +258,12 @@ class CreateOrderEndpoint implements EndpointInterface {
|
||||||
} else {
|
} else {
|
||||||
$this->purchase_unit = $this->purchase_unit_factory->from_wc_cart( null, $this->handle_shipping_in_paypal );
|
$this->purchase_unit = $this->purchase_unit_factory->from_wc_cart( null, $this->handle_shipping_in_paypal );
|
||||||
|
|
||||||
|
// Do not allow completion by webhooks when started via non-checkout buttons,
|
||||||
|
// it is needed only for some APMs in checkout.
|
||||||
|
if ( in_array( $data['context'], array( 'product', 'cart', 'cart-block' ), true ) ) {
|
||||||
|
$this->purchase_unit->set_custom_id( '' );
|
||||||
|
}
|
||||||
|
|
||||||
// The cart does not have any info about payment method, so we must handle free trial here.
|
// The cart does not have any info about payment method, so we must handle free trial here.
|
||||||
if ( (
|
if ( (
|
||||||
in_array( $payment_method, array( CreditCardGateway::ID, CardButtonGateway::ID ), true )
|
in_array( $payment_method, array( CreditCardGateway::ID, CardButtonGateway::ID ), true )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue