django-paypal设置 [英] django-paypal setup

查看:247
本文介绍了django-paypal设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人设置django-paypal?以下是其链接 here



我有myproject设置,我的文件夹sturecture看起来像这样:



myproject> paypal> stdandard和pro文件夹)



到我的settins.py文件我添加了

  INSTALLED_APPS =(
'myproject.paypal.standard',
'myproject.paypal.pro',



  urlpatterns + = patterns('myproject.account.views',
(r'^ payment-url / $','buy_my_item'),

,在我的帐户视图中我添加了:

 从myproject。 paypal.pro.views导入PayPalPro 
从myproject.paypal.pro.forms import PaymentForm,ConfirmForm

def buy_my_item(request):
item = {'amt':10.00 ,#金额收取项目
'inv':1111,#唯一跟踪变量paypal
'cu 2222,#为您定制跟踪变量
'cancelurl':http://127.0.0.1:8000/,#快速结帐取消网址
'returnurl':http: //127.0.0.1:8000/}#快速结帐返回url

kw = {'item':'item',#你要卖的
'payment_template':'pro /payment.html',#模板用于付款表单
'confirm_template':ConfirmForm,#表单类用于快速结帐确认
'payment_form_cls':PaymentForm,#表单类用于付款
'success_url':'/ success',#成功付款后重定向
}

ppp = PayPalPro(** kw)
return ppp(request)

---编辑---------
然后,我添加了专业和标准的模板文件夹到我的项目模板文件夹。



当我走 http://127.0.0.1:8000/account/payment-url/ 和提交表单...



我得到一个ValueError:字典更新序列元素#0的长度为1; 2需要



追溯:

 文件... \accounts\views.py在buy_my_item 
655. return ppp(request)
文件... \paypal\pro\views.py在__call__
115 。return self.validate_payment_form()
文件... \paypal\pro\views.pyin validate_payment_form
133. success = form.process(self.request,self.item)
文件... \paypal\pro\forms.py进程



< $开始=35>

  • params.update(item)


  • 解决方案

    在您的代码中

     'payment_form_cls':'payment_form_cls',#表单类用于付款

    这必须是用于验证的Form对象。

     'payment_form_cls':MyValidationForm,#表单类用于付款






    修改



    http://github.com/johnboxall/django-paypal/tree/master



    您的请求应为包括一个notify-url,return-url和cancel-return。 PayPal将发送邮件到这些URL。



    由于Paypal将发送消息到这些URL,你必须把它们放在你的urls.py中。您必须编写这三个URL的查看功能。这些网址将向您发送您的PayPal回复。


    Has anyone setup django-paypal? Here is the link to it here?

    I have "myproject" setup, and my folder sturecture looks like this:

    myproject > paypal > (stdandard and pro folders)

    to my settins.py file I added

    INSTALLED_APPS = (
        'myproject.paypal.standard',
        'myproject.paypal.pro',
    )
    

    in my url's file for my account app I added:

    urlpatterns += patterns('myproject.account.views',
        (r'^payment-url/$', 'buy_my_item'),                   
    )
    

    and in my account view I added:

    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)
    

    --- EDIT --------- Then, I added the pro and standard template folders to my projects template folder.

    When I go to http://127.0.0.1:8000/account/payment-url/ and submit the form...

    I get a 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
    

    1. params.update(item)

    解决方案

    In your code...

      'payment_form_cls': 'payment_form_cls',  # form class to use for payment
    

    This must be a Form object that's used for validation.

       'payment_form_cls': MyValidationForm,  # form class to use for payment
    


    Edit

    http://github.com/johnboxall/django-paypal/tree/master

    Your request is supposed to include a notify-url, return-url and cancel-return. All three url's YOU provide to Paypal.

    Paypal will send messages to these URL's.

    Since Paypal will send messages to these URL's, YOU must put them in your urls.py. You must write view functions for these three urls'. These urls will have your paypal responses sent to them.

    这篇关于django-paypal设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆