<?php /*+********************************************************************************** * The contents of this file are subject to the vtiger CRM Public License Version 1.1 * ("License"); You may not use this file except in compliance with the License * The Original Code is: SalesPlatform Ltd * The Initial Developer of the Original Code is SalesPlatform Ltd. * All Rights Reserved. * If you have any questions or comments, please email: devel@salesplatform.ru ************************************************************************************/ require_once 'modules/SPCMLConnector/TransactionController.php'; require_once 'include/utils/VtlibUtils.php'; if (vtlib_isModuleActive("SPCMLConnector")) { $userName = $_SERVER['PHP_AUTH_USER']; $userPassword = $_SERVER['PHP_AUTH_PW']; $transactionController = new TransactionController($userName, $userPassword); $transactionStatus = $transactionController->startTransactionStep($_REQUEST); echo $transactionStatus; }
/** * 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']); } } }
/** * 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)); }