2016-06-30 25 views
0

我試圖執行3個經典步驟的支付寶立即購買按鈕自定義變量到「付款完成頁面」不工作

我想實現是有一個ID從步驟1將第3步。我試圖做的是這一領域的插入像「定製」變量:

<input type="hidden" name="custom" value="--Server Code--"> 

支付寶付款後,貝寶重定向我到我的網頁:

http://www.mysite.cm/tx=blalba?aaaa 

在這個網址有沒有自定義字段。如果從API,我聯繫PayPal獲得銷售詳情,我沒有得到任何與我的自定義字段相關的信息。

我在做什麼錯了? 我正在考慮使用cookie的工作,但我更願意以標準方式來完成。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> 
     <input type="hidden" name="cmd" value="_s-xclick"> 
     <input type="hidden" name="return" value="testestest"> 
     <input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal è il metodo rapido e sicuro per pagare e farsi pagare online."> 
     <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1"> 
    </form> 

回答

2

PayPal自定義變量在IPN(實例付款通知)中返回,而不是在用戶完成付款後返回到您的網站。

在你的情況只是一個會話變量就足夠了。

編輯:

另一種方法可能會在「迴歸」字段中添加適當的URL值。例如:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
    <input type="hidden" name="cmd" value="_xclick"> 
    <input type="hidden" name="return" value="http://www.website.com?pram=value"> 
    <input type="hidden" name="cancel" value="http://www.website.com?param=value"> 
    <input type="hidden" name="business" value="[email protected]"> 
    <input type="hidden" name="item_name" value="Test"> 
    <input type="hidden" name="amount" value="9.00"> 
    <input type="hidden" name="currency_code" value="EUR"> 

    <input type="image" src="https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal è il metodo rapido e sicuro per pagare e farsi pagare online."> 
    <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1"> 
</form> 
+0

我不確定。 '因爲如果我從在線配置中將自定義字段設置爲一個值,我可以在詳細信息和查詢字符串中找到它。問題是從後面的代碼中分配它!我可以繼續使用IPN,但它更「異步」。 –

+0

一個問題,爲什麼你需要自定義變量? – CCamilo

+0

跟蹤特定會話。該過程由以下步驟組成:基於在步驟1收集的數據收集數據,付款,創建文檔。 我需要一個標識符,但我覺得它存儲在cookie或會話中很糟糕! –

0

現有的答案已經提到,IPN是要走的路,但現在缺少的是如何真正實現更多的相關信息。

我最近這個做我自己,所以這裏是爲我工作的解決方案:

首先,您需要將您的ID添加到您的「立即付款」按鈕的HTML,例如進入「自定義」變量,就像問題中所示。

在我自己的實現,我不得不使用「自定義」變量(不記得細節了)一些問題,所以我通過我的ID作爲IPN「通知」的URL網址參數,而不是:

<input type="hidden" name="notify_url" value="https://example.com/notify/?id=xyz"> 

下面是我的按鈕完整的HTML代碼:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> 
    <input type="hidden" name="cmd" value="_s-xclick"> 
    <input type="hidden" name="hosted_button_id" value="ABCDEFGHILJKLM"> 
    <table> 
    <tr><td><input type="hidden" name="on0" value="Betrag">Betrag</td></tr><tr><td><select name="os0"> 
     <option value="Gebuehr">Gebuehr €3,50 EUR</option> 
     <option value="Gebuehr und Spende">Gebuehr und Spende €5,00 EUR</option> 
    </select> </td></tr> 
    </table> 
    <input type="hidden" name="currency_code" value="EUR"> 
    <input type="image" src="https://www.paypalobjects.com/de_DE/DE/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Jetzt einfach, schnell und sicher online bezahlen – mit PayPal."> 
    <img alt="" border="0" src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif" width="1" height="1"> 
    <input type="hidden" name="notify_url" value="https://example.com/notify/?id=xyz"> 
</form> 

付款過程完成後,PayPal將發佈一個IPN message我通知URL,其中包含了大量的信息有關transa ction (詳情請見鏈接)

我的ID是通過URL參數傳遞,這樣我就可以得到它(在PHP)這樣的:

$uid = ""; 
if (!empty($_GET['id'])) { 
    $uid = $_GET['id']; 
} 

和當然,你需要check whether the IPN call is actually coming from PayPal