/** * Get the payment method title for a given token, e.g: * * <Amex logo> American Express ending in 6666 * * @since 4.0.0 * @param SV_WC_Payment_Gateway_Payment_Token $token token * @return string payment method title */ protected function get_payment_method_title($token) { $image_url = $token->get_image_url(); $last_four = $token->get_last_four(); $type = $token->get_type_full(); if ($image_url) { // format like "<Amex logo image> American Express" $title = sprintf('<img src="%1$s" alt="%2$s" title="%2$s" width="40" height="25" />%3$s', esc_url($image_url), esc_attr__($type, $this->get_plugin()->get_text_domain()), esc_html__($type, $this->get_plugin()->get_text_domain())); } else { // missing payment method image, format like "American Express" $title = esc_html__($type, $this->get_plugin()->get_text_domain()); } // add "ending in XXXX" if available if ($last_four) { $title .= ' ' . sprintf(__('ending in %s', $this->get_plugin()->get_text_domain()), $last_four); } // add "(default)" if token is set as default if ($token->is_default()) { $title .= ' ' . __('(default)', $this->get_plugin()->get_text_domain()); } return apply_filters('wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_title', $title, $token, $this); }
/** * Get the order note message when a customer saves their payment method * to their account * * @since 4.1.2 * @param \SV_WC_Payment_Gateway_Payment_Token $token the payment token being saved * @return string */ protected function get_saved_payment_token_order_note($token) { $message = ''; // order note based on gateway type if ($this->is_credit_card_gateway()) { /* translators: Placeholders: %1$s - payment gateway title (such as Authorize.net, Braintree, etc), %2$s - payment method name (mastercard, bank account, etc), %3$s - last four digits of the card/account, %4$s - card/account expiry date */ $message = sprintf(__('%1$s Payment Method Saved: %2$s ending in %3$s (expires %4$s)', 'woocommerce-plugin-framework'), $this->get_method_title(), $token->get_type_full(), $token->get_last_four(), $token->get_exp_date()); } elseif ($this->is_echeck_gateway()) { // account type (checking/savings) may or may not be available, which is fine /* translators: Placeholders: %1$s - payment gateway title (such as CyberSouce, NETbilling, etc), %2$s - account type (checking/savings - may or may not be available), %3$s - last four digits of the account */ $message = sprintf(__('%1$s eCheck Payment Method Saved: %2$s account ending in %3$s', 'woocommerce-plugin-framework'), $this->get_method_title(), $token->get_account_type(), $token->get_last_four()); } return $message; }
/** * Get the title for a saved payment method, like * * <Amex logo> American Express ending in 6666 (expires 10/20) * * @since 4.0.0 * @param SV_WC_Payment_Gateway_Payment_Token $token payment token * @return string saved payment method title */ protected function get_saved_payment_method_title($token) { $image_url = $token->get_image_url(); $last_four = $token->get_last_four(); $type = $token->get_type_full(); if ($image_url) { // format like "<Amex logo image> American Express" $title = sprintf('<img src="%1$s" alt="%2$s" title="%2$s" width="30" height="20" style="width: 30px; height: 20px;" />%3$s', esc_url($image_url), esc_attr__($type, 'woocommerce-plugin-framework'), esc_html__($type, 'woocommerce-plugin-framework')); } else { // missing payment method image, format like "American Express" $title = esc_html__($type, 'woocommerce-plugin-framework'); } // add "ending in XXXX" if available if ($last_four) { /* translators: Placeholders: %s - last four digits of card/account */ $title .= ' ' . sprintf(esc_html__('ending in %s', 'woocommerce-plugin-framework'), $last_four); } // add "(expires MM/YY)" if available if ($token->get_exp_month() && $token->get_exp_year()) { /* translators: Placeholders: %s - expiry date */ $title .= ' ' . sprintf(esc_html__('(expires %s)', 'woocommerce-plugin-framework'), $token->get_exp_date()); } /** * Payment Gateway Payment Form Payment Method Title. * * Filters the text/HTML rendered for a saved payment method, like "Amex ending in 6666". * * @since 4.0.0 * @param string $title * @param \SV_WC_Payment_Gateway_Payment_Token $token * @param \SV_WC_Payment_Gateway_Payment_Form $this payment form instance */ return apply_filters('wc_' . $this->get_gateway()->get_id() . '_payment_form_payment_method_title', $title, $token, $this); }
/** * Get the payment method title for a given token, e.g: * * <Amex logo> American Express ending in 6666 * * @since 4.0.0 * @param SV_WC_Payment_Gateway_Payment_Token $token token * @return string payment method title */ protected function get_payment_method_title($token) { $image_url = $token->get_image_url(); $last_four = $token->get_last_four(); $type = $token->get_type_full(); if ($image_url) { // format like "<Amex logo image> American Express" $title = sprintf('<img src="%1$s" alt="%2$s" title="%2$s" width="40" height="25" />%3$s', esc_url($image_url), esc_attr__($type, 'woocommerce-plugin-framework'), esc_html__($type, 'woocommerce-plugin-framework')); } else { // missing payment method image, format like "American Express" $title = esc_html__($type, 'woocommerce-plugin-framework'); } // add "ending in XXXX" if available if ($last_four) { /* translators: %s - last four digits of a card/account */ $title .= ' ' . sprintf(esc_html__('ending in %s', 'woocommerce-plugin-framework'), $last_four); } // add "(default)" if token is set as default if ($token->is_default()) { $title .= ' ' . esc_html__('(default)', 'woocommerce-plugin-framework'); } /** * My Payment Methods Table Method Title Filter. * * Allow actors to modify the table method title. * * @since 4.0.0 * @param string $title payment method title * @param \SV_WC_Payment_Gateway_Payment_Token $token token object * @param \SV_WC_Payment_Gateway_My_Payment_Methods $this instance */ return apply_filters('wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_title', $title, $token, $this); }