Get last 4 digits from Credit card number magento 2.

You can get last 4 digits from a credit card using Magento 2 when you worked with payment method extension or modification to payment method.

You need last four digits to show the payment credit card number in customer order’s payment details.

For Display purpose, You can show last four digits as per below code snippets,

When you call the above method, $this->getCcLast4() you got the last four digits of cc number.

Output:
1111