Exemple #1
0
 /**
  * Set payment
  *
  * @param \Jazzee\Entity\Payment $payment
  */
 public function setPayment(\Jazzee\Entity\Payment $payment)
 {
     $this->payment = $payment;
     if ($payment->getAnswer() != $this) {
         $payment->setAnswer($this);
     }
 }
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
 /**
  * Record transaction information pending until it is settled with the bank
  */
 public function pendingPayment(\Jazzee\Entity\Payment $payment, \Foundation\Form\Input $input)
 {
     if (\is_a($this->_controller, 'ApplyPageController')) {
         $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->amount = $input->get('amount');
         $aim->cust_id = $payment->getAnswer()->getApplicant()->getId();
         $aim->customer_ip = $_SERVER['REMOTE_ADDR'];
         $aim->email = $payment->getAnswer()->getApplicant()->getEmail();
         $aim->email_customer = 0;
         $aim->card_num = $input->get('cardNumber');
         $aim->exp_date = $input->get('expirationDate');
         $aim->card_code = $input->get('cardCode');
         $aim->zip = $input->get('postalCode');
         $aim->description = $this->_paymentType->getVar('description');
         $aim->test_request = $this->_controller->getConfig()->getStatus() == 'PRODUCTION' ? 0 : 1;
         $response = $aim->authorizeAndCapture();
         if ($response->approved) {
             $payment->setAmount($response->amount);
             $payment->setVar('transactionId', $response->transaction_id);
             $payment->setVar('authorizationCode', $response->authorization_code);
             $payment->pending();
             return true;
         } else {
             $payment->setAmount($response->amount);
             $payment->setVar('transactionId', $response->transaction_id);
             $payment->setVar('rejectedReasonCode', $response->response_reason_code);
             $payment->setVar('rejectedReason', $response->response_reason_text);
             $payment->rejected();
             return false;
         }
     } else {
         if (\is_a($this->_controller, 'ApplicantsSingleController')) {
             $transactionDetails = new \AuthorizeNetTD($this->_paymentType->getVar('gatewayId'), $this->_paymentType->getVar('gatewayKey'));
             $transactionDetails->setSandBox($this->_paymentType->getVar('testAccount'));
             //test accounts get sent to the sandbox
             // Get Transaction Details
             $transactionId = $input->get('transactionId');
             $response = $transactionDetails->getTransactionDetails($transactionId);
             if (!$response->response or $response->isError()) {
                 throw new \Jazzee\Exception("Unable to get transaction details for transcation id {$transactionId}", E_ERROR, 'There was a problem getting payment information.');
             }
             if ((int) $response->xml->transaction->customer->id != $payment->getAnswer()->getApplicant()->getId()) {
                 throw new \Jazzee\Exception("Transaction {$transactionId} does not belong to applicant #" . $payment->getAnswer()->getApplicant()->getId());
             }
             if ((int) $response->xml->transaction->responseCode == 1) {
                 $payment->setAmount((string) $response->xml->transaction->authAmount);
                 $payment->setVar('transactionId', $transactionId);
                 $payment->setVar('authorizationCode', (string) $response->xml->transaction->authorization_code);
                 $payment->pending();
                 return true;
             }
             $payment->setAmount((string) $response->xml->transaction->authAmount);
             $payment->setVar('transactionId', (string) $response->xml->transaction->transid);
             $payment->setVar('rejectedReasonCode', (string) $response->xml->transaction->responseReasonCode);
             $payment->setVar('rejectedReason', (string) $response->xml->transaction->responseReasonDescription);
             $payment->rejected();
         }
     }
     return false;
 }