/** * Refund the amount * Need to decode last 4 digits for request. * * @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment * @param float $amount * @return $this * @throws \Exception */ public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount) { $last4 = $payment->getCcLast4(); $payment->setCcLast4($payment->decrypt($last4)); try { $this->processRefund($payment, $amount); } catch (\Exception $e) { $payment->setCcLast4($last4); throw $e; } $payment->setCcLast4($last4); return $this; }