0

I'm developing a custom WooCommerce payment gateway plugin.

However, I'm having one issue in the http://website/my-account page.

The registered token payment methods is not listing properly all data in http://website/my-account/payment-methods page.

From the payment-methods.php I can see that in the code payment methods are listed based on the wc_get_account_payment_methods_columns() function.

However when I tried to echo the array, I don't see the payment method value of last4 listed in it - even the actual size is one.

I'm trying to look for more documentation, however I haven't found the solution yet.

Is it something that I need to explicitly trigger when adding new payment-method / checkout using new payment method apart from saving the payment token?

Thanks!

0

This issue was due to i override the type of token when extending WC_Payment_Token_CC, to avoid this i need to remove the type override. Everything will display properly. This is due to WooCommerce framework will not assign the last4 value when the type is not == "cc"

function wc_get_account_saved_payment_methods_list_item_cc( $item, $payment_token ) {
if ( 'cc' !== strtolower( $payment_token->get_type() ) ) {
    return $item;
}

$card_type               = $payment_token->get_card_type();
$item['method']['last4'] = $payment_token->get_last4();
$item['method']['brand'] = ( ! empty( $card_type ) ? ucfirst( $card_type ) : esc_html__( 'Credit card', 'woocommerce' ) );
$item['expires']         = $payment_token->get_expiry_month() . '/' . substr( $payment_token->get_expiry_year(), -2 );

return $item;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.