有没有人设置过django-paypal? 这是链接在这里
我已经设置了“myproject”,我的文件夹结构如下:
myproject > paypal > (stdandard and pro 文件夹)
我在settings.py文件中添加了以下内容:
INSTALLED_APPS = (
'myproject.paypal.standard',
'myproject.paypal.pro',
)
在我的账户应用程序的URL文件中,我添加了以下内容:
urlpatterns += patterns('myproject.account.views',
(r'^payment-url/$', 'buy_my_item'),
)
在我的账户视图中,我添加了:
from myproject.paypal.pro.views import PayPalPro
from myproject.paypal.pro.forms import PaymentForm, ConfirmForm
def buy_my_item(request):
item = {'amt':"10.00", # amount to charge for item
'inv':"1111", # unique tracking variable paypal
'custom':"2222", # custom tracking variable for you
'cancelurl':"http://127.0.0.1:8000/", # Express checkout cancel url
'returnurl':"http://127.0.0.1:8000/"} # Express checkout return url
kw = {'item':'item', # what you're selling
'payment_template': 'pro/payment.html', # template to use for payment form
'confirm_template': ConfirmForm, # form class to use for Express checkout confirmation
'payment_form_cls': PaymentForm, # form class to use for payment
'success_url': '/success', # where to redirect after successful payment
}
ppp = PayPalPro(**kw)
return ppp(request)
---编辑--------- 然后,我将pro和standard模板文件夹添加到我的项目模板文件夹中。
当我访问http://127.0.0.1:8000/account/payment-url/并提交表单时...
出现了ValueError:"dictionary update sequence element #0 has length 1; 2 is required"
Traceback:
File "...\accounts\views.py" in buy_my_item
655. return ppp(request)
File "...\paypal\pro\views.py" in __call__
115. return self.validate_payment_form()
File "...\paypal\pro\views.py" in validate_payment_form
133. success = form.process(self.request, self.item)
File "...\paypal\pro\forms.py" in process
- params.update(item)
item
字典。 - jb.