2016-01-06 18 views
2

我正在使用PHP paypal Restfull SDK。 當用戶將重定向到貝寶網站付款。因爲我們知道顯示項目清單&的金額信息。 但我需要顯示增值稅替代稅收標籤。更改字段名稱稅收爲增加

如何更改稅收標籤? 請讓我知道。

鏈接中的SDK: https://github.com/paypal/PayPal-PHP-SDK

問題: https://github.com/paypal/PayPal-PHP-SDK/issues/460

不知道爲什麼,他們說不可能的。

這裏是證明: enter image description here

這裏是我的代碼。

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

您只需要更換在你的網站頁面稅字段中輸入您的增值稅場,你必須重定向過程那樣:

替換該場:

<input name="VAT_1" value="yourAmount" type="hidden"> 

帶:

<input name="TAX_1" value="yourAmount" type="hidden"> 

需要注意的是:輸入名稱可能會改變,但它將包含VAT

+1

謝謝devpro! 但我有restfull API。所以在我的情況下這是行不通的。 它將使用簡單的HTML方法。 –

+0

是的,它會在簡單的HTML上工作。你是否意味着你有一個paypal的直接網址? @Ankitvadariya – devpro

+0

是的! SDK將生成URL。 另外,我曾嘗試在SDK上的每個Word中更改Tax To Vat。 –