get_id(); $order = wc_get_order( $order_id ); if ( ! $order ) { return $payment_method_title; } $payment_method_id = $order->get_payment_method(); if ( stripos( $payment_method_id, 'woocommerce_payments' ) !== 0 ) { return $payment_method_title; } // If this is a WooPay order, return the html for the WooPay payment method name. if ( $order->get_meta( 'is_woopay' ) ) { return $this->show_woopay_payment_method_name( $order ); } $gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method_id ]; if ( ! is_object( $gateway ) || ! method_exists( $gateway, 'get_payment_method' ) ) { return $payment_method_title; } $payment_method = $gateway->get_payment_method( $order ); // GooglePay/ApplePay/Link/Card to be supported later. if ( $payment_method->get_id() === Payment_Method::CARD ) { return $this->show_card_payment_method_name( $order, $payment_method ); } // If this is an LPM (BNPL or local payment method) order, return the html for the payment method name. $name_output = $this->show_lpm_payment_method_name( $gateway, $payment_method ); if ( false !== $name_output ) { return $name_output; } return $payment_method_title; } /** * Returns the HTML to add the card brand logo and the last 4 digits of the card used to the * payment method name on the order received page. * * @param WC_Order $order the order being shown. * @param WCPay\Payment_Methods\UPE_Payment_Method $payment_method the payment method being shown. * * @return string */ public function show_card_payment_method_name( $order, $payment_method ) { $card_brand = $order->get_meta( '_card_brand' ); if ( ! $card_brand ) { return $payment_method->get_title(); } ob_start(); ?>
WooPay get_meta( 'last4' ) ) { echo esc_html_e( 'Card ending in', 'woocommerce-payments' ) . ' '; echo esc_html( $order->get_meta( 'last4' ) ); } ?>
get_payment_method_icon_for_location( 'checkout', false, $gateway->get_account_country() ), $payment_method->get_id(), ], '8.5.0', 'wc_payments_thank_you_page_lpm_payment_method_logo_url' ); $method_logo_url = apply_filters( 'wc_payments_thank_you_page_lpm_payment_method_logo_url', $method_logo_url, $payment_method->get_id() ); // If we don't have a logo URL here for some reason, bail. if ( ! $method_logo_url ) { return false; } ob_start(); ?> format_addtional_thankyou_order_received_text( __( 'We detected and prevented an attempt to pay for a duplicate order. If this was a mistake and you wish to try again, please create a new order.', 'woocommerce-payments' ) ); } return $text; } /** * Add the notice to the thank you page in case an existing intention was successful for the order. * * @param string $text the default thank you text. * * @return string */ public function add_notice_previous_successful_intent( $text ) { if ( isset( $_GET[ Duplicate_Payment_Prevention_Service::FLAG_PREVIOUS_SUCCESSFUL_INTENT ] ) ) { // phpcs:disable WordPress.Security.NonceVerification.Recommended $text .= $this->format_addtional_thankyou_order_received_text( __( 'We prevented multiple payments for the same order. If this was a mistake and you wish to try again, please create a new order.', 'woocommerce-payments' ) ); } return $text; } /** * Formats the additional text to be displayed on the thank you page, with the side effect * as a workaround for an issue in Woo core 8.1.x and 8.2.x. * * @param string $additional_text The additional text to be displayed. * * @return string Formatted text. */ private function format_addtional_thankyou_order_received_text( string $additional_text ): string { /** * This condition is a workaround for Woo core 8.1.x and 8.2.x as it formatted the filtered text, * while it should format the original text only. * * It's safe to remove this conditional when WooPayments requires Woo core 8.3.x or higher. * * @see https://github.com/woocommerce/woocommerce/pull/39758 Introduce the issue since 8.1.0. * @see https://github.com/woocommerce/woocommerce/pull/40353 Fix the issue since 8.3.0. */ if ( version_compare( WC_VERSION, '8.0', '>' ) && version_compare( WC_VERSION, '8.3', '<' ) ) { echo " "; return ' ' . $additional_text; } return sprintf( '
%s
', $additional_text ); } /** * Enqueue style to the order success page */ public function enqueue_scripts() { if ( ! is_order_received_page() ) { return; } WC_Payments_Utils::enqueue_style( 'wcpay-success-css', plugins_url( 'assets/css/success.css', WCPAY_PLUGIN_FILE ), [], WC_Payments::get_file_version( 'assets/css/success.css' ), 'all', ); } /** * Make sure we show the TYP page for orders paid with WooPay * that create new user accounts, code mainly copied from * WooCommerce WC_Shortcode_Checkout::order_received and * WC_Shortcode_Checkout::guest_should_verify_email. * * @param bool $value The current value for this filter. */ public function determine_woopay_order_received_verify_known_shoppers( $value ) { global $wp; $order_id = $wp->query_vars['order-received']; $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( wp_unslash( $_GET['key'] ) ) ); $order = wc_get_order( $order_id ); if ( ( ! $order instanceof WC_Order ) || ! $order->get_meta( 'is_woopay' ) || ! hash_equals( $order->get_order_key(), $order_key ) ) { return $value; } $verification_grace_period = (int) apply_filters( 'woocommerce_order_email_verification_grace_period', 10 * MINUTE_IN_SECONDS, $order ); $date_created = $order->get_date_created(); // We do not need to verify the email address if we are within the grace period immediately following order creation. $is_within_grace_period = is_a( $date_created, \WC_DateTime::class, true ) && time() - $date_created->getTimestamp() <= $verification_grace_period; return ! $is_within_grace_period; } }