$expmonth = date('m');
$address = '56 Cowles Road';
$postalcode = '06279';
$cvv = null;
/**
 * There are also some test configurations you can use to simulate certain 
 * errors occuring. You pass these test configuration constants in as the $name 
 * parameter to the credit card to trigger various errors/warnings. 
 */
//$name = QUICKBOOKS_MERCHANTSERVICE_TEST_AVSZIPCVVFAIL;		// Simulate a sucessful transaction that failed all AVS and CVV checks, but was still processed (i.e. your gateway is set up to accept everything)
//$name = QUICKBOOKS_MERCHANTSERVICE_TEST_COMMUNICATIONERROR;	// Simulate a general communication error
// Create the CreditCard object
$Card = new QuickBooks_MerchantService_CreditCard($name, $number, $expyear, $expmonth, $address, $postalcode, $cvv);
// We're going to authorize $295.00
$amount = 295.0;
if ($Transaction = $MS->authorize($Card, $amount)) {
    print 'Card authorized!' . "\n";
    print_r($Transaction);
    //exit;
    /*
    Every time the MerchantService class returns a $Transaction object to you, 
    you should store the returned $Transaction. You'll need the returned 
    $Transaction object (or at the very least the data contained therein) in 
    order to push these transactions to QuickBooks, to actually capture the 
    funds, to issue a refund, or to issue a void. 
    
    There are several convienence methods to convert the $Transaction object to 
    more storage-friendly formats if you would prefer to use these: 
    */
    // Get the transaction as a string which can later be turned back into a transaction object
    $str = $Transaction->serialize();
 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" );
     }
 }