|
Rank: Starting Member
Groups: Registered
Joined: 3/20/2005 Posts: 9 Location: ,
|
I'm trying to set tax as a seperate amount in an Express Checkout transaction so both me and the buyer can see the tax (and shipping if I can figure it out) as a seperate breakdown in the receipt emails.
I cannot figure out how to call it with the PHP SDK. There is a serious lack of examples of how to use this code, unfortunately.
I'm trying something like:
$TaxTotal->setattr('currencyID', 'USD');
$TaxTotal->setval($tax, 'iso-8859-1');
I've tried other things like:
$DoExpressCheckoutPaymentRequestDetails->setTaxTotal($tax, 'iso-8859-1');
How do I call this??
This is some of what I have so far...
--8<---- snip -------------------
$handler =& ProfileHandler_File::getInstance(array (
'path' => '',
'charset' => 'iso-8859-1',
));
if (Services_PayPal::isError($handler)) {
var_dump($handler->getMessage());
exit;
}
$profile =& APIProfile::getInstance('acdeed43422446cbb0ed692d1409e24d', $handler);
if (Services_PayPal::isError($profile)) {
var_dump($profile->getMessage());
exit;
}
$profile->setAPIPassword($GLOBALS["PaypalAPIPassword"]);
$caller =& Services_PayPal::getCallerServices($profile);
if (Services_PayPal::isError($caller)) {
var_dump($caller->getMessage());
exit;
}
$OrderTotal =& Services_PayPal::getType('BasicAmountType');
if (Services_PayPal::isError($OrderTotal)) {
var_dump($OrderTotal);
exit;
}
$OrderTotal->setattr('currencyID', 'USD');
$OrderTotal->setval($carttotal, 'iso-8859-1');
$ShippingTotal->setattr('currencyID', 'USD');
$ShippingTotal->setval($ship_cost, 'iso-8859-1');
$TaxTotal->setattr('currencyID', 'USD');
$TaxTotal->setval($tax, 'iso-8859-1');
$PaymentDetails =& Services_PayPal::getType('PaymentDetailsType');
if (Services_PayPal::isError($PaymentDetails)) {
var_dump($PaymentDetails);
exit;
}
$PaymentDetails->setShippingTotal($ShippingTotal);
$PaymentDetails->setTaxTotal($TaxTotal);
$PaymentDetails->setOrderTotal($OrderTotal);
$DoExpressCheckoutPaymentRequestDetails =& Services_PayPal::getType('DoExpressCheckoutPaymentRequestDetailsType');
if (Services_PayPal::isError($DoExpressCheckoutPaymentRequestDetails)) {
var_dump($DoExpressCheckoutPaymentRequestDetails);
exit;
}
$DoExpressCheckoutPaymentRequestDetails->setPaymentDetails($PaymentDetails);
$DoExpressCheckoutPaymentRequestDetails->setPayerID($ppbuyerid, 'iso-8859-1');
$DoExpressCheckoutPaymentRequestDetails->setToken($pptoken, 'iso-8859-1');
$DoExpressCheckoutPaymentRequestDetails->setPaymentAction($action, 'iso-8859-1');
$DoExpressCheckoutPayment =& Services_PayPal::getType('DoExpressCheckoutPaymentRequestType');
if (Services_PayPal::isError($DoExpressCheckoutPayment)) {
var_dump($DoExpressCheckoutPayment);
exit;
}
$DoExpressCheckoutPayment->setDoExpressCheckoutPaymentRequestDetails($DoExpressCheckoutPaymentRequestDetails);
$result = $caller->DoExpressCheckoutPayment($DoExpressCheckoutPayment);
if (Services_PayPal::isError($result)) {
var_dump($result);
} else {
/* Success */
echo "<h2>Order Complete</h2>\n";
echo "<pre>";
print_r($result);
echo "</pre>";
}
--8<---- snip -------------------
Thanks,
-Jason
|