简体   繁体   English

贝宝开发人员Beta:测试交易未在沙盒业务帐户中列出

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

So..... it seems Paypal Developer decided to change everything on their brand new website as of 2013, and it's making my life miserable for the past few days. 所以.....看来,Paypal Developer决定从2013年起改变其全新网站上的所有内容,这让过去几天我的生活很痛苦。 Please note that I'm totally new to integrating Paypal in website. 请注意,我是将Paypal集成到网站中的全新手。 I tried to follow this tutorial, but it's from 2009: http://www.codeproject.com/Articles/42894/Introduction-to-PayPal-for-C-ASP-NET-developers 我尝试遵循本教程,但该教程来自2009年: http : //www.codeproject.com/Articles/42894/Introduction-to-PayPal-for-C-ASP-NET-developers

I am not using the Paypal Api. 我没有使用Paypal Api。 Don't know if i should? 不知道我应该吗?

Here's what I did: 这是我所做的:

1) I went to https://developer.paypal.com/ and logged in with my own paypal account. 1)我去了https://developer.paypal.com/,并用自己的Paypal帐户登录。

2) This is one of the tricky part. 2)这是棘手的部分之一。 In the tutorials i've checked, there was an option to create "preconfigured test accounts", but it's not available anymore. 在我检查过的教程中,有一个选项可以创建“预配置的测试帐户”,但现在不再可用。 So i created two test accounts (or so i think) with their new Create Account button. 因此,我使用其新的“创建帐户”按钮创建了两个测试帐户(或我认为)。 One personal (buyer) and one Business (seller). 一位个人(买方)和一位企业(卖方)。 No tutorials mentionned if the mail adress of those test accounts needs to exists or if they can be fictitious... i made the buyer a real one (which i created for this test) and the seller a fictitious one. 如果需要存在这些测试帐户的邮件地址,或者它们可以是虚构的,则没有提及任何教程……我使买方成为真实的(我为此测试创建的),而卖方则使之成为虚拟的。

3) In my Test Seller Account, I activated AutoReturn with my CallbackUrl and I activated Payment Data Transfer (PDT) and placed the token in my web.config. 3)在我的测试卖方帐户中,我使用CallbackUrl激活了自动退货,并且激活了付款数据传输(PDT)并将令牌放置在我的web.config中。

4) Following the tutorial yet again, i created my .Net Visual Studio project. 4)再次按照本教程操作,我创建了.Net Visual Studio项目。 Something really simple, a Default.aspx, a Callback.aspx and a Cancelled.aspx. 真正简单的东西是Default.aspx,Callback.aspx和Cancelled.aspx。 Callback for checking if the transaction was a success and Cancelled to check if the user cancelled the transaction. 回调以检查交易是否成功,并单击取消以检查用户是否取消交易。

5) Here is the code/Paypal hiddenfield variables of Default.aspx. 5)这是Default.aspx的代码/ Paypal隐藏字段变量。 Nothing really fancy: 没什么好看的:

<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) Code-behind of Callback.aspx, taken and adapted from the 2009 tutorial mentionned above: 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) Up to there, it's not that complicated. 7)到那为止,没有那么复杂。 Afterwards, I first login in my Paypal Developer Account. 之后,我首先登录我的Paypal开发者帐户。 I start the project and test it out. 我启动该项目并进行测试。 Push the buy now button, get redirected to Paypal Sandbox Test Store as expected. 按立即购买按钮,按预期重定向到贝宝沙盒测试商店。 I login with my buyer test account, click Pay Now. 我使用买家测试帐户登录,然后单击“立即付款”。 Process. 处理。 Transaction Successful. 交易成功。 The page redirects me to Callback.aspx as expected, and the Success message is shown. 页面按预期将我重定向到Callback.aspx,并显示成功消息。 Not so shabby. 不太破旧。

8) But here is the other tricky part. 8)但这是另一个棘手的部分。 In the Paypal Developer site, i see the buyer/seller notifications saying that a payment was sent/received. 在Paypal开发人员网站上,我看到买家/卖家通知说已付款/已收到。 I login as the test buyer in sandbox and check the recent activity: an entry shows that a payment was done and Completed (status). 我以测试买家的身份登录沙箱,并检查了最近的活动:一个条目显示付款已完成并已完成(状态)。 I login as the test seller, i check the recent activity and i see no transaction entry, but the Paypal Balance grows, meaning the payment was added?!? 我以测试卖方的身份登录, 检查了最近的活动,但没有看到任何交易记录,但是Paypal余额增加了,这意味着已添加了付款?! ... ...

I don't understand... is this suppose to happen? 我不明白...这应该发生吗? Did i do something wrong? 我做错什么了吗? If i go live with these settings is everything gonna go wrong? 如果我使用这些设置,一切都会出错吗?

In a video tutorial, which didn't really helped me, it clearly showed a transaction entry in the seller test account. 在没有真正帮助我的视频教程中,它清楚地显示了卖方测试帐户中的交易条目。 Why didn't mine showed up, or any of the bazillion test transactions i've done until now? 为什么我的交易没有出现,或者直到现在我还没有进行过如此庞大的测试交易?

Can anyone make sure the process is legit? 任何人都可以确保该过程合法吗? It would reassure me a great deal. 这会让我放心。 I feel uncomfortable messing with money when i'm not really sure about this. 当我不确定这笔钱时,我感到不舒服。 Will this code be enough to create post-payment logic like update my database to mention the payment was done or cancelled? 此代码是否足以创建后付款逻辑,例如更新我的数据库以提及已完成或已取消付款? If there is an easier way, don't hesitate to tell me. 如果有更简单的方法,请不要犹豫告诉我。

Thank you so much in advance and sorry for the epic novel. 提前非常感谢您,并为这部史诗般的小说感到抱歉。

New Sandbox Business accounts currently have Payments Pro enabled on them by default and the account layout is different than a Standard Business or Personal account. 当前,默认情况下,新的Sandbox Business帐户启用了Payments Pro,并且帐户布局与标准企业帐户或个人帐户不同。 With a Pro account you do not see the transactions on the Account Overview page when you first log in. 使用Pro帐户时,首次登录时不会在“帐户概述”页面上看到交易。

To view the transactions on the Pro account you need to open the History tab. 要查看Pro帐户上的交易,您需要打开“历史记录”标签。 You figured that out and you're good to go. 您知道了这一点,就很好了。 I was concerned that transactions weren't appearing on the History tab but that doesn't seem to be the problem so that's a relief. 我担心交易没有出现在“历史记录”选项卡上,但这似乎不是问题,所以这很轻松。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM