我正在使用PHP paypal Restfull SDK。 当用户将重定向到paypal网站进行支付。我们知道显示项目列表&金额信息。 但我需要显示增值税以代替税收标签。
如何更改税收标签? 请告诉我。
SDK链接: https://github.com/paypal/PayPal-PHP-SDK
问题: https://github.com/paypal/PayPal-PHP-SDK/issues/460
不知道为什么他们说不可能。
这是我的代码。
function paypal_payment(){
if ($config) {
set_config($config);
}
require __DIR__ . '/../bootstrap.php';
$payer = new Payer();
$payer->setPaymentMethod("paypal");
foreach ($pay_data->item_list as $item) {
$item1 = new Item();
$item1->setName($item['title'])
->setDescription($item['description'])
->setCurrency($pay_data->currency)
->setQuantity($item['quantity'])
->setTax($item['tax'])
->setPrice($item['price']);
$all_items[] = $item1;
}
$itemList = new ItemList();
$itemList->setItems($all_items);
if (!isset($pay_data->shipping_charg)) {
$pay_data->shipping_charg = 0;
}
if (!isset($pay_data->tax)) {
$pay_data->tax = 0;
}
if (!isset($pay_data->subtotal)) {
$pay_data->subtotal = 0;
}
$details = new Details();
$details->setShipping($pay_data->shipping_charg)
->setTax($pay_data->tax)
->setSubtotal($pay_data->subtotal);
$amount = new Amount();
$amount->setCurrency($pay_data->currency)
->setTotal($pay_data->total)
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber($pay_data->invoice_number);
// ### Redirect urls
// Set the urls that the buyer must be redirected to after
// payment approval/ cancellation.
$baseUrl = getBaseUrl();
$redirectUrls = new RedirectUrls();
if ($is_for_order === false) {
$redirectUrls->setReturnUrl(lang_anchor('PaypalTest/payment_done'))
->setCancelUrl(lang_anchor('PaypalTest/cancel'));
} else {
$redirectUrls->setReturnUrl(lang_anchor('payment/payment_done/true'))
->setCancelUrl(lang_anchor('payment/cancel'));
}
// ### Payment
// A Payment Resource; create one using
// the above types and intent set to 'sale'
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
// For Sample Purposes Only.
$request = clone $payment;
// ### Create Payment
// Create a payment by calling the 'create' method
// passing it a valid apiContext.
// (See bootstrap.php for more on `ApiContext`)
// The return object contains the state and the
// url to which the buyer must be redirected to
// for payment approval
try {
$payment->create($apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
$data = ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
return $data;
exit(1);
}
// ### Get redirect url
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $payment->getApprovalLink()
// method
$approvalUrl = $payment->getApprovalLink();
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
// ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "$approvalUrl", $request, $payment);
redirect($approvalUrl);
return $approvalUrl;
}
谢谢:-) Ankit Vadariya
答案 0 :(得分:0)
您只需要在具有重定向过程的网站页面中将Tax字段替换为Tax字段,如下所示:
替换此字段:
<input name="VAT_1" value="yourAmount" type="hidden">
。通过强>
<input name="TAX_1" value="yourAmount" type="hidden">
请注意:输入名称可能会更改,但会包含VAT
。