get_payment_method() !== 'woocommerce_payments_' . Payment_Method::MULTIBANCO || 'on-hold' !== $order->get_status() ) { return; } $order_service = WC_Payments::get_order_service(); $multibanco_info = $order_service->get_multibanco_info_from_order( $order ); $unix_expiry = $multibanco_info['expiry']; $expiry_date = date_i18n( wc_date_format() . ' ' . wc_time_format(), $unix_expiry ); $days_remaining = max( 0, floor( ( $unix_expiry - time() ) / DAY_IN_SECONDS ) ); $formatted_order_total = $order->get_formatted_order_total(); wc_print_notice( __( 'Your order is on hold until payment is received. Please follow the payment instructions by the expiry date.', 'woocommerce-payments' ), 'notice' ); ?>
<?php esc_attr_e( 'Multibanco', 'woocommerce-payments' ); ?>
get_order_number() ) ); ?>
%s', 'woocommerce-payments' ), [ 'strong' => '', ] ), esc_html( $expiry_date ) ); ?>

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 ); } // Check if this is an Express Checkout payment (Google Pay, Apple Pay, etc.). $express_checkout_payment_method = $order->get_meta( '_wcpay_express_checkout_payment_method' ); if ( ! empty( $express_checkout_payment_method ) ) { return $this->show_express_checkout_payment_method_name( $order, $express_checkout_payment_method ); } $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 ); // Link payments go through the card gateway (woocommerce_payments), so the gateway's // payment method is 'card'. Detect Link by checking the order's payment tokens. if ( Payment_Method::CARD === $payment_method->get_id() ) { $token_ids = $order->get_payment_tokens(); if ( ! empty( $token_ids ) ) { $last_token = \WC_Payment_Tokens::get( end( $token_ids ) ); if ( $last_token instanceof \WC_Payment_Token_WCPay_Link ) { $link_pm = WC_Payments::get_payment_method_by_id( Payment_Method::LINK ); if ( $link_pm ) { $payment_method = $link_pm; } } } } // Handle card payments. if ( Payment_Method::CARD === $payment_method->get_id() ) { 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 Express Checkout payment method logo and 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 string $express_checkout_payment_method the express checkout payment method (e.g., 'google_pay', 'apple_pay'). * * @return string */ public function show_express_checkout_payment_method_name( $order, $express_checkout_payment_method ) { $payment_method = WC_Payments::get_payment_method_by_id( $express_checkout_payment_method ); if ( ! $payment_method ) { return 'Payment Request'; } $icon_url = $payment_method->get_icon(); $dark_icon_url = $payment_method->get_dark_icon(); $dark_attr = $dark_icon_url !== $icon_url ? ' data-dark-src="' . esc_url_raw( $dark_icon_url ) . '"' : ''; ob_start(); ?> 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_account_country(); $method_logo_url = apply_filters_deprecated( 'wc_payments_thank_you_page_bnpl_payment_method_logo_url', [ $payment_method->get_icon( $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; } $dark_icon_url = $payment_method->get_dark_icon( $account_country ); $dark_attr = $dark_icon_url !== $method_logo_url ? ' data-dark-src="' . esc_url_raw( $dark_icon_url ) . '"' : ''; 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; } /** * Replace the order received text with a failure message when the order status is 'failed'. * * @param string $text The original thank you text. * @return string */ public function replace_order_received_text_for_failed_orders( $text ) { global $wp; $order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ?? 0 ) ); $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( wp_unslash( $_GET['key'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $order = false; if ( $order_id > 0 ) { $order = wc_get_order( $order_id ); if ( ! $order instanceof WC_Order || ! hash_equals( $order->get_order_key(), $order_key ) ) { $order = false; } } if ( ! $order || ! $order->needs_payment() || 0 !== strpos( $order->get_payment_method(), WC_Payment_Gateway_WCPay::GATEWAY_ID ) ) { return $text; } $intent_id = $order->get_meta( '_intent_id', true ); $payment_method = $order->get_payment_method(); // Strip the gateway ID prefix from the payment method. $payment_method_type = str_replace( WC_Payment_Gateway_WCPay::GATEWAY_ID . '_', '', $payment_method ); $should_show_failure = false; // Check order status first to avoid unnecessary API calls. if ( $order->has_status( Order_Status::FAILED ) ) { $should_show_failure = true; } elseif ( ! empty( $intent_id ) && ! empty( $payment_method_type ) && in_array( $payment_method_type, Payment_Method::REDIRECT_PAYMENT_METHODS, true ) ) { // For redirect-based payment methods that haven't been marked as failed yet, check the intent status. // Add a small delay to allow the intent to be updated. sleep( 1 ); $intent = Get_Intention::create( $intent_id ); $intent = $intent->send(); $intent_status = $intent->get_status(); if ( Intent_Status::REQUIRES_PAYMENT_METHOD === $intent_status && $intent->get_last_payment_error() ) { $should_show_failure = true; } } if ( $should_show_failure ) { // Store the failure state to use in wp_footer. $this->should_hide_status_description = true; $checkout_url = wc_get_checkout_url(); return sprintf( /* translators: %s: checkout URL */ __( 'Unfortunately, your order has failed. Please try checking out again.', 'woocommerce-payments' ), esc_url( $checkout_url ) ); } return $text; } /** * Output any necessary footer scripts */ public function output_footer_scripts() { if ( ! empty( $this->should_hide_status_description ) ) { echo " "; } if ( is_order_received_page() || is_view_order_page() ) { $this->output_dark_icon_swap_script(); } } /** * Enqueue style to the order success page */ public function enqueue_scripts() { if ( ! is_order_received_page() && ! is_view_order_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', ); WC_Payments::register_script_with_dependencies( 'WCPAY_SUCCESS_PAGE', 'dist/success', [] ); wp_set_script_translations( 'WCPAY_SUCCESS_PAGE', 'woocommerce-payments' ); wp_enqueue_script( 'WCPAY_SUCCESS_PAGE' ); } /** * 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; } /** * Add Multibanco payment instructions to the order on-hold email. * * @param WC_Order|mixed $order The order object. * @param bool|mixed $sent_to_admin Whether the email is being sent to the admin. * @param bool|mixed $plain_text Whether the email is plain text. * @param WC_Email|string $email The email object. */ public function add_multibanco_payment_instructions_to_order_on_hold_email( $order, $sent_to_admin = false, $plain_text = false, $email = '' ): void { if ( ! $email instanceof WC_Email_Customer_On_Hold_Order || ! $order || $order->get_payment_method() !== 'woocommerce_payments_' . Payment_Method::MULTIBANCO ) { return; } $order_service = WC_Payments::get_order_service(); $multibanco_info = $order_service->get_multibanco_info_from_order( $order ); $unix_expiry = $multibanco_info['expiry']; $expiry_date = date_i18n( wc_date_format() . ' ' . wc_time_format(), $unix_expiry ); $formatted_order_total = $order->get_formatted_order_total(); if ( $plain_text ) { echo "----------------------------------------\n"; echo esc_html__( 'Multibanco Payment instructions', 'woocommerce-payments' ) . "\n\n"; printf( /* translators: %s: expiry date */ esc_html__( 'Expires %s', 'woocommerce-payments' ) . "\n\n", esc_html( $expiry_date ) ); echo '1. ' . esc_html__( 'In your online bank account or from an ATM, choose "Payment and other services".', 'woocommerce-payments' ) . "\n"; echo '2. ' . esc_html__( 'Click "Payments of services/shopping".', 'woocommerce-payments' ) . "\n"; echo '3. ' . esc_html__( 'Enter the entity number, reference number, and amount.', 'woocommerce-payments' ) . "\n\n"; echo esc_html__( 'Entity', 'woocommerce-payments' ) . ': ' . esc_html( $multibanco_info['entity'] ) . "\n"; echo esc_html__( 'Reference', 'woocommerce-payments' ) . ': ' . esc_html( $multibanco_info['reference'] ) . "\n"; echo esc_html__( 'Amount', 'woocommerce-payments' ) . ': ' . esc_html( wp_strip_all_tags( $formatted_order_total ) ) . "\n"; echo "----------------------------------------\n\n"; } else { ?>
<?php esc_attr_e( 'Multibanco', 'woocommerce-payments' ); ?>
get_order_number() ) ); ?>
%s', 'woocommerce-payments' ), [ 'strong' => '', ] ), esc_html( $expiry_date ) ); ?>

' ) && version_compare( WC_VERSION, '8.3', '<' ) ) { echo " "; return ' ' . $additional_text; } return sprintf( '
%s
', $additional_text ); } }