/** * runTransaction * * @param object|array $request */ public function runTransaction($request) { // Check if we have a valid request object if (!is_array($request) && !is_object($request)) { throw new \Exception('request must be an object'); } // If the request is an array convert to object if (is_array($request)) { $request = json_decode(json_encode($request)); } // Add some values that we need $request->merchantID = $this->merchant_id; $request->clientLibrary = 'PHP'; $request->clientLibraryVersion = phpversion(); $request->clientEnvironment = php_uname(); // Check if we have a reference code already if (!isset($request->merchantReferenceCode)) { $request->merchantReferenceCode = sha1(microtime()); } // Now run the request as needed return parent::runTransaction($request); }
public static function process_transaction($values) { global $a; $wsdl = ACTIVITY_CENTER_TRANSACTION_URL . '/soap/gate/0AE595C1/usaepay.wsdl'; // instantiate SoapClient object as $client $client = new SoapClient($wsdl); $sourcekey = ACTIVITY_CENTER_USAEPAY_KEY; $pin = '3532'; // generate random seed value $seed = time() . rand(); // make hash value using sha1 function $clear = $sourcekey . $seed . $pin; $hash = sha1($clear); // assembly ueSecurityToken as an array $token = array('SourceKey' => $sourcekey, 'PinHash' => array('Type' => 'sha1', 'Seed' => $seed, 'HashValue' => $hash), 'ClientIP' => $_SERVER['REMOTE_ADDR']); try { $lineItems[] = array('ProductRefNum' => $a->ID, 'SKU' => $a->post_title, 'ProductName' => 'Activity Fee', 'Description' => $a->desc_short, 'UnitPrice' => $a->fee, 'Qty' => AC::load_saved_data('number_of_registrants'), 'Taxable' => $a->include_tax); if (AC::is_addon_in_cart()) { foreach (AC::get_addons_in_cart() as $tax_status_group) { foreach ($tax_status_group as $addon) { $tax_status_group == 'taxable' ? $tax = true : ($tax = false); $lineItems[] = array('ProductRefNum' => $a->ID, 'SKU' => $a->post_title, 'ProductName' => $a->addon_group[$addon['index']]['title'], 'Description' => $a->addon_group[$addon['index']]['desc'], 'UnitPrice' => $a->addon_group[$addon['index']]['cost'], 'Qty' => $addon['quantity'], 'Taxable' => $tax); } } } if (AC::load_saved_data('gratuity')) { $lineItems[] = array('ProductRefNum' => $a->ID, 'SKU' => $a->post_title, 'ProductName' => 'Gratuity', 'Description' => AC::load_saved_data('gratuity') . '% gratuity', 'UnitPrice' => AC::calculate_gratuity(), 'Qty' => 1, 'Taxable' => false); } if (AC::load_saved_data('donation')) { $lineItems[] = array('ProductRefNum' => $a->ID, 'SKU' => $a->post_title, 'ProductName' => 'Donation', 'Description' => 'Donation to the Vetri Foundation', 'UnitPrice' => AC::load_saved_data('donation'), 'Qty' => 1, 'Taxable' => false); } $values['number_of_registrants'] < 2 ? $seats = 'seat' : ($seats = 'seats'); $Request = array('AccountHolder' => $values['cc_name'], 'Details' => array('Description' => $values['number_of_registrants'] . ' ' . $seats . ' for ' . $a->post_title, 'Amount' => AC::get_total(), 'OrderID' => $_SESSION['edgimo-reservation-form']['timer_id'], 'Currency' => 'USD'), 'CreditCardData' => array('CardNumber' => $values['cc_number'], 'CardExpiration' => $values['cc_exp_month'] . $values['cc_exp_year'], 'AvsStreet' => $values['billing_address'], 'AvsZip' => $values['billing_zip'], 'CardCode' => $values['cc_ccv']), 'BillingAddress' => array('City' => $values['billing_city'], 'Email' => $values['registrant_1_email'], 'FirstName' => $values['billing_first_name'], 'LastName' => $values['billing_last_name'], 'Phone' => $values['billing_phone'], 'State' => $values['billing_state'], 'Street' => $values['billing_address'], 'Zip' => $values['billing_zip']), 'LineItems' => $lineItems); $res = $client->runTransaction($token, $Request); if (ACTIVITY_CENTER_TESTMODE) { var_dump($res); } $result = array(); if ($res->Result == 'Error') { $result['success'] = false; $result['message'] = 'There was an error with your transaction:<br /><strong>' . $res->Error . '</strong>'; } if ($res->Result == 'Approved') { $result['success'] = true; $result['message'] = 'Your reservation has been approved!'; $result['RefNum'] = $res->RefNum; $result['AuthCode'] = $res->AuthCode; $result['CardType'] = $res->CardLevelResult; $result['Last4'] = substr($values['cc_number'], -4); } if ($res->Result == 'Declined') { $result['success'] = false; $result['message'] = 'Your transaction was declined. Please check your information and try again.<br />Error: <strong>' . $res->Error . '</strong>.'; } return $result; } catch (SoapFault $e) { echo $client->__getLastRequest(); echo $client->__getLastResponse(); die("runTransaction failed :" . $e->getMessage()); } }
$client = new SoapClient($wsdl); $sourcekey = '3K3070JOzmqp0h936O2ligRNu0T8tXcR'; $pin = 'evol'; // generate random seed value $seed = mktime() . rand(); // make hash value using sha1 function $clear = $sourcekey . $seed . $pin; $hash = sha1($clear); // assembly ueSecurityToken as an array $token = array('SourceKey' => $sourcekey, 'PinHash' => array('Type' => 'sha1', 'Seed' => $seed, 'HashValue' => $hash), 'ClientIP' => $_SERVER['REMOTE_ADDR']); //print_r($token);die; try { $Request = array('AccountHolder' => 'Tester Jones', 'Details' => array('Description' => 'Example Transaction', 'Amount' => '4.00', 'Invoice' => '44539'), 'CreditCardData' => array('CardNumber' => '4444555566667779', 'CardExpiration' => '0909', 'AvsStreet' => '1234 Main Street', 'AvsZip' => '99281', 'CardCode' => '999')); //print_r($token); //print_r($Request);die; $res = $client->runTransaction($token, $Request); print_r($res); } catch (SoapFault $e) { echo $client->__getLastRequest(); echo $client->__getLastResponse(); die("runTransaction failed :" . $e->getMessage()); } exit; phpinfo(); die; $con = mysqli_connect("172.17.0.1", "root", "123456", "mysql"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Perform queries