diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js index f00242f4e..bc83c736e 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/CheckoutBootstap.js @@ -84,9 +84,8 @@ class CheckoutBootstap { const currentPaymentMethod = getCurrentPaymentMethod(); const isPaypal = currentPaymentMethod === PaymentMethods.PAYPAL; const isCard = currentPaymentMethod === PaymentMethods.CARDS; - const isOXXO = currentPaymentMethod === PaymentMethods.OXXO; const isSavedCard = isCard && isSavedCardSelected(); - const isNotOurGateway = !isPaypal && !isCard && !isOXXO; + const isNotOurGateway = !isPaypal && !isCard; const isFreeTrial = PayPalCommerceGateway.is_free_trial_cart; const hasVaultedPaypal = PayPalCommerceGateway.vaulted_paypal_email !== ''; @@ -95,7 +94,6 @@ class CheckoutBootstap { setVisible(this.gateway.button.wrapper, isPaypal && !(isFreeTrial && hasVaultedPaypal)); setVisible(this.gateway.messages.wrapper, isPaypal && !isFreeTrial); setVisible(this.gateway.hosted_fields.wrapper, isCard && !isSavedCard); - setVisible('#ppcp-oxxo', isOXXO && !isSavedCard && !isPaypal); if (isPaypal && !isFreeTrial) { this.messages.render(); diff --git a/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php b/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php index fe143aa41..edfae0095 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php +++ b/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php @@ -78,11 +78,20 @@ class OXXO { array( $this, 'register_assets' ) ); - add_action( - 'woocommerce_review_order_after_payment', - function () { - echo ''; - } + add_filter( + 'woocommerce_thankyou_order_received_text', + function( string $message, WC_Order $order ) { + $payer_action = $order->get_meta( 'ppcp_oxxo_payer_action' ) ?? ''; + + $button = ''; + if ( $payer_action ) { + $button = '
'; + } + + return $message . ' ' . $button; + }, + 10, + 2 ); } diff --git a/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXOGateway.php b/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXOGateway.php index 8fb168769..69203d885 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXOGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXOGateway.php @@ -129,7 +129,6 @@ class OXXOGateway extends WC_Payment_Gateway { */ public function process_payment( $order_id ) { $wc_order = wc_get_order( $order_id ); - $wc_order->update_status( 'on-hold', __( 'Awaiting OXXO payment.', 'woocommerce-paypal-payments' ) ); $purchase_unit = $this->purchase_unit_factory->from_wc_order( $wc_order ); $payer_action = ''; diff --git a/modules/ppcp-webhooks/src/Handler/PaymentCapturePending.php b/modules/ppcp-webhooks/src/Handler/PaymentCapturePending.php index 18ebef228..27e8bdf29 100644 --- a/modules/ppcp-webhooks/src/Handler/PaymentCapturePending.php +++ b/modules/ppcp-webhooks/src/Handler/PaymentCapturePending.php @@ -17,6 +17,8 @@ use WP_REST_Response; */ class PaymentCapturePending implements RequestHandler { + use PrefixTrait; + /** * The logger. * @@ -74,6 +76,53 @@ class PaymentCapturePending implements RequestHandler { $this->logger->info( (string) wc_print_r( $resource, true ) ); + $order_id = isset( $request['resource']['custom_id'] ) + ? $this->sanitize_custom_id( $request['resource']['custom_id'] ) + : 0; + + if ( ! $order_id ) { + $message = sprintf( + // translators: %s is the PayPal webhook Id. + __( + 'No order for webhook event %s was found.', + 'woocommerce-paypal-payments' + ), + isset( $request['id'] ) ? $request['id'] : '' + ); + $this->logger->log( + 'warning', + $message, + array( + 'request' => $request, + ) + ); + $response['message'] = $message; + return rest_ensure_response( $response ); + } + + $wc_order = wc_get_order( $order_id ); + if ( ! is_a( $wc_order, \WC_Order::class ) ) { + $message = sprintf( + // translators: %s is the PayPal refund Id. + __( 'Order for PayPal refund %s not found.', 'woocommerce-paypal-payments' ), + isset( $request['resource']['id'] ) ? $request['resource']['id'] : '' + ); + $this->logger->log( + 'warning', + $message, + array( + 'request' => $request, + ) + ); + $response['message'] = $message; + return rest_ensure_response( $response ); + } + + if ( $wc_order->get_status() === 'pending' ) { + $wc_order->update_status('on-hold', __('Payment initiation was successful, and is waiting for the buyer to complete the payment.', 'woocommerce-paypal-payments')); + + } + $response['success'] = true; return new WP_REST_Response( $response ); }