Merge branch 'trunk' into PCP-417-new-feature---pay-upon-invoice

This commit is contained in:
dinamiko 2022-05-17 14:16:23 +02:00
commit ade0e51e47
12 changed files with 229 additions and 66 deletions

View file

@ -150,7 +150,8 @@ class OrderProcessor {
* @return 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 ) {
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
return false;

View file

@ -167,7 +167,7 @@ class SettingsListener {
* Prevent enabling both Pay Later messaging and PayPal vaulting
*/
public function listen_for_vaulting_enabled() {
if ( ! $this->is_valid_site_request() ) {
if ( ! $this->is_valid_site_request() || State::STATE_ONBOARDED !== $this->state->current_state() ) {
return;
}
@ -208,10 +208,6 @@ class SettingsListener {
$this->settings->set( 'message_product_enabled', false );
$this->settings->set( 'message_cart_enabled', false );
$this->settings->persist();
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway' );
wp_safe_redirect( $redirect_url, 302 );
exit;
}
/**
@ -442,19 +438,10 @@ class SettingsListener {
*/
private function is_valid_site_request() : bool {
/**
* No nonce needed at this point.
*
* phpcs:disable WordPress.Security.NonceVerification.Missing
* phpcs:disable WordPress.Security.NonceVerification.Recommended
*/
if ( empty( $this->page_id ) ) {
return false;
}
// phpcs:enable WordPress.Security.NonceVerification.Missing
// phpcs:enable WordPress.Security.NonceVerification.Recommended
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return false;
}