繁体   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