【问题标题】:django-paypal setup for PDT gives me an errorPDT 的 django-paypal 设置给了我一个错误
【发布时间】:2012-03-16 14:31:37
【问题描述】:

我正在使用 django-paypal[1] 的 dcramers 版本。我正在尝试通过我的沙盒业务 paypal 帐户 xpanta_XXX_biz@paypal.com 将 PDT 与订阅一起使用

这是我的意见.py[2]:

def subscribe_confirmation(request, username):
    try:
        user = User.objects.get(username=username)
    except User.DoesNotExist:
        raise Http404(u'User not Found')
    paypal_dict = {
        "cmd": "_xclick-subscriptions",
        "business": "xpanta_XXX_biz@gmail.com",
        "a3": "9.99",                      # monthly price
        "p3": 1,                           # duration of each unit (depends on unit)
        "t3": "M",                         # duration unit ("M for Month")
        "src": "1",                        # make payments recur
        "sra": "1",                        # reattempt payment on payment error
        "no_note": "1",                    # remove extra notes (optional)
        "item_name": "monthly subscription",
        "notify_url": "http://mydomain.com/paypal/pdt/",
        "return_url": "http://mydomain.com/pp_success/%s/" % username,
        "cancel_return": "http://mydomain.com/pp_cancel/%s/" % username,
    }

    # Create the instance.
    form = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe")
    variables = RequestContext(request, {'user': user, 'form': form, 'type': 'monthly', 'price': '9.99'})
    return render_to_response("subscribe_confirm.html", variables)

但是,当我登录到贝宝网站以测试订阅我的服务时(使用我的普通贝宝凭据。由于某种原因,我无法使用我的个人沙盒帐户 xpanta_XXX_per@gmail.com 来测试支付系统) 我得到这个错误:

The link you have used to enter the PayPal system is invalid. Please review the link and try again.

错误底部有一个“返回商户”按钮,可将我返回到取消页面(如预期的那样)。

我做错了什么?

PS:添加urls.py部分:

(...
    url(r'^pp_success/(\w+)/$', pp_success),
    url(r'^pp_cancel/(\w+)/$', pp_cancel),
...)

urlpatterns += patterns('',
    url(r'^paypal/pdt/', include('paypal.standard.pdt.urls')),
)

[1]https://github.com/dcramer/django-paypal

[2] 自述文件(“使用 PayPal Payments 标准 PDT”部分)中描述的其他步骤保持不变,完全按照描述完成。

【问题讨论】:

    标签: django django-paypal


    【解决方案1】:

    我想我已经找到了答案。

    在自述文件中说,为了在模板中呈现表单,我们需要这样做:{{ form.render }}

    它并没有说,如果您需要使用您的沙盒帐户,您需要像这样呈现它:

    {{ form.sandbox }}

    【讨论】:

      猜你喜欢
      • 2015-07-01
      • 2017-05-09
      • 2016-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多