//$path_to_private_key_and_certificate = '/path/doesnt/exist.pem'; // This should trigger an error //$path_to_private_key_and_certificate = null; // If you're using the DESKTOP model // This is your login ID that Intuit assignes you during the application // registration process. $application_login = '******'; // This is the connection ticket assigned to you during the application // registration process. To conform to Intuit security practices, you are // *required* to store this key *encrypted* and not in plain-text. // // The ticket below is provided as an example, you should *not* store your // connection ticket in plain text as shown below. You should store it in your // database or in a separate file, outside of the web server document root, // encrypted with a crypto library such as {@link http://www.php.net/mcrypt}. $connection_ticket = 'TGT-152-LWGj1YQUufTAlSW8DK1c6A'; // Create an instance of the MerchantService object $MS = new QuickBooks_MerchantService($dsn, $path_to_private_key_and_certificate, $application_login, $connection_ticket); // If you're using a Intuit QBMS development account, you must set this to true! $MS->useTestEnvironment(true); // If you want to see the full XML input/output, you can turn on debug mode $MS->useDebugMode(true); /* There are several methods available in the QuickBooks_MerchantService class. The most common methods are described below: - authorize() This authorizes a given amount against the a credit card. It is important to note that this *does not* actually charge the credit card, it just "reserves" the amount on the credit card and guarentees that if you do a capture() on the same credit card within X days, the funds will be available. Authorizations are used in situations where you want to ensure the money
<?php /** * * * * * @package QuickBooks * @subpackage Documentation */ ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/Users/kpalmer/Projects/QuickBooks/'); require_once 'QuickBooks.php'; require_once 'QuickBooks/MerchantService.php'; $MS = new QuickBooks_MerchantService(null, '/Users/kpalmer/Projects/QuickBooks/QuickBooks/dev/test_qbms.pem', 'test.www.academickeys.com', 'TGT-152-LWGj1YQUufTAlSW8DK1c6A'); $MS->useTestEnvironment(true); $name = 'Keith Palmer'; $number = '5105105105105100'; $expyear = date('Y'); $expmonth = date('m'); $address = '56 Cowles Road'; $postalcode = '06279'; $cvv = null; $Card = new QuickBooks_MerchantService_CreditCard($name, $number, $expyear, $expmonth, $address, $postalcode, $cvv); //if ($Transaction = $MS->authorize($Card, 295)) if ($Transaction = $MS->charge($Card, 295)) { print 'Card authorized!'; } else { print 'An error occured: ' . $MS->errorNumber() . ': ' . $MS->errorMessage(); }
header('Content-Type: text/plain'); // I always program in E_STRICT error mode... error_reporting(E_ALL | E_STRICT); ini_set('display_errors', true); // Include the QuickBooks files require_once '../QuickBooks.php'; $dsn = null; // $dsn = 'mysql://root:@localhost/quickbooks_merchantservice'; $path_to_private_key_and_certificate = null; //$path_to_private_key_and_certificate = '/Users/keithpalmerjr/Projects/QuickBooks/QuickBooks/dev/test_qbms.pem'; $application_login = '******'; //$application_login = '******'; $connection_ticket = 'TGT-145-niiEL2kCFoOTYHvkwBarmg'; //$connection_ticket = 'TGT-152-LWGj1YQUufTAlSW8DK1c6A'; // Create an instance of the MerchantService object $MS = new QuickBooks_MerchantService($dsn, $path_to_private_key_and_certificate, $application_login, $connection_ticket); // If you're using a Intuit QBMS development account, you must set this to true! $MS->useTestEnvironment(true); // If you want to see the full XML input/output, you can turn on debug mode //$MS->useDebugMode(true); // Now, let's create a credit card object, and authorize an amount agains the card $name = 'Keith Palmer'; $number = '5105105105105100'; $expyear = date('Y'); $expmonth = date('m'); $address = '56 Cowles Road'; $postalcode = '06279'; $cvv = '349'; // Create the CreditCard object $Card = new QuickBooks_MerchantService_CreditCard($name, $number, $expyear, $expmonth, $address, $postalcode, $cvv); // Our customer #
function qbmc_process() { global $event_details; $event_id = $event_details['ID']; if (is_null($event_id)) { return false; } $regis_id = $this->erm->get_regis_id(); $post_ID = $this->erm->get_regis_post_id(); $this->ecm->setup_event_details($event_id); $_totals = $this->erm->calculate_cart_totals(); $gateway_info = $this->erm->get_gateway_info(); $this->epl->load_file('libraries/gateways/qbmc/QuickBooks.php'); $dsn = null; $path_to_private_key_and_certificate = null; $application_login = trim($gateway_info['_epl_user']); $connection_ticket = trim($gateway_info['_epl_pwd']); $MS = new QuickBooks_MerchantService($dsn, $path_to_private_key_and_certificate, $application_login, $connection_ticket); $test = $gateway_info['_epl_sandbox'] == 0 ? false : true; $MS->useTestEnvironment($test); $MS->useDebugMode(false); foreach ($_POST as $k => &$v) { trim(esc_attr($v)); } $name = $_POST['_epl_cc_first_name'] . ' ' . $_POST['_epl_cc_last_name']; $number = $_POST['_epl_cc_num']; $expyear = $_POST['_epl_cc_exp_year']; $expmonth = date_i18n("m", strtotime($_POST['_epl_cc_exp_month'])); $address = $_POST['_epl_cc_address']; $postalcode = $_POST['_epl_cc_zip']; $cvv = $_POST['_epl_cc_cvv']; $Card = new QuickBooks_MerchantService_CreditCard($name, $number, $expyear, $expmonth, $address, $postalcode, $cvv); $amount = $_totals['money_totals']['grand_total']; if ($Transaction = $MS->authorize($Card, $amount)) { $str = $Transaction->serialize(); // Now convert it back to a transaction object $Transaction = QuickBooks_MerchantService_Transaction::unserialize($str); $arr = $Transaction->toArray(); // ... and back again? $Transaction = QuickBooks_MerchantService_Transaction::fromArray($arr); // ... or an XML document? $xml = $Transaction->toXML(); $Transaction = QuickBooks_MerchantService_Transaction::fromXML($xml); if ($Transaction = $MS->capture($Transaction, $amount)) { $arr = $Transaction->toArray(); $transactionId = $arr['CreditCardTransID']; $data['post_ID'] = $post_ID; $data['_epl_grand_total'] = epl_get_balance_due(); $data['_epl_payment_amount'] = $_totals['money_totals']['grand_total']; $data['_epl_payment_date'] = current_time('mysql'); $data['_epl_payment_method'] = $this->erm->get_payment_profile_id(); $data['_epl_transaction_id'] = $transactionId; $data['_epl_prediscount_total'] = epl_get_element('pre_discount_total', $_totals['money_totals'], 0); $data['_epl_discount_amount'] = epl_get_element('discount_amount', $_totals['money_totals'], 0); $data = apply_filters('epl_auth_net_aim_response_data', $data, $Transaction); $this->erm->update_payment_data($data); return true; } else { return '<div class="epl_error">ERROR: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . '</div>'; // print('An error occured during capture: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . "\n" ); } } else { return '<div class="epl_error">ERROR: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . '</div>'; //print('An error occured during authorization: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . "\n" ); } }
header('Content-Type: text/plain'); // Show some errors... error_reporting(E_ALL | E_STRICT); ini_set('display_errors', true); // Include the QuickBooks files require_once '../QuickBooks.php'; // $dsn = 'mysql://root:@localhost/quickbooks_merchantservice'; $dsn = null; //$path_to_private_key_and_certificate = null; // If you're using the DESKTOP model $path_to_private_key_and_certificate = null; //$application_login = '******'; $application_login = '******'; //$connection_ticket = 'TGT-152-LWGj1YQUufTAlSW8DK1c6A'; $connection_ticket = 'TGT-157-p3PyZPoH3DtieLSh4ykp6Q'; // Create an instance of the MerchantService object $MS = new QuickBooks_MerchantService($dsn, $path_to_private_key_and_certificate, $application_login, $connection_ticket); // If you're using a Intuit QBMS development account, you must set this to true! $MS->useTestEnvironment(true); // If you want to see the full XML input/output, you can turn on debug mode $MS->useDebugMode(true); $routing = '211170282'; $account = '414074882'; $info = QuickBooks_MerchantService_CheckingAccount::INFO_PERSONAL; $type = QuickBooks_MerchantService_CheckingAccount::TYPE_CHECKING; $first_name = 'Keith'; $last_name = 'Palmer'; $phone = '+1 (860) 634-1602'; $Check = new QuickBooks_MerchantService_CheckingAccount($routing, $account, $info, $type, $first_name, $last_name, $phone); // We're going to transfer $295 out of their checking account $amount = 295.0; if ($Transaction = $MS->debitCheck($Check, $amount, QuickBooks_MerchantService::MODE_INTERNET)) {