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;
 }
Exemple #2
0
 /**
  * Contact anet and attempt to refund the payment
  * @see ApplyPaymentInterface::refundPayment()
  */
 public function refundPayment(\Jazzee\Entity\Payment $payment, \Foundation\Form\Input $input)
 {
     $client = new \SoapClient(self::CASHNET_WSDL);
     $parameters = array('OperatorID' => $this->_paymentType->getVar('operatorId'), 'Password' => $this->_paymentType->getVar('operatorPassword'), 'VirtualDirectory' => $this->_controller->getConfig()->getStatus() == 'PRODUCTION' ? self::CASHNET_VIRTUALDIRECTORY : self::CASHNET_TEST_VIRTUALDIRECTORY, 'TransactionNo' => $input->get('transactionId'));
     $results = $client->CASHNetSOAPRequestInquiry(array('inquiryParams' => $parameters));
     $xml = new \SimpleXMLElement($results->CASHNetSOAPRequestInquiryResult);
     if ($xml->result != 0) {
         return "Unable to get refund transaction details from cashnet for payment: {$payment->getId()}, transaction: {$input->get('transactionId')} for applicant {$payment->getAnswer()->getApplicant()->getId()}.  Cashnet said: {$xml->respmessage}";
     }
     if ($xml->transactions[0]->transaction->txno == $input->get('transactionId')) {
         $payment->refunded();
         $payment->setVar('refundAmount', $xml->transactions[0]->transaction->totalamount);
         $payment->setVar('refundTransactionId', $xml->transactions[0]->transaction->txno);
         $payment->setVar('refundedReason', $input->get('refundedReason'));
         return true;
     } else {
         throw new \Jazzee\Exception("Transaction details differ between cashnet and payment: {$payment->getId()} for applicant {$payment->getAnswer()->getApplicant()->getId()}.");
     }
     return true;
 }
Exemple #3
0
 /**
  * Check payments are refunded outside Jazzee and then marked as refunded
  * @see ApplyPaymentInterface::refundPayment()
  */
 public function refundPayment(\Jazzee\Entity\Payment $payment, \Foundation\Form\Input $input)
 {
     $payment->refunded();
     $payment->setVar('refundedReason', $input->get('refundedReason'));
     return true;
 }