コード例 #1
0
 $str = $Transaction->serialize();
 print 'Serialized transaction: ' . $str . "\n\n";
 // Now convert it back to a transaction object
 $Transaction = QuickBooks_MerchantService_Transaction::unserialize($str);
 // ... maybe you'd rather convert it to an array?
 $arr = $Transaction->toArray();
 print 'Array transaction: ';
 print_r($arr);
 print "\n\n";
 // ... and back again?
 $Transaction = QuickBooks_MerchantService_Transaction::fromArray($arr);
 // ... or an XML document?
 $xml = $Transaction->toXML();
 print 'XML transaction: ' . $xml . "\n\n";
 // ... and back again?
 $Transaction = QuickBooks_MerchantService_Transaction::fromXML($xml);
 /* 
 Now that that card has been authorized, let's actually capture the funds. 
 
 You can just pass in the transaction if you want to capture for the same 
 amount as the authorization. Alternatively, you can pass in a different 
 amount *less than* the authorization amount to only capture a portion of 
 the authorization. 
 
 If you want to capture more than the authorization was for, use charge(). 
 */
 // Only capture $50.00
 // $amount = 50.0;
 if ($Transaction = $MS->capture($Transaction, $amount)) {
     print 'Card captured!' . "\n";
     print_r($Transaction);
コード例 #2
0
 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" );
     }
 }