I am trying to add payment-related information in the Order email on Magento 2. ( Last 4 digits of the card, expiry date of the card ).

2 Answers 2


It seems to me that expiration date is a sensitive data that shouldn't be sent threw an email ? But may be I'm wrong. Actually you probably doesn't have any place where this data is stored.

  • 1
    Yes. But last 4 digit was showing in admin order page. I would like to retrieve at least this data. is it possible ? Sep 29, 2021 at 16:38

Yes, you can retrieve credit card details from order object.

$order is of type Magento\Sales\Model\Order

The following methods get the credit card details:

  • Hi Patel , Thanks for the information. I checked this, it shows empty data. Sep 30, 2021 at 15:45
  • which object ur using for order can you please tell me Sep 30, 2021 at 17:39
  • Same object, that you mention on this. $order is of type Magento\Sales\Model\Order . I have used this on Observer (email_order_set_template_vars_before) and payment gateway Stripes. Oct 1, 2021 at 4:39

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.