Пример #1
0
 /**
  * Parse the transaction results sent from Authorize.net Direct Post
  * @param \TransactionController $controller
  */
 public static function transaction($controller)
 {
     $matches = array();
     preg_match('#page/(\\d{1,})/?#', $_POST['redirect_url'], $matches);
     if (!isset($matches[1])) {
         throw new \Jazzee\Exception("No page id match found in redirect_url: '{$_POST['redirect_url']}");
     }
     $applicationPage = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\ApplicationPage')->find($matches[1]);
     if (!$applicationPage) {
         throw new \Jazzee\Exception("{$matches[1]} is not a valid applicationPage id");
     }
     if (!empty($_POST['x_cust_id'])) {
         $applicant = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\Applicant')->find($_POST['x_cust_id']);
         if (!$applicant) {
             throw new \Jazzee\Exception("{$_POST['x_cust_id']} is not a valid applicant id.  Anet post: " . var_export($_POST, true));
         }
         $answer = new \Jazzee\Entity\Answer();
         $answer->setPage($applicationPage->getPage());
         $applicant->addAnswer($answer);
         $payment = new \Jazzee\Entity\Payment();
         $payment->setType($controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\PaymentType')->find($_POST['paymentType']));
         $answer->setPayment($payment);
         $fakeInput = new \Foundation\Form\Input(array());
         if ($payment->getType()->getJazzeePaymentType($controller)->pendingPayment($payment, $fakeInput)) {
             $controller->getEntityManager()->persist($applicant);
             $controller->getEntityManager()->persist($answer);
             $controller->getEntityManager()->persist($payment);
             foreach ($payment->getVariables() as $var) {
                 $controller->getEntityManager()->persist($var);
             }
             $controller->getEntityManager()->flush();
             print \AuthorizeNetDPM::getRelayResponseSnippet($_POST['redirect_url']);
         }
     }
 }
Пример #2
0
 /**
  * Parse the transaction results sent from cashnet
  * @param \TransactionController $controller
  */
 public static function transaction($controller)
 {
     if (empty($_POST['ref1val1']) or empty($_POST['ref2val1'])) {
         throw new \Jazzee\Exception("refval1 or refval2 not set by cashnet.  Cashnet post: " . var_export($_POST, true));
     }
     $matches = array();
     preg_match('#page/(\\d{1,})/?#', $_POST['ref2val1'], $matches);
     if (!isset($matches[1])) {
         throw new \Jazzee\Exception("No page id match found in ref2val1: '{$_POST['ref2val1']}'");
     }
     $applicationPage = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\ApplicationPage')->find($matches[1]);
     if (!$applicationPage) {
         throw new \Jazzee\Exception("{$matches[1]} is not a valid applicationPage id");
     }
     $applicant = $controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\Applicant')->find($_POST['ref1val1']);
     if (!$applicant) {
         throw new \Jazzee\Exception("{$_POST['ref1val1']} is not a valid applicant id.  Cashnet post: " . var_export($_POST, true));
     }
     $answer = new \Jazzee\Entity\Answer();
     $answer->setPage($applicationPage->getPage());
     $applicant->addAnswer($answer);
     $payment = new \Jazzee\Entity\Payment();
     $payment->setType($controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\PaymentType')->findOneBy(array('class' => get_called_class())));
     $answer->setPayment($payment);
     $input = new \Foundation\Form\Input($_POST);
     if ($payment->getType()->getJazzeePaymentType($controller)->pendingPayment($payment, $input)) {
         $controller->getEntityManager()->persist($applicant);
         $controller->getEntityManager()->persist($answer);
         $controller->getEntityManager()->persist($payment);
         foreach ($payment->getVariables() as $var) {
             $controller->getEntityManager()->persist($var);
         }
         $controller->getEntityManager()->flush();
         header('Location: ' . $_POST['ref2val1']);
         die;
     }
     throw new \Jazzee\Exception("We were unable to record this payment.  Cashnet post: " . var_export($_POST, true));
 }