1

I wanna get the credit card number when the user hit the place order button. Right now I am using this event: sales_order_save_before and using this code to get the card number but gets no value. It's possible???

NOTE: I am using authorize.net and direct post payment methods.

$session  = Mage::getSingleton('checkout/session');
            $quote_id = $session->getQuoteId();
            $quote  = Mage::getModel('sales/quote')->load($quote_id );
            $paymentData = $quote->getPayment()->getData();
            $cc_number = Mage::getModel('payment/info')->decrypt($paymentData['cc_number_enc']);
            echo $cc_number;  // getting no value here!!!
1

No, you can retrieve only last four credit card digits from order.

If you just need to full credit card number. Please purchase an extension from Magento 2 marketplace

//***if orderid=1001;***

$orderId=1001;
$order = $this->order->load($orderId);
$expmonth=$order->getPayment()->getCcExpMonth();   *//get expirymonth* 
$expyear=$order->getPayment()->getCcExpYear();      *//get expiryyear*
$cclast4=$order->getPayment()->getCcLast4();        *//get expiry last four digit from card*  

It worked like charm

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.