2012-03-16 31 views
1

我正在使用django-paypal的dcramers版本[1]。我試圖用PDT與我的沙箱業務的貝寶賬戶訂閱[email protected]用於PDT的django-paypal安裝程序給我一個錯誤

這是我的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": "[email protected]", 
     "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憑證出於某種原因,我不能用我個人的沙盒帳戶[email protected]爲了測試支付系統。)我得到這個錯誤:

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

我想我找到了答案。

自述文件

它說,爲了使表單模板,我們需要這樣做:{{ form.render }}

這並不是說,無論如何,如果你需要使用沙箱帳戶,你需要使其呈現如下:

{{ form.sandbox }}

相關問題