Table of Contents

DoExpressCheckoutPayment Examples

Notes

NOTICE - When adding items, the amount_items variable will be calculated automatically, but the amount_tax and amount_total variables are NOT calculated automatically based on the items amount and tax values. This is because there can be certain cases when the amount_tax will not just be the amount of all the tax amounts of the items.

Please keep in mind, if ANY of the items have a tax amount set, then you MUST set amount_tax.

Request

// Create instance of the phpPayPal class
$paypal = new YipPayPal();
 
// Set the required fields	
$paypal->token = $_SESSION['token'];
$paypal->payer_id = $_SESSION['payer_id'];
 
// Final total amount and shipping
$paypal->amount_total = '50.00';
$paypal->amount_shipping = '10.00';
 
// Add items to the PayPal transaction (not required)
// addItem() function FORMAT - $name, $number, $quantity, $amount_tax, $amount
$paypal->addItem('Item Name', 'N102', 1, 0, 20.00);
$paypal->addItem('Item Example 2 Name', 'N101', 2, 0, 10.00);
 
// Make the request
$paypal->DoExpressCheckoutPayment();

For more information on field descriptions, requirements and corresponding PayPal fields, see the parameters list.

Required Fields

Optional Fields

Response

The class instance will always provide the raw PayPal response to the Response array. During testing (sandbox mode), you can simply output the value of Response to see the PayPal response.

$paypal->Response;
 
// Display the response
print_r($paypal->Response);

Success Response

If the transaction was successful, PayPal will return the following values:

Error Response

If there was an exception with the interaction with PayPal, _error will return true.

See the error documentation for details about error return values and procedures.

 

code/classes/phppaypal/examples/doexpresscheckoutpayment.txt · Last modified: 2008/03/02 23:09 (external edit)