function getAndClearErrors() { $out = $this->WebSession->getArray("flashError"); if ($out) { $this->WebSession->setArray("flashError", array()); } return $out; }
public static function getInstance() { if (self::$instance == null) { self::$instance = new WebSession(); } return self::$instance; }
/** * get instance * * Falls die einzige Instanz noch nicht existiert, erstelle sie * Gebe die einzige Instanz dann zurück * * @return Singleton */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
function hoaTransactionAuthThenCapture() { $uniqueValue = get_unique_value(); $merchantAccountId = 'account-' . $uniqueValue; $merchantTransactionId = 't-' . $uniqueValue; if (fail_if_merchant_transaction_id_too_long($merchantTransactionId)) { return; } $merchantPaymentMethodId = 'pm-' . $uniqueValue; $creditCardAccount = '5454541111111111'; $paymentType = 'CreditCard'; $cvn = '111'; $exp = '201801'; $email = get_unique_value() . '@nomail.com'; $successUrl = 'http://good.com'; $errorUrl = 'http://bad.com'; $HOAmethod = 'Transaction_Auth'; $HOAurl = 'https://secure.prodtest.sj.vindicia.com/vws'; $HOAversion = '5.0'; $ipAddress = '127.0.0.1'; $name = 'John Vindicia'; $addr1 = '303 Twin Dolphin Drive'; $city = 'Redwood City'; $district = 'CA'; $postalCode = '94065'; $country = 'US'; #------------------------------------------------------------ #-Step 1- #-Step 1- Initialize the WebSession before the PaymentMethod #-Step 1- form is displayed to the user #-Step 1- # # Create a new WebSession object $webSession = new WebSession(); # Set the WebSession parameters $webSession->setReturnURL($successUrl); $webSession->setErrorURL($errorUrl); $webSession->setIpAddress($ipAddress); $webSession->setMethod($HOAmethod); $webSession->setVersion($HOAversion); #------------------------------------------------------------ # Set PrivateFormValues. These are hidden fields in the POST # that we want to protect from hacking. If the value in the # POST does not match the value set during initialization, # the WebSession.finalize will fail // $account_VID = $account->VID; // // $nameVals[0] = new NameValuePair(); // $nameVals[0]->setName('Account_VID'); // $nameVals[0]->setValue($account_VID); // so that we can use the existing account $tx_id = new NameValuePair(); $tx_id->setName('vin_Transaction_merchantTransactionId'); $tx_id->setValue($merchantTransactionId); // so that we can use the existing account # Your ID for this user $acct_id = new NameValuePair(); $acct_id->setName("vin_Account_merchantAccountId"); $acct_id->setValue($merchantAccountId); # Your ID for this PaymentMethod $paym_id = new NameValuePair(); $paym_id->setName("vin_PaymentMethod_merchantPaymentMethodId"); $paym_id->setValue($merchantPaymentMethodId); $pmt_type = new NameValuePair(); $pmt_type->setName("vin_PaymentMethod_type"); $pmt_type->setValue($paymentType); # Add the PrivateFormValues to the WebSession $webSession->setPrivateFormValues(array($tx_id, $acct_id, $paym_id, $pmt_type)); #------------------------------------------------------------ # Set any parameters specific for the Method we are # calling in the WebSession. # $minChargebackProbability = new NameValuePair(); $minChargebackProbability->setName("Transaction_Auth_minChargebackProbability"); $minChargebackProbability->setValue("70"); $dryRun = new NameValuePair(); $dryRun->setName("Transaction_Auth_dryRun"); $dryRun->setValue("false"); $sendEmailNotification = new NameValuePair(); $sendEmailNotification->setName("Transaction_Auth_sendEmailNotification"); $sendEmailNotification->setValue("true"); // Transaction_Auth takes in one more parameter - campaignCode // We can collect campaign code from the payment form and set // prior to WebSession.Finalize, or pass it in here prior to WebSession.Initialize. $campaign = 'CampaignXYZ'; // $campaignCodeNVP = new NameValuePair(); // $campaignCodeNVP->setName("Transaction_Auth_campaignCode"); // $campaignCodeNVP->setValue($campaign); $webSession->setMethodParamValues(array($sendEmailNotification, $minChargebackProbability, $dryRun)); # Initialize the WebSession # $response = $webSession->initialize(); # Check to see that the initialize succeeded # if ($response['returnCode'] == 200) { # The VID of the WebSession object serves as session id # $vin_WebSession_vid = $response['data']->session->getVID(); } else { print $response; return; } #------------------------------------------------------------ #-Step 2- #-Step 2- This is the payment method FORM and the HOA POST #-Step 2- # Fields on the checkout FORM # User supplied input // $post['vin_PaymentMethod_merchantPaymentMethodId'] = // $merchantPaymentMethodId; $post['vin_PaymentMethod_accountHolderName'] = $post['vin_PaymentMethod_billingAddress_name'] = $name; $post['vin_PaymentMethod_billingAddress_addr1'] = $addr1; $post['vin_PaymentMethod_billingAddress_city'] = $city; $post['vin_PaymentMethod_billingAddress_district'] = $district; $post['vin_PaymentMethod_billingAddress_postalCode'] = $postalCode; $post['vin_PaymentMethod_billingAddress_country'] = $country; $post['vin_Account_emailAddress'] = $email; $post['vin_PaymentMethod_creditCard_account'] = $creditCardAccount; $post['vin_PaymentMethod_creditCard_expirationDate'] = $exp; $post['vin_PaymentMethod_nameValues_cvn'] = $cvn; $post['vin_Transaction_transactionItems_0_sku'] = 'Item 1'; $post['vin_Transaction_transactionItems_0_name'] = 'Item 1 Description'; $post['vin_Transaction_transactionItems_0_price'] = '99'; $post['vin_Transaction_transactionItems_0_quantity'] = '1'; # Hidden fields in the checkout FORM # $post['vin_WebSession_vid'] = $vin_WebSession_vid; # Copy the BillingAddress to the ShippingAddress to improve # Chargeback dispute success. Visa will deny disputed Chargeback # for many reasons. A missing ShippingAddress, even though there # is nothing being shipped, is commonly one of those reasons. # This can be done with JavaScript on the checkout form. # $post['vin_Account_name'] = $post['vin_PaymentMethod_billingAddress_name']; $post['vin_Account_shippingAddress_name'] = $post['vin_PaymentMethod_billingAddress_name']; $post['vin_Account_shippingAddress_addr1'] = $post['vin_PaymentMethod_billingAddress_addr1']; $post['vin_Account_shippingAddress_city'] = $post['vin_PaymentMethod_billingAddress_city']; $post['vin_Account_shippingAddress_district'] = $post['vin_PaymentMethod_billingAddress_district']; $post['vin_Account_shippingAddress_county'] = $post['vin_PaymentMethod_billingAddress_county']; $post['vin_Account_shippingAddress_postalCode'] = $post['vin_PaymentMethod_billingAddress_postalCode']; $post['vin_Account_shippingAddress_country'] = $post['vin_PaymentMethod_billingAddress_country']; $post['vin_Account_shippingAddress_phone'] = $post['vin_PaymentMethod_billingAddress_phone']; // If you have a Campaign Code form value... //$post['Transaction_Auth_campaignCode'] = $campaign; # Create the curl command line for exec by looping through the # $post array # $curlopts = ""; foreach ($post as $name => $value) { $curlopts .= " --data-urlencode {$name}=\"{$value}\""; } # Do the POST # exec("curl -s {$curlopts} " . $HOAurl, $curlout, $curlret); #-Step 3----------------------------------------------------- #-Step 3- #-Step 3- This code should be on the returnURL page #-Step 3- #-Step 3- Nothing has been committed until the WebSession gets #-Step 3- finalized. This is done in the returnURL page code. For #-Step 3- example, the returnURL is a confirmation page and when #-Step 3- the user clicks a confirmation button the form action #-Step 3- is a page that performs all the actual finalize steps. #-Step 3- #------------------------------------------------------------ # This is only necessary for this CLI implementation. # # Flatten the output from exec so we can search it. The response # from a successful HOA POST should be a 302 page that contains # our returnURL with the WebSessionVID as the query string. # if (php_sapi_name() == "cli") { $curlresp = implode("\n", $curlout); } # #------------------------------------------------------------ # For CLI, use the WebSessionId we stored in the POST values # for curl. For everything else, retrieve the WebSessionId # from the URL query string on the redirect to the returnURL # if (php_sapi_name() == "cli") { $session_id = $post['vin_WebSession_vid']; } else { $session_id = $_GET['session_id']; } $campaignCode = $post['Transaction_Auth_campaignCode']; if ($campaignCode != null) { $fetchedWebSession = new WebSession(); $response = $fetchedWebSession->fetchByVid($session_id); $response_object = $response['data']; $return_code = $response['returnCode']; $websession = $response_object->session; if ($return_code != "200" || $websession->apiReturn->returnCode != "200") { print $response; } } $webSession = new WebSession(); $webSession->setVid($session_id); if ($campaignCode != null) { $campaignCodeNVP = new NameValuePair(); $campaignCodeNVP->setName("Transaction_Auth_campaignCode"); $campaignCodeNVP->setValue($campaignCode); $webSession->setMethodParamValues(array($campaignCodeNVP)); } $response = $webSession->finalize(); if ($response['returnCode'] != '200') { print $response['data']->session->apiReturn->returnCode . PHP_EOL; print $response['data']->session->apiReturn->returnString . PHP_EOL; } else { print "returnCode=" . $response['data']->session->apiReturn->returnCode . PHP_EOL; print "returnString=" . $response['data']->session->apiReturn->returnString . PHP_EOL; if ($response['data']->session->apiReturn->returnCode == "200") { $returnTransaction = $response['data']->session->apiReturnValues->transactionAuth->transaction; if ($returnTransaction->statusLog[0]->status == 'Authorized') { print "Transaction approved\n"; $captureTransaction = new Transaction(); $response = $captureTransaction->capture(array($returnTransaction)); print "returnCode=" . $response['returnCode'] . PHP_EOL; print "returnString=" . $response['returnString'] . PHP_EOL; if ($response['returnCode'] == 200) { $captureResults = $response['data']->results; foreach ($captureResults as $captureResult) { if ($captureResult->returnCode == 200) { print "Transaction with id " . $captureResult->merchantTransactionId . " was successfully captured"; } else { print "Transaction was not successfully captured. ReturnCode=" . $captureResult->returnCode; } } } else { print "Transactions were not successfully captured. ReturnCode=" . $response['returnCode']; } } else { if ($returnTransaction->statusLog[0]->status == 'Cancelled') { print "Transaction not approved \n"; print "Reason code is: "; print $returnTransaction->statusLog[0]->creditCardStatus->authCode; print "\n"; } else { print "Error: Unexpected transaction status\n"; } } } else { if ($response['data']->session->apiReturn->returnCode = "202") { print "Transaction cannot be processed due to taxes being temporarily unavailable\n"; } else { if ($response['data']->session->apiReturn->returnCode == "400") { print "Transaction cannot be processed due to data validation error\n"; } else { if ($response['data']->session->apiReturn->returnCode == "402") { print "Transaction cannot be processed due to transaction error\n"; } else { if ($response['data']->session->apiReturn->returnCode = "403") { print "Transaction cannot be processed due to high fraud potential\n"; } else { if ($response['data']->session->apiReturn->returnCode = "406") { print "Transaction cannot be processed due to Chargeback risk score being higher than minChargebackProbability\n"; } else { if ($response['data']->session->apiReturn->returnCode = "407") { print "Transaction cannot be processed due to Failed AVS policy evaluation\n"; } else { if ($response['data']->session->apiReturn->returnCode = "408") { print "Transaction cannot be processed due to Failed CVN policy evaluation\n"; } else { print "Error while making call to Vindicia CashBox\n"; } } } } } } } } } }
{ printHTMLContent('genStandalongJSBlock', array(genJSExistBoxWithCloseRedirect(WEB_JS_OKMSGBOX_ID, $GLOBALS['MOD_LANG']->getMessage('gl.txt.update.success'), WEB_ROOT . '/contact/'))); } /*============================ * Main execution *===========================*/ $modelContact = new AlertContact(); if (!empty($sendAct)) { $name = webDataFilter('p', 'name', 'string'); $email = webDataFilter('p', 'email', 'email'); $mobileArea = webDataFilter('p', 'mobileArea', 'string'); $mobile = webDataFilter('p', 'mobile', 'string'); $sp = webDataFilter('p', 'sp', 'string'); switch ($sendAct) { case 'add': $param = array("login_no" => WebSession::get(PRODUCT_ID, 'tno'), "name" => &$name, "email" => &$email, "mobile_area" => &$mobileArea, "mobile" => &$mobile, "sp" => &$sp); $result = $modelContact->addContact($param); if ($result['success'] === false) { $view['jsErrMsg'] =& $result['errmsg']; //show add UI using post data $action = 'addPost'; //no exit } else { //header("location: ".WEB_ROOT.'/contact/'); printSuccessMsgBox(); exit; } break; case 'modify': $param = array("name" => &$name, "email" => &$email, "mobile_area" => &$mobileArea, "mobile" => &$mobile, "sp" => &$sp); $result = $modelContact->updateContact(webDataFilter('p', 'ctno', 'int'), $param);
?> </div> <div id="fnc"></div> </div> <div class="clear"></div> <table id="swa-body" cellspacing="0" cellpadding="0" border="0"><tr> <td id="swa-body-left"> <div id="swa-nav" > <div id="menu" class="ui-menu"> <div class="menu-item" id="main"><div id="homeIcon"></div></div> <div class="menu-item" id="site"><div id="siteIcon"></div></div> <div class="menu-item" id="account"><div id="accountIcon"></div></div> <div class="menu-item" id="search"><div id="searchIcon"></div></div> <div class="menu-item" id="contact"><div id="contactIcon"></div></div> <?php if (WebSession::get(PRODUCT_ID, 'op') == WEB_APP_TYPE && WebSession::get(PRODUCT_ID, 'subacc') == '0') { echo <<<EOF <div class="menu-item" id="manager"><div id="acctmgrIcon"></div></div> EOF; } ?> <div class="menu-item" id="logout"><div id="logoutIcon"></div></div> </div> <!-- <div id="widget"></div> --> </div> </td> <td id="swa-body-right"><div id="swa-content"></div></td> </tr></table> <div class="clear"></div> <div id="swa-footer">
/*============================ * Include files * require_once() * include_once(), etc... *===========================*/ require_once UTILS_ROOT . "/utils_data_filter.php"; require_once UTILS_ROOT . "/util_time.php"; require_once DBMODEL_ROOT . '/class.msg_trans_log.php'; require_once SERVICE_ROOT . "/sms/SmartLightingSendSMS.php"; /*============================ * Public Variables *===========================*/ //SMS data passed by POST $m = webDataFilter('g', 'm', 'string'); $Sender = WebSession::get(PRODUCT_ID, 'tno'); $result = array('success' => true, 'errcode' => 0); $delay = 5; //waiting for 5 munites $maxtime = 60 * 5; $maxcounts = $maxtime / $delay; /*============================ * Public Functions *===========================*/ /*============================ * Main execution *===========================*/ $resultSMS = call_user_func($m, $Sender); if ($resultSMS['success'] === true) { if (APP_DEBUG_MODE == '1') { //return debug msg
*/ require_once 'system/include/app_init.inc'; /* * app common library, loaded after security check */ require_once SERVICE_ROOT . '/class.langHandler.php'; require_once PRODUCT_LIB_ROOT . '/common.php'; require_once PRODUCT_LIB_ROOT . '/class.moduleHandler.php'; /* * parse request & check module */ $MOD_ID = empty($MOD_ID) ? 'home' : $MOD_ID; if (!ModuleHandler::isModuleExists($MOD_ID)) { //redirect to home page if login already, or redirect to login page header('location: ' . WEB_ROOT); exit; } if (strcmp('login', $MOD_ID) != 0) { WebSession::put(PRODUCT_ID, 'last_mod_id', $MOD_ID); } /* * prepare page level variables * * please use $GLOBALS['MOD_ID'], $GLOBALS['MOD_LANG']... * to get the variables whitin module programs. */ $MOD_LANG = new WebLangHandler(ModuleHandler::getLangModuleName($MOD_ID), WEB_LANG, PRODUCT_LANG_ROOT); /* * call module controller */ require_once ModuleHandler::getModulePath($MOD_ID, PRODUCT_MODULES_ROOT);
$nvp7->setValue('CatchUp'); $nvp8 = new NameValuePair(); $nvp8->setName('Account_updatePaymentMethod_replaceOnAllAutoBills'); $nvp8->setValue('true'); $nvp9 = new NameValuePair(); $nvp9->setName('Account_updatePaymentMethod_ignoreAvsPolicy'); $nvp9->setValue('false'); $nvp10 = new NameValuePair(); $nvp10->setName('Account_updatePaymentMethod_ignoreCvnPolicy'); $nvp10->setValue('false'); $webSession->setMethodParamValues(array($nvp7, $nvp8, $nvp9, $nvp10)); $response = $webSession->initialize(); if ($response['returnCode'] == 200) { $sessionId = $response['data']->session->getVID(); return $sessionId; } // Add error checking and logging of soap ids }); //Example Method for WebSession Finalize $app->get('/wsfinalizeaccountupdatepaymentmethod', function (Request $request) use($app) { $webSession = new WebSession(); $websession_id = $request->query->get('vin_WebSession_VID'); $webSession->setVID($websession_id); $response = $webSession->finalize(); // Add error checking and logging of soap ids // Check all the response codes, log soap id. $paymentMethodVid = $response['data']->session->apiReturnValues->accountUpdatePaymentMethod->account->paymentMethods[0]->VID; return $paymentMethodVid; }); ?>
* @author Jorgen Horstink <*****@*****.**> * @copyright Copyright (c) 2010, Jorgen Horstink * @licency Apache License, Version 2.0 */ define('DEPLOYR_DIRECTORY', 'classes/deployR'); define('SESSION_DIRECTORY', 'classes/session'); define('COLLECTION_DIRECTORY', 'classes/collection'); set_include_path(get_include_path() . PATH_SEPARATOR . '/'); //require_once DEPLOYR_DIRECTORY . '/DeployRSession.php'; require_once DEPLOYR_DIRECTORY . '/DeployRClient.php'; require_once DEPLOYR_DIRECTORY . '/impl/DeployRBasicAuthentication.php'; require_once SESSION_DIRECTORY . '/WebSession.php'; require_once SESSION_DIRECTORY . '/SessionFactory.php'; // Added to .gitignore, contains the USERNAME, PASSWORD and DEPLOYR_URL constants require_once 'conf/conf.php'; SessionFactory::setInstance(WebSession::getInstance()); $session = SessionFactory::getInstance(); // Just for testing. $session->removeNamespace('deployr'); $session->removeNamespace('deployr_sessions'); try { // Injects a Session object to be able bind the current logged in user to the Client. $client = DeployRClient::createHttpClient(DEPLOYR_URL, $session); $client->open(); // Login checks if the user is already logged in. If so, the injected session object has a valid cookieId $client->login(new DeployRBasicAuthentication(USERNAME, PASSWORD)); // Use a named session. If the session already exists, it reuses the old named session. Otherwise it creates a new session. $pSession = $client->createSession('mySession'); $deployRExecution = $pSession->executeCode("myVector <- rnorm(100); png(\"myplot.png\"); plot(myVector); dev.off();", "myVector", "myplot.png"); $file = $deployRExecution->getFiles()->get("myplot.png"); echo "<img src='" . $file . "' />";
/* * cache user info * register session info and redirect to home page */ WebSession::destroy(PRODUCT_ID); $resultLogin = $modelSecurity->recordLogin($userInfo['login_no'], session_id(), getenv('REMOTE_ADDR')); if ($resultLogin['success'] === false) { errorAlert($resultLogin['errmsg']); } else { WebSession::put(PRODUCT_ID, 'pass', 1); WebSession::put(PRODUCT_ID, 'tid', $userInfo['login_id']); WebSession::put(PRODUCT_ID, 'tno', $userInfo['login_no']); WebSession::put(PRODUCT_ID, 'tna', $userInfo['first_name'] . ' ' . $userInfo['last_name']); WebSession::put(PRODUCT_ID, 'op', $userInfo['acc_type']); WebSession::put(PRODUCT_ID, 'sid', session_id()); WebSession::put(PRODUCT_ID, 'creater', $userInfo['creater']); //WebSession::put(PRODUCT_ID, 'level', 'customer'); WebSession::put(PRODUCT_ID, 'subacc', $userInfo['sub_acc']); WebSession::put(PRODUCT_ID, 'gno', $userInfo['group_no']); WebSession::put(PRODUCT_ID, 'mdno', $userInfo['master_dealer']); //redirect to home page header('location: ' . WEB_ROOT . '/home/'); exit; } } /*============================ * View Loading *===========================*/ $view['title'] = $GLOBALS['MOD_LANG']->getMessage('html.title', array(PRODUCT_NAME)); $view['footer'] = $GLOBALS['MOD_LANG']->getMessage('html.right', array(PRODUCT_RIGHT, PRODUCT_VERSION)); include "view/v_login.php";
$result_session = $modelSecurity->isSessionExists($cache_tno, session_id(), getenv('REMOTE_ADDR')); if ($result_session['success'] === false) { header('Location: ' . WEB_ROOT . '/logout/'); exit; } $isSessionExists = $result_session['data']; //check login pass if ($isSessionExists === false || WebSession::get(PRODUCT_ID, 'pass') != 1) { header('Location: ' . WEB_ROOT . '/logout/'); exit; } //auto logout ------Start (2 hour) WebSession::checkAutoLogout(PRODUCT_ID, TIME_OUT, false, WEB_ROOT . '/logout/'); //auto logout ------End\ } else { if (strcmp('login', $MOD_ID) == 0) { //if load login page and login already, redirect to home page if (WebSession::get(PRODUCT_ID, 'pass') == 1) { header('Location: ' . WEB_ROOT . '/'); exit; } } else { //load modules within $ESCAPE_MOD_ID } } } else { if (empty($MOD_ID) || !in_array($MOD_ID, $ESCAPE_MOD_ID)) { header('Location: ' . WEB_ROOT . '/login/'); exit; } }
function finalize_credit_card_AutoBill_then_transaction_auth_capture_Transaction_Items($websession_id) { $webSession = new WebSession(); $webSession->setVID($websession_id); $response = $webSession->finalize(); if ($response['returnCode'] != '200') { print $response; } # Note, finalize almost always returns a 200 returnCode. The real # test for success of the underlying API call is inspection of # the apiReturn and apiReturnValues objects # Parse out the return object from the method call # $apiReturnValues = $response['data']->session->apiReturnValues; # Check the returnCode of the method called. # See Returns for update method of AutoBill object in the API # Reference for possible returnCodes. # if ($response['data']->session->apiReturn->returnCode != "200") { //408 - AutoBill creation failed: CVV check failed //407 - AutoBill creation failed: AVS Check Failed //409 - AutoBill creation failed: AVS and CVV Check Failed //410 - AutoBill creation failed: AVS and CVV check could not be performed //402 - AutoBill creation failed: Card authorization failed //400 - AutoBill creation failed print $apiReturnValues; } else { //Get info from autobill transaction for use processing remaining cart items $autobill = $response['data']->session->apiReturnValues->autoBillUpdate->autobill; $account = $autobill->account; $paymentMethod = $autobill->paymentMethod; $transaction = new Transaction(); $transaction->setCurrency('USD'); $transaction->setSourcePaymentMethod($paymentMethod); $transaction->setAccount($account); $transaction->setShippingAddress($account->shippingAddress); // loop through the cart on server side to add items. $transaction_lineitem1 = new TransactionItem(); $transaction_lineitem1->setSku('club cover'); $transaction_lineitem1->setName('club cover'); $transaction_lineitem1->setPrice('4.99'); $transaction_lineitem1->setQuantity('1'); $transaction_lineitem2 = new TransactionItem(); $transaction_lineitem2->setSku('shipping'); $transaction_lineitem2->setName('shipping'); $transaction_lineitem2->setPrice('5.00'); $transaction_lineitem2->setQuantity('1'); $transaction_lineitem2->setTaxClassification('NT'); $lineitems = array($transaction_lineitem1, $transaction_lineitem2); $transaction->setTransactionItems($lineitems); $sendEmailNotification = false; $ignoreAvsPolicy = true; $ignoreCvnPolicy = true; $campaign = NULL; $dryrun = false; $response = $transaction->authCapture($sendEmailNotification, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaign, $dryrun); if ($response['returnCode'] != '200') { print $response['returnCode'] . PHP_EOL; print $response['returnString'] . PHP_EOL; } else { print "returnCode=" . $response['returnCode'] . PHP_EOL; print "returnString=" . $response['returnString'] . PHP_EOL; if ($response['returnCode'] == "200") { $returnTransaction = $response['data']->transaction; if ($returnTransaction->statusLog[0]->status == 'Authorized') { print "Transaction approved\n"; print "Transaction with id " . $returnTransaction->merchantTransactionId . " was successfully captured"; return $returnTransaction->merchantTransactionId; } else { if ($returnTransaction->statusLog[0]->status == 'Cancelled') { print "Transaction not approved \n"; print "Reason code is: "; print $returnTransaction->statusLog[0]->creditCardStatus->authCode; print "\n"; } else { print "Error: Unexpected transaction status\n"; } } } else { if ($response['returnCode'] == "202") { print "Transaction cannot be processed due to taxes being temporarily unavailable\n"; } else { if ($response['returnCode'] == "400") { print "Transaction cannot be processed due to data validation error\n"; } else { if ($response['returnCode'] == "402") { print "Transaction cannot be processed due to transaction error\n"; } else { if ($response['returnCode'] == "409") { print "Transaction cannot be processed due to Failed AVS and CVN policy evaluation\n"; } else { if ($response['returnCode'] == "410") { print "Transaction cannot be processed due to not being able to perform AVS and CVN policy evaluation\n"; } else { print "Error while making call to Vindicia CashBox\n"; } } } } } } } } }
<?php /*============================ * Include files * require_once() * include_once(), etc... *===========================*/ require_once DBMODEL_ROOT . "/class.security.php"; /*============================ * Public Variables *===========================*/ $modelSecurity = null; /*============================ * Public Functions *===========================*/ /*============================ * Main execution *===========================*/ $modelSecurity = new Security(); $modelSecurity->recordLogout(WebSession::get(PRODUCT_ID, 'tno'), session_id(), getenv('REMOTE_ADDR')); WebSession::destroy(PRODUCT_ID); header('location: ' . WEB_ROOT . '/login/'); exit; /*============================ * View Loading *===========================*/
private function get_session() { if (isset($_SESSION['eframe_session'])) { if (!empty($_SESSION['eframe_session'])) { $this->session = WebSession::getInstance(); $this->session->load($this); } } }
<?php // Include the Vindicia library ini_set('include_path', '/Applications/MAMP/htdocs/16.0'); require_once "Vindicia/Soap/Vindicia.php"; require_once "Vindicia/Soap/Const.php"; // first, parse the POST parameters and create the Account object $session_id = $_GET['session_id']; $websession = new WebSession(); $response = $websession->fetchByVid('', $session_id); print_r($response); $response_object = $response['data']; $return_code = $response['returnCode']; $websession = $response_object->session; if ($return_code == "200" && $websession->apiReturn->returnCode == "200") { // then all is good $response = $websession->finalize(); //print the entire response for debugging if needed //print "Printing finalize response <br />"; //print_r ($response); print "<br />"; if ($response['returnCode'] == '200' && $response['data']->session->apiReturn->returnCode == "200") { print "Finalize successful." . "<br />"; print "SOAP ID: " . $response['data']->return->soapId . "<br />"; print "vinAVS: " . $response['data']->session->apiReturnValues->paymentMethodUpdate->authStatus->vinAVS . "<br />"; print "authCode: " . $response['data']->session->apiReturnValues->paymentMethodUpdate->authStatus->creditCardStatus->authCode . "<br />"; print "cvnCode: " . $response['data']->session->apiReturnValues->paymentMethodUpdate->authStatus->creditCardStatus->cvnCode . "<br />"; } else { print "Unable to finalize the websession" . "<br />"; print "returnCode: " . $response['returnCode'] . "<br />"; print "returnString: " . $response['returnString'] . "<br />";
* Main execution *===========================*/ $modelContact = new AlertContact(); $result_total = $modelContact->getContactCount(WebSession::get(PRODUCT_ID, 'tno')); if ($result_total['success'] === true) { $count = $result_total['data']; unset($result_total); if ($count > 0) { $pageTotal = ceil($count / $pageLimit); } if ($pageCurrent > $pageTotal) { $pageCurrent = $pageTotal; } $start = $pageLimit * $pageCurrent - $pageLimit; // do not put $limit*($page - 1) $result_list = $modelContact->getContactList(WebSession::get(PRODUCT_ID, 'tno'), $start, $pageLimit); if ($result_list['success'] === true) { foreach ($result_list['data'] as $k => $v) { $data['rows'][] = array('id' => $v['contact_no'], 'cell' => array('name' => $v['name'], 'email' => $v['email'], 'mobile_info' => $v['mobile_info'])); } $data['page'] = $pageCurrent; $data['total'] = $pageTotal; $data['records'] = $count; } else { $data['error'] = array('errcode' => $result_list['errcode'], 'errmsg' => $result_list['errmsg']); } } else { $data['error'] = array('errcode' => $result_total['errcode'], 'errmsg' => $result_total['errmsg']); } echo json_encode($data); /*============================
function hoaAccountUpdatePaymentMethod($merchantAccountId = null, $merchantPaymentMethodId = null) { $creditCardAccount = '5454541111111111'; $paymentType = 'CreditCard'; $cvn = '111'; $exp = '201805'; $email = get_unique_value() . '@nomail.com'; $successUrl = 'http://good.com'; $errorUrl = 'http://bad.com'; $HOAmethod = 'Account_UpdatePaymentMethod'; $HOAurl = str_replace("soap", "secure", VIN_SOAP_HOST) . "/vws.html"; $HOAversion = '5.0'; // VIN_SOAP_CLIENT_VERSION $ipAddress = '127.0.0.1'; $name = 'John Vindicia'; $addr1 = '303 Twin Dolphin Drive'; $city = 'Redwood City'; $district = 'CA'; $postalCode = '94065'; $country = 'US'; # Create a new WebSession object $webSession = new WebSession(); # Set the WebSession parameters $webSession->setReturnURL($successUrl); $webSession->setErrorURL($errorUrl); $webSession->setIpAddress($ipAddress); $webSession->setMethod($HOAmethod); $webSession->setVersion($HOAversion); if (is_null($merchantAccountId)) { $merchantAccountId = 'account-2015-02-10_02_55_50'; } if (is_null($merchantPaymentMethodId)) { $merchantPaymentMethodId = 'pm-2015-02-10_02_55_50'; } // Step 2: start configuring the WebSession with the parameters we want to have $nvp1 = new NameValuePair(); $nvp1->setName('vin_Account_merchantAccountId'); $nvp1->setValue($merchantAccountId); // so that we can use the existing account $nvp2 = new NameValuePair(); $nvp2->setName('vin_PaymentMethod_merchantPaymentMethodId'); $nvp2->setValue($merchantPaymentMethodId); $nvp3 = new NameValuePair(); $nvp3->setName('vin_PaymentMethod_type'); $nvp3->setValue($paymentType); $webSession->setPrivateFormValues(array($nvp1, $nvp2, $nvp3)); $nvp7 = new NameValuePair(); $nvp7->setName('Account_updatePaymentMethod_updateBehavior'); $nvp7->setValue('CatchUp'); $nvp8 = new NameValuePair(); $nvp8->setName('Account_updatePaymentMethod_replaceOnAllAutoBills'); $nvp8->setValue('false'); $nvp9 = new NameValuePair(); $nvp9->setName('Account_updatePaymentMethod_ignoreAvsPolicy'); $nvp9->setValue('false'); $nvp10 = new NameValuePair(); $nvp10->setName('Account_updatePaymentMethod_ignoreCvnPolicy'); $nvp10->setValue('false'); $webSession->setMethodParamValues(array($nvp7, $nvp8, $nvp9, $nvp10)); // now, create the session and generate it's session ID $response = $webSession->initialize(); print_r($response); # Check to see that the initialize succeeded # if ($response['returnCode'] == 200) { # The VID of the WebSession object serves as session id # $vin_WebSession_vid = $response['data']->session->getVID(); } else { print_r($response); return; } # populate accountHolderName with same value as on billingAddress: $post['vin_PaymentMethod_accountHolderName'] = $post['vin_PaymentMethod_billingAddress_name'] = $name; $post['vin_PaymentMethod_billingAddress_addr1'] = $addr1; $post['vin_PaymentMethod_billingAddress_city'] = $city; $post['vin_PaymentMethod_billingAddress_district'] = $district; $post['vin_PaymentMethod_billingAddress_postalCode'] = $postalCode; $post['vin_PaymentMethod_billingAddress_country'] = $country; $post['vin_Account_emailAddress'] = $email; $post['vin_PaymentMethod_creditCard_account'] = $creditCardAccount; $post['vin_PaymentMethod_creditCard_expirationDate'] = $exp; $post['vin_PaymentMethod_nameValues_cvn'] = $cvn; $post['vin_WebSession_vid'] = $vin_WebSession_vid; # Copy the BillingAddress to the ShippingAddress to improve # Chargeback dispute success. Visa will deny disputed Chargeback # for many reasons. A missing ShippingAddress, even though there # is nothing being shipped, is commonly one of those reasons. # This can be done with JavaScript on the checkout form. # $post['vin_Account_name'] = $post['vin_PaymentMethod_billingAddress_name']; $post['vin_Account_shippingAddress_name'] = $post['vin_PaymentMethod_billingAddress_name']; $post['vin_Account_shippingAddress_addr1'] = $post['vin_PaymentMethod_billingAddress_addr1']; $post['vin_Account_shippingAddress_city'] = $post['vin_PaymentMethod_billingAddress_city']; $post['vin_Account_shippingAddress_district'] = $post['vin_PaymentMethod_billingAddress_district']; $post['vin_Account_shippingAddress_county'] = $post['vin_PaymentMethod_billingAddress_county']; $post['vin_Account_shippingAddress_postalCode'] = $post['vin_PaymentMethod_billingAddress_postalCode']; $post['vin_Account_shippingAddress_country'] = $post['vin_PaymentMethod_billingAddress_country']; $post['vin_Account_shippingAddress_phone'] = $post['vin_PaymentMethod_billingAddress_phone']; # Create the curl command line for exec by looping through the # $post array # $curlopts = ""; foreach ($post as $name => $value) { $curlopts .= " --data-urlencode {$name}=\"{$value}\""; } print "<b><i>SOAP URL</i></b>: " . VIN_SOAP_HOST . PHP_EOL; # Do the POST # print "Posting to <b>HOA URL</b>: " . $HOAurl . PHP_EOL; print PHP_EOL; exec("curl -s {$curlopts} " . $HOAurl, $curlout, $curlret); # this line is only here to support testing with a single PHP file: $_GET = simulate_get($curlout); # the above function established the $_GET array to be the same as # what PHP by default populates in the $_GET array when the returnURL # page is a separate PHP file, and is here to support testing with # a single PHP file. #--------------------------------------------------------------------------- # # PHP specific code handling of HOA WebSession Method finalize processing # ------------------------------------------------------------------------ # # The finalize call returns an updated WebSession object. This # is correct in that it refers to the WebSession.finalize soap request and the # WebSession.finalizeResponse soap response as defined in the WSDL and Online # Soap Documentation at: # # http://developer.vindicia.com/docs/soap/index.html?ver=9.0 # # However, specific to the CashBox PHP Client library, this translates into # the mapping into the PHP API method to invoke the WebSession.finalize soap # request, and the WebSession.finalizeResponse object containing the returned # WebSession object may be accessed from the response: # # 1) PHP API method to invoke the WebSession.finalize soap request: # # $response = WebSession->finalize() # # 2) WebSession.finalizeResponse soap response object containing WebSession: # # Following a successful call to finalize(), the values from $response, the # WebSession.finalizeResponse soap response, are then accessible by referencing # the nested objects in the response corresponding to the hierarchy in the WSDL. # # Note that the WebSession data members from the WSDL are documented in the # Online Soap documentation for the WebSession datatype below: # # http://developer.vindicia.com/docs/soap/AllDataTypes.html?pf=1&ver=9.0&type=WebSession # # --- # # HOA uses the following 3 steps: # 1. WebSession.initialize (initialize & obtain a sessionId for the WebSession) # 2. HOA Form Post (Present Form to buyer with hidden sessionId, buyer posts to HOA) # 3. Redirect to HOA success page (sessionId from redirect for WebSession.finalize) # # Below describes the handling of Step 3, HOA success page, # where the sessionId from the redirect URL is passed to the finalize() method below: # # 6. Upon payment form submission if customer’s browser is redirected to the Return URL # hosted by you and specified in the WebSession object. On this page finalize the # WebSession object as follows: # # a. The redirect URL string contains WebSession’s VID as the value associated with # name ‘session_id’. Use the VID to make the finalize() call below: # # --- # # HOA WebSession Method: Account_UpdatePaymentMethod # #--------------------------------------------------------------------------- # # HOA Success Page: Need to call WebSession.finalize() to invoke internal # soap call to Account.updatePaymentMethod() as indicated by the value of # WebSession Method (Account_UpdatePaymentMethod), using the parameters already # contained in the WebSession object stored in the database (on the HOA/CashBox server). # # # Documentation of Soap Objects returned in PHP code (displayed by print_r($response)): # # To see the data members in the WebSession (& all other CashBox Soap objects), # please review the Online Soap Documentation at the link below: # # http://developer.vindicia.com/docs/soap/index.html?ver=9.0 # # Within the Online Soap Documentation, the following links are pertinent: # # All Data Types that are returned by PHP (as seen by print_r($response) are found at: # http://developer.vindicia.com/docs/soap/AllDataTypes.html?ver=9.0 # # The WebSession methods (including WebSession.initialize() & WebSession.finalize(): # http://developer.vindicia.com/docs/soap/WebSession.html?ver=9.0 # # Specifically for the code below, the WebSession Data Type definition: # http://developer.vindicia.com/docs/soap/AllDataTypes.html?pf=1&ver=9.0&type=WebSession # # With the above Documentation of the CashBox Soap Objects in mind, the source code # of the PHP library itself reveals the actual syntax of the PHP methods involved in # setting data members on the CashBox Soap Objects represented in PHP Objects created # & used in this sample code. # # The source code for the WebSession Object in the PHP library is found under # Vindicia/Soap/WebSession.php within the PHP library for example. # #-Step 3----------------------------------------------------- #-Step 3- #-Step 3- This code should be on the returnURL page #-Step 3- #-Step 3- Nothing has been committed until the WebSession gets #-Step 3- finalized. This is done in the returnURL page code. For #-Step 3- example, the returnURL is a confirmation page and when #-Step 3- the user clicks a confirmation button the form action #-Step 3- is a page that performs all the actual finalize steps. #-Step 3- print "Parameters from redirect URL:" . PHP_EOL; print_r($_GET); $session_id = $_GET['session_id']; $webSession = new WebSession(); $webSession->setVid($session_id); # initialize call timestamp in case of error for support information below: date_default_timezone_set("America/Los_Angeles"); $call_timestamp = date("c"); // c - The ISO-8601 date (e.g. 2015-06-17T16:34:42+00:00) $response = $webSession->finalize(); print_r($response); $session = $response['data']->session; # WebSession.finalizeResponse.return.returnCode $returnCode = $response['returnCode']; # WebSession.finalizeResponse.return.returnString $returnString = $response['returnString']; # WebSession.finalizeResponse.return.soapId $finalize_soapId = $response['data']->return->soapId; print $call_timestamp . " WebSession.finalize soapId: " . $finalize_soapId . "\n"; # log soap id if available in the return values of this call # WebSession.apiReturn.returnCode $apiReturnCode = $session->apiReturn->returnCode; # WebSession.apiReturn.returnString $apiReturnString = $session->apiReturn->returnString; # WebSession.apiReturnValues $apiReturnValues = $session->apiReturnValues; # WebSession.apiReturnValues.accountUpdatePaymentMethod $accountUpdatePaymentMethod = $apiReturnValues->accountUpdatePaymentMethod; # WebSession.apiReturnValues.accountUpdatePaymentMethod.validated $validated = $accountUpdatePaymentMethod->validated; if ($response['returnCode'] != '200') { print $response['returnCode'] . PHP_EOL; print $returnString . PHP_EOL; print $apiReturnCode . PHP_EOL; print $apiReturnString . PHP_EOL; } else { print $apiReturnCode . PHP_EOL; print $apiReturnString . PHP_EOL; if ($apiReturnCode == "200") { print PHP_EOL . 'Updated Credit Card. Account=' . $merchantAccountId . ' PaymentMethod=' . $merchantPaymentMethodId . PHP_EOL; } else { if ($apiReturnCode = "261") { print "All active AutoBills were updated. AutoBills which are both expired and Suspended cannot be updated.\n"; } else { if ($apiReturnCode == "400") { print "One of the following:\n• Invalid Payment Method Type. (You cannot change the Payment Method Type on an existing Payment Method.)\n• No PaymentMethod specified in arguments.\n• Data validation error Failed to create Payment-Type-Specific Payment Record: Credit Card conversion failed: Credit Card failed Luhn check.\n"; } else { if ($apiReturnCode == "402") { print "One of the following:\n• PaymentMethod failed validation.\n• Error attempting to authorize card.\n• Unable to authorize card.\n"; } else { if ($apiReturnCode = "404") { print "No match found error-description.\n Returned if CashBox cannot find an account that matches the input in the Vindicia database.\n"; } else { if ($apiReturnCode = "407") { print "Transaction cannot be processed due to Failed AVS policy evaluation\n"; } else { if ($apiReturnCode = "408") { print "Transaction cannot be processed due to Failed CVN policy evaluation\n"; } else { if ($apiReturnCode = "409") { print "AutoBill creation failed: due to AVS and CVV Check Failed\n"; } else { if ($apiReturnCode = "410") { print "AutoBill creation failed: due to AVS and CVV Check not being able to be performed\n"; } else { print "Error while making call to Vindicia CashBox\n"; } } } } } } } } } } return array('apiReturnCode' => $apiReturnCode, 'validated' => $validated); }
function hoaAutoBill() { # Set the data members from the arg values # $uniqueValue = get_unique_value(); $merchantAutoBillId = 'ab-' . $uniqueValue; $merchantAccountId = 'account-' . $uniqueValue; $merchantPaymentMethodId = 'pm-' . $uniqueValue; $merchantProductId = 'Video'; $merchantBillingPlanId = 'OneMonthSubOneMonthRecurring'; $creditCardAccount = '5454541111111111'; $paymentType = 'CreditCard'; $cvn = '111'; $exp = '201501'; $email = get_unique_value() . '@nomail.com'; $successUrl = 'http://good.com'; $errorUrl = 'http://bad.com'; $HOAmethod = 'AutoBill_Update'; $HOAurl = 'https://secure.prodtest.sj.vindicia.com/vws'; $HOAversion = '5.0'; $ipAddress = '127.0.0.1'; $name = 'John Vindicia'; $addr1 = '303 Twin Dolphin Drive'; $city = 'Redwood City'; $district = 'CA'; $postalCode = '94065'; $country = 'US'; #------------------------------------------------------------ #-Step 1- #-Step 1- Initialize the WebSession before the PaymentMethod #-Step 1- form is displayed to the user #-Step 1- # # Create a new WebSession object $webSession = new WebSession(); # Set the WebSession parameters $webSession->setReturnURL($successUrl); $webSession->setErrorURL($errorUrl); $webSession->setIpAddress($ipAddress); $webSession->setMethod($HOAmethod); $webSession->setVersion($HOAversion); #------------------------------------------------------------ # Set PrivateFormValues. These are hidden fields in the POST # that we want to protect from hacking. If the value in the # POST does not match the value set during initialization, # the WebSession.finalize will fail # Your ID for this AutoBill $ab_id = new NameValuePair(); $ab_id->setName("vin_AutoBill_merchantAutoBillId"); $ab_id->setValue($merchantAutoBillId); # Your ID for this user $acct_id = new NameValuePair(); $acct_id->setName("vin_Account_merchantAccountId"); $acct_id->setValue($merchantAccountId); # Permissible values for the Product that is going to be purchased // $prod_id = new NameValuePair(); // $prod_id->setName("vin_Product_merchantProductId"); // $prod_id->setValue($merchantProductId); # Permissible values for the Product that is going to be purchased $prod_id = new NameValuePair(); $prod_id->setName("vin_AutoBill_items_0_Product_merchantProductId"); $prod_id->setValue($merchantProductId); # Permissible values for BillingPlan to be used $plan_id = new NameValuePair(); $plan_id->setName("vin_BillingPlan_merchantBillingPlanId"); $plan_id->setValue($merchantBillingPlanId); # Your ID for this PaymentMethod $paym_id = new NameValuePair(); $paym_id->setName("vin_PaymentMethod_merchantPaymentMethodId"); $paym_id->setValue($merchantPaymentMethodId); $pmt_type = new NameValuePair(); $pmt_type->setName("vin_PaymentMethod_type"); $pmt_type->setValue($paymentType); # Add the PrivateFormValues to the WebSession $webSession->setPrivateFormValues(array($ab_id, $acct_id, $prod_id, $plan_id, $paym_id, $pmt_type)); #------------------------------------------------------------ # Set any parameters specific for the Method we are # calling in the WebSession. # $validate = new NameValuePair(); $validate->setName("AutoBill_Update_validatePaymentMethod"); // $validate->setName("AutoBill_Update_validate"); $validate->setValue("true"); $minChargebackProbability = new NameValuePair(); $minChargebackProbability->setName("AutoBill_Update_minChargebackProbability"); // Value of 100 turns off fraud checking. $minChargebackProbability->setValue("100"); $ignoreCvnPolicy = new NameValuePair(); $ignoreCvnPolicy->setName("AutoBill_Update_ignoreCvnPolicy"); $ignoreCvnPolicy->setValue("false"); $ignoreAvsPolicy = new NameValuePair(); $ignoreAvsPolicy->setName("AutoBill_Update_ignoreAvsPolicy"); $ignoreAvsPolicy->setValue("false"); $dryRun = new NameValuePair(); $dryRun->setName("AutoBill_Update_dryRun"); $dryRun->setValue("false"); // AutoBill_Update takes in one more parameter - campaignCode // We will collect campaign code from the payment form $webSession->setMethodParamValues(array($validate, $minChargebackProbability, $ignoreCvnPolicy, $ignoreAvsPolicy, $dryRun)); # Initialize the WebSession # $response = $webSession->initialize(); # Check to see that the initialize succeeded # if ($response['returnCode'] == 200) { # The VID of the WebSession object serves as session id # $vin_WebSession_vid = $response['data']->session->getVID(); } else { print $response; return; } #------------------------------------------------------------ #-Step 2- #-Step 2- This is the payment method FORM and the HOA POST #-Step 2- # TODO: Parameterize these from $_POST or $argv # Fields on the checkout FORM # User supplied input // $post['vin_PaymentMethod_merchantPaymentMethodId'] = // $merchantPaymentMethodId; $post['vin_PaymentMethod_accountHolderName'] = $post['vin_PaymentMethod_billingAddress_name'] = $name; $post['vin_PaymentMethod_billingAddress_addr1'] = $addr1; $post['vin_PaymentMethod_billingAddress_city'] = $city; $post['vin_PaymentMethod_billingAddress_district'] = $district; $post['vin_PaymentMethod_billingAddress_postalCode'] = $postalCode; $post['vin_PaymentMethod_billingAddress_country'] = $country; $post['vin_Account_emailAddress'] = $email; $post['vin_PaymentMethod_creditCard_account'] = $creditCardAccount; $post['vin_PaymentMethod_creditCard_expirationDate'] = $exp; $post['vin_PaymentMethod_nameValues_cvn'] = $cvn; # Hidden fields in the checkout FORM # $post['vin_WebSession_vid'] = $vin_WebSession_vid; // If you have a Campaign Code form value... //$post['AutoBill_Update_campaignCode'] = 'XYZ'; # Copy the BillingAddress to the ShippingAddress to improve # Chargeback dispute success. Visa will deny disputed Chargeback # for many reasons. A missing ShippingAddress, even though there # is nothing being shipped, is commonly one of those reasons. # This can be done with JavaScript on the checkout form. # $post['vin_Account_name'] = $post['vin_PaymentMethod_billingAddress_name']; $post['vin_Account_shippingAddress_name'] = $post['vin_PaymentMethod_billingAddress_name']; $post['vin_Account_shippingAddress_addr1'] = $post['vin_PaymentMethod_billingAddress_addr1']; $post['vin_Account_shippingAddress_city'] = $post['vin_PaymentMethod_billingAddress_city']; $post['vin_Account_shippingAddress_district'] = $post['vin_PaymentMethod_billingAddress_district']; $post['vin_Account_shippingAddress_county'] = $post['vin_PaymentMethod_billingAddress_county']; $post['vin_Account_shippingAddress_postalCode'] = $post['vin_PaymentMethod_billingAddress_postalCode']; $post['vin_Account_shippingAddress_country'] = $post['vin_PaymentMethod_billingAddress_country']; $post['vin_Account_shippingAddress_phone'] = $post['vin_PaymentMethod_billingAddress_phone']; # Create the curl command line for exec by looping through the # $post array # $curlopts = ""; foreach ($post as $name => $value) { $curlopts .= " --data-urlencode {$name}=\"{$value}\""; } # Do the POST # exec("curl -s {$curlopts} " . $HOAurl, $curlout, $curlret); #-Step 3----------------------------------------------------- #-Step 3- #-Step 3- This code should be on the returnURL page #-Step 3- #-Step 3- Nothing has been committed until the WebSession gets #-Step 3- finalized. This is done in the returnURL page code. For #-Step 3- example, the returnURL is a confirmation page and when #-Step 3- the user clicks a confirmation button the form action #-Step 3- is a page that performs all the actual finalize steps. #-Step 3- #------------------------------------------------------------ # This is only necessary for this CLI implementation. # # Flatten the output from exec so we can search it. The response # from a successful HOA POST should be a 302 page that contains # our returnURL with the WebSessionVID as the query string. # if (php_sapi_name() == "cli") { $curlresp = implode("\n", $curlout); } # #------------------------------------------------------------ # For CLI, use the WebSessionId we stored in the POST values # for curl. For everything else, retrieve the WebSessionId # from the URL query string on the redirect to the returnURL # if (php_sapi_name() == "cli") { $session_id = $post['vin_WebSession_vid']; } else { $session_id = $_GET['session_id']; } $webSession = new WebSession(); $webSession->setVid($session_id); $response = $webSession->finalize(); if ($response['returnCode'] != '200') { print $response; } # Note, finalize almost always returns a 200 returnCode. The real # test for success of the underlying API call is inspection of # the apiReturn and apiReturnValues objects # Parse out the return object from the method call # $apiReturnValues = $response['data']->session->apiReturnValues; # Check the returnCode of the method called. # See Returns for update method of AutoBill object in the API # Reference for possible returnCodes. # if ($response['data']->session->apiReturn->returnCode != "200") { //408 - AutoBill creation failed: CVV check failed //407 - AutoBill creation failed: AVS Check Failed //409 - AutoBill creation failed: AVS and CVV Check Failed //410 - AutoBill creation failed: AVS and CVV check could not be performed //402 - AutoBill creation failed: Card authorization failed //400 - AutoBill creation failed print $apiReturnValues; } print 'success'; print $response['data']->session->apiReturn->soapId . " AutoBill >" . $merchantAutoBillId . "< created for Account >" . $merchantAccountId . "< using PaymentMethod >" . $merchantPaymentMethodId . "< AuthCode->" . $response['data']->session->apiReturnValues->autoBillUpdate->authStatus->creditCardStatus->getAuthCode() . "< AVS->" . $response['data']->session->apiReturnValues->autoBillUpdate->authStatus->creditCardStatus->getAvsCode() . "< CVN->" . $response['data']->session->apiReturnValues->autoBillUpdate->authStatus->creditCardStatus->getCvnCode() . "<"; }
use repositories\UserAccountRepository; use repositories\UserAccountRememberMeRepository; ///////////////////////// Redirect to Correct Domain $parseDomain = new ParseDomain($_SERVER['SERVER_NAME']); if (!$parseDomain->isCoveredByCookies()) { if ($app['config']->isSingleSiteMode) { header("Location: " . $app['config']->getWebIndexDomainSecure() . $_SERVER['REQUEST_URI']); } else { // Not sure how to improve this; it's hard to work out which domain they were trying to hit. header("Location: " . $app['config']->getWebIndexDomainSecure()); } die("REDIRECT!"); } ///////////////////////// Sessions /** @var WebSession **/ $WEBSESSION = new WebSession(); $app['websession'] = $WEBSESSION; /** @var FlashMessages **/ $FLASHMESSAGES = new FlashMessages($WEBSESSION); $app['flashmessages'] = $FLASHMESSAGES; /** @var UserAgent **/ $USERAGENT = new \UserAgent(); $app['userAgent'] = $USERAGENT; ///////////////////////// TWIG $dirs = array(); foreach ($CONFIG->extensions as $extensionName) { // Carefully ordered so extensions are first in list. // And in config, later extensions listed can overwrite earlier extensions. array_unshift($dirs, APP_ROOT_DIR . '/extension/' . $extensionName . '/theme/default/templates'); if ($CONFIG->isSingleSiteMode) { array_unshift($dirs, APP_ROOT_DIR . '/extension/' . $extensionName . '/theme/default/templatesSingleSite');
require_once "Vindicia/Soap/Vindicia.php"; require_once "Vindicia/Soap/Const.php"; // Pls change the ip address , return and cancel URL as per your setup // note that IP address should be the customer's IP address define("IP_ADDRESS", "192.168.1.100"); define("HOA_RETURN_URL", "http://localhost:8888/success.php"); define("HOA_CANCEL_URL", "http://localhost:8888/error.php"); // pls change the URL according to your test server, // for prodtest set it as 'https://secure.prodtest.sj.vindicia.com/vws' define("HOA_POST_URL", "https://secure.prodtest.sj.vindicia.com/vws.html"); // for staging set it as 'https://secure.staging.sj.vindicia.com/vws' //define("HOA_POST_URL","https://secure.staging.sj.vindicia.com/vws.html"); // get the merchantPaymentMethodId we will updating from the post $merchantPmId = $_POST['merchantPmId']; // ok, now we're ready to get the new card info. Step 1: create the WebSession object $websession = new WebSession(); $websession->setMethod('PaymentMethod_Update'); $websession->setReturnURL(HOA_RETURN_URL); $websession->setErrorURL(HOA_CANCEL_URL); $websession->setIpAddress(IP_ADDRESS); // Step 2: start configuring the WebSession with the parameters we want to have $nvp1 = new NameValuePair(); $nvp1->setName('vin_PaymentMethod_merchantPaymentMethodId'); $nvp1->setValue($merchantPmId); $websession->setPrivateFormValues(array($nvp1)); $nvp6 = new NameValuePair(); $nvp6->setName('PaymentMethod_Update_validate'); $nvp6->setValue(1); //needs to be less than 100 to get a score. 100 is used to ignore fraud scoring $nvp7 = new NameValuePair(); $nvp7->setName('PaymentMethod_Update_minchargebackprobability');