コード例 #1
0
    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);
    } else {
        print 'An error occured during capture: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . "\n";
    }
} else {
    print 'An error occured during authorization: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . "\n";
}
//exit;
// If you didn't want to
if ($Transaction = $MS->charge($Card, $amount)) {
    print 'Card charged!' . "\n";
    print_r($Transaction);
} else {
    print 'An error occured during charge: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . "\n";
}
exit;
// We can issue refunds too...
if ($Transaction = $MS->refund($Card, $amount)) {
    print 'Card refunded $' . $amount . ' dollars!' . "\n";
    print_r($Transaction);
} else {
    print 'An error occured during refund: ' . $MS->errorNumber() . ': ' . $MS->errorMessage() . "\n";
}
/*
Let's trigger an error, just so we can see how to handle it. We can trigger 
コード例 #2
0
<?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();
}