/** * Record transaction information pending */ public function pendingPayment(\Jazzee\Entity\Payment $payment, \Foundation\Form\Input $input) { if (\is_a($this->_controller, 'TransactionController')) { foreach ($payment->getAnswer()->getApplicant()->getAnswers() as $answer) { if ($existingPayment = $answer->getPayment()) { if ($existingPayment->getType() == $payment->getType() and $existingPayment->getVar('UCLA_REF_NO') == $input->get('UCLA_REF_NO')) { //UCLA double posts transactions so if we have already stored this answer then we shouldn't store it again. return false; } } } $payment->setAmount($input->get('amount1') ? $input->get('amount1') : 0); if ($input->get('result') == '0') { $payment->setVar('tx', $input->get('tx')); $payment->pending(); $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' => $payment->getVar('tx')); $results = $client->CASHNetSOAPRequestInquiry(array('inquiryParams' => $parameters)); $xml = new \SimpleXMLElement($results->CASHNetSOAPRequestInquiryResult); if ($xml->result != 0) { $this->_controller->log("Unable to get transaction details from cashnet for transaction: {$payment->getVar('tx')} for applicant {$payment->getAnswer()->getApplicant()->getId()}. Cashnet said: {$xml->respmessage}", \Monolog\Logger::ERROR); } else { if ($xml->transactions[0]->transaction->txno == $payment->getVar('tx') and $xml->transactions[0]->transaction->totalamount == $payment->getAmount()) { if (strtolower($xml->transactions[0]->transaction->txstatus) == 'c') { $payment->setVar('tx', $xml->transactions[0]->transaction->txno); $payment->settled(); } else { //for unspecified reasons sometimes a voided/cancled transaction gets sent, these need to be marked //as rejected. Its unclear if they would normally have a transaction 'result' or zero so we have to be carefull $payment->setVar('rejectedReason', $xml->transactions[0]->transaction->respmessage); $payment->rejected(); } } else { throw new \Jazzee\Exception("Transaction details differ between cashnet and payment for applicant {$payment->getAnswer()->getApplicant()->getId()}. Payment (TX: {$payment->getVar('tx')}, Ammount: {$payment->getAmount()}) Cashnet Payment (TX: {$xml->transactions[0]->transaction->txno}, Amount: {$xml->transactions[0]->transaction->totalamount}) "); } } } else { $payment->setVar('tx', $input->get('failedtx')); $payment->setVar('rejectedReason', $input->get('respmessage')); $payment->rejected(); } $payment->setVar('custcode', $input->get('custcode')); $payment->setVar('pmtcode', $input->get('pmtcode')); $payment->setVar('itemcode', $input->get('itemcode1')); $payment->setVar('UCLA_REF_NO', $input->get('UCLA_REF_NO')); } else { if (\is_a($this->_controller, 'ApplicantsSingleController')) { $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) { throw new \Jazzee\Exception("Unable to get transaction details from cashnet for transaction: {$input->get('transactionId')} for applicant {$payment->getAnswer()->getApplicant()->getId()}. Cashnet said: {$xml->respmessage}"); } $payment->setVar('tx', $xml->transactions[0]->transaction->txno); $payment->setAmount($xml->transactions[0]->transaction->totalamount); $payment->setVar('custcode', $xml->transactions[0]->transaction->custcode); $payment->setVar('pmtcode', $xml->transactions[0]->transaction->pmtcode); $payment->setVar('itemcode', $xml->transactions[0]->transaction->itemcode); foreach ($xml->transactions[0]->transaction->trefs->tref as $tref) { $payment->setVar($tref->reftype, $tref->refvalue); } if (strtolower($xml->transactions[0]->transaction->txstatus) == 'c') { $payment->settled(); } else { //for unspecified reasons sometimes a voided/cancled transaction gets sent, these need to be marked //as rejected. Its unclear if they would normally have a transaction 'result' or zero so we have to be carefull $payment->setVar('rejectedReason', $xml->transactions[0]->transaction->respmessage); $payment->rejected(); } } else { throw new \Jazzee\Exception("UCLACashNET::pendingPayment called form invalid controller: " . get_class($this->_controller)); } } return true; }