我正在使用dcramers版本的django-paypal [1]。我正在尝试使用PDT订阅我的沙箱业务paypal帐户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)
然而,当我登录paypal网站以测试订阅我的服务时(使用我的普通paypal凭据。出于某种原因,我无法使用我的个人沙盒帐户xpanta_XXX_per@gmail.com
来测试支付系统)我收到此错误:
The link you have used to enter the PayPal system is invalid. Please review the link and try again.
错误底部有一个“Return to Merchant”按钮,它返回取消页面(正如预期的那样)。
我做错了什么?
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”部分)中描述的其他步骤不会改变,完全按照描述完成。
答案 0 :(得分:0)
我想我找到了答案。
自述文件中的表示为了在模板中呈现表单,我们需要这样做:{{ form.render }}
它没有说,如果你需要使用你的沙盒帐户,你需要像这样呈现它:
{{ form.sandbox }}