簡體   English   中英

貝寶開發人員Beta:測試交易未在沙盒業務帳戶中列出

[英]Paypal Developer Beta: Test transaction not listed in Sandbox Business account

所以.....看來,Paypal Developer決定從2013年起改變其全新網站上的所有內容,這讓過去幾天我的生活很痛苦。 請注意,我是將Paypal集成到網站中的全新手。 我嘗試遵循本教程,但該教程來自2009年: http : //www.codeproject.com/Articles/42894/Introduction-to-PayPal-for-C-ASP-NET-developers

我沒有使用Paypal Api。 不知道我應該嗎?

這是我所做的:

1)我去了https://developer.paypal.com/,並用自己的Paypal帳戶登錄。

2)這是棘手的部分之一。 在我檢查過的教程中,有一個選項可以創建“預配置的測試帳戶”,但現在不再可用。 因此,我使用其新的“創建帳戶”按鈕創建了兩個測試帳戶(或我認為)。 一位個人(買方)和一位企業(賣方)。 如果需要存在這些測試帳戶的郵件地址,或者它們可以是虛構的,則沒有提及任何教程……我使買方成為真實的(我為此測試創建的),而賣方則使之成為虛擬的。

3)在我的測試賣方帳戶中,我使用CallbackUrl激活了自動退貨,並且激活了付款數據傳輸(PDT)並將令牌放置在我的web.config中。

4)再次按照本教程操作,我創建了.Net Visual Studio項目。 真正簡單的東西是Default.aspx,Callback.aspx和Cancelled.aspx。 回調以檢查交易是否成功,並單擊取消以檢查用戶是否取消交易。

5)這是Default.aspx的代碼/ Paypal隱藏字段變量。 沒什么好看的:

<form id="form1" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" runat="server">
<div>
    <!-- Type: Buy Now/Simple Payment -->
    <input type="hidden" name="cmd" value="_xclick" />
    <!-- PayPal ID or an email address associated with your PayPal account -->
    <input type="hidden" name="business" value="THE-SELLER-MAIL-ADRESS" />
    <!-- Name of service selected -->
    <input type="hidden" name="item_name" value="Forfait Regulier" />
    <!-- Currency -->
    <input type="hidden" name="currency_code" value="CAD" />
    <!-- Return method: 2 – the buyer’s browser is redirected to the return URL by using the POST method, and all payment variables are included -->
    <input type="hidden" name="rm" value="2" />
    <!-- Button text -->
    <input type="hidden" name="cbt" value="Retourner sur Bloc D'Affaires" />
    <!-- Cancel callback url -->
    <input type="hidden" name="cancel_return" value="http://dev.triarts.ca/Pages/Cancelled.aspx" />
    <!-- Amount -->
    <input type="hidden" name="amount" value="10.00" />
    <!-- Don't show Shipping adress form -->
    <input type="hidden" name="no_shipping" value="1" />
    <!-- Don't show seller note box -->
    <input type="hidden" name="no_note" value="1" /> 
    <!-- Button -->
    <input type="submit" value="Payer" />
</div>
</form>

6)Callback.aspx的代碼隱藏,取自並改編自上述2009教程:

protected void Page_Load(object sender, EventArgs e)
{
    string authToken = WebConfigurationManager.AppSettings["PDTToken"];

    //read in tx token from querystring
    string txToken = Request.QueryString.Get("tx");


    string query = string.Format("cmd=_notify-synch&tx={0}&at={1}",
                          txToken, authToken);

    // Create the request back
    string url = WebConfigurationManager.AppSettings["PayPalSubmitUrl"];
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

    // Set values for the request back
    req.Method = "POST";
    req.ContentType = "application/x-www-form-urlencoded";
    req.ContentLength = query.Length;

    // Write the request back IPN strings
    StreamWriter stOut = new StreamWriter(req.GetRequestStream(),
                             System.Text.Encoding.ASCII);
    stOut.Write(query);
    stOut.Close();

    // Do the request to PayPal and get the response
    StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
    string strResponse = stIn.ReadToEnd();
    stIn.Close();

    // If response was SUCCESS, parse response string and output details
    if (strResponse.StartsWith("SUCCESS"))
    {
        Label1.Text = "Success";
    }
    else
    {
        Label1.Text = "Oooops, something went wrong...";
    }
}

7)到那為止,沒有那么復雜。 之后,我首先登錄我的Paypal開發者帳戶。 我啟動該項目並進行測試。 按立即購買按鈕,按預期重定向到貝寶沙盒測試商店。 我使用買家測試帳戶登錄,然后單擊“立即付款”。 處理。 交易成功。 頁面按預期將我重定向到Callback.aspx,並顯示成功消息。 不太破舊。

8)但這是另一個棘手的部分。 在Paypal開發人員網站上,我看到買家/賣家通知說已付款/已收到。 我以測試買家的身份登錄沙箱,並檢查了最近的活動:一個條目顯示付款已完成並已完成(狀態)。 我以測試賣方的身份登錄, 檢查了最近的活動,但沒有看到任何交易記錄,但是Paypal余額增加了,這意味着已添加了付款?! ...

我不明白...這應該發生嗎? 我做錯什么了嗎? 如果我使用這些設置,一切都會出錯嗎?

在沒有真正幫助我的視頻教程中,它清楚地顯示了賣方測試帳戶中的交易條目。 為什么我的交易沒有出現,或者直到現在我還沒有進行過如此龐大的測試交易?

任何人都可以確保該過程合法嗎? 這會讓我放心。 當我不確定這筆錢時,我感到不舒服。 此代碼是否足以創建后付款邏輯,例如更新我的數據庫以提及已完成或已取消付款? 如果有更簡單的方法,請不要猶豫告訴我。

提前非常感謝您,並為這部史詩般的小說感到抱歉。

當前,默認情況下,新的Sandbox Business帳戶啟用了Payments Pro,並且帳戶布局與標准企業帳戶或個人帳戶不同。 使用Pro帳戶時,首次登錄時不會在“帳戶概述”頁面上看到交易。

要查看Pro帳戶上的交易,您需要打開“歷史記錄”標簽。 您知道了這一點,就很好了。 我擔心交易沒有出現在“歷史記錄”選項卡上,但這似乎不是問題,所以這很輕松。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM