When a customer pays with a credit card, it should save the card type and last four digits of the credit card so that it can be displayed where needed.
My workaround is to add the following snippet in OrderProcessor.php before the end of the process(WC_Order $wc_order) function:
$card_brand = ”;
$last_digits = ”;
if (!is_null($order->payment_source()) && !is_null($order->payment_source()->card()))
{
$card_brand = $order->payment_source()->card()->brand();
$last_digits = $order->payment_source()->card()->last_digits();
}
if (!empty($card_brand) && !empty($last_digits)) {
$wc_order->update_meta_data( ‘payment_cc_info’, $card_brand . ” *” . $last_digits);
$wc_order->save();
}
I then get the payment_cc_info meta data where needed.
This is obviously not the best way to handle it and requires a modification every time the plugin updates so an official way to handle this would be appreciated.
Open
Last updated: January 3, 2024
0 comments
Log in to comment on this feature request.