1

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

这是我的views.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 支付标准 PDT”一节)中描述的其他步骤保持不变,完全按照描述完成。

4

1 回答 1

0

我想我已经找到了答案。

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

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

{{ form.sandbox }}

于 2012-03-17T06:17:34.053 回答