Exemple #1
0
 /**
  * Contact anet and attempt to refund the payment
  * @see ApplyPaymentInterface::refundPayment()
  */
 public function refundPayment(\Jazzee\Entity\Payment $payment, \Foundation\Form\Input $input)
 {
     $aim = new \AuthorizeNetAIM($this->_paymentType->getVar('gatewayId'), $this->_paymentType->getVar('gatewayKey'));
     $aim->setSandBox($this->_paymentType->getVar('testAccount'));
     //test accounts get sent to the sandbox
     $aim->test_request = $this->_controller->getConfig()->getStatus() == 'PRODUCTION' ? 0 : 1;
     $aim->zip = $input->get('zip');
     $response = $aim->credit($payment->getVar('transactionId'), $payment->getAmount(), $input->get('cardNumber'));
     if ($response->approved) {
         $payment->refunded();
         $payment->setVar('refundedReason', $input->get('refundedReason'));
         return true;
     } else {
         return "Unable to submit refund for transaction #{$payment->getVar('transactionId')} authorize.net said: " . $response->getMessageText();
     }
     return false;
 }