django-paypal 设置

发布于 2024-07-17 09:03:51 字数 2287 浏览 5 评论 0原文

有人设置过 django-paypal 吗? 这是它的链接这里

我有“myproject”设置,我的文件夹结构如下所示:

myproject > 贝宝> (stdandard 和 pro 文件夹)

到我的 settins.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)

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

当我访问 http://127.0.0.1:8000/account/ payment-url/ 并提交表单...

我收到 ValueError :“字典更新序列元素 #0 的长度为 1;需要 2”

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)

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/

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)
, 'buy_my_item'), )

and in my account view I added:

--- 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:

  1. params.update(item)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难愈 2024-07-24 09:03:51

在您的代码中...

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

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

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

编辑

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

您的请求应该包含通知网址、返回网址和取消返回。 您向 Paypal 提供的所有三个网址。

Paypal 将向这些 URL 发送消息。

由于 Paypal 会将消息发送到这些 URL,因此您必须将它们放入 urls.py 中。 您必须为这三个 url 编写视图函数。 您的 PayPal 回复将发送给这些网址。

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.

一场信仰旅途 2024-07-24 09:03:51

PayPal django 集成 帖子应该会对您有所帮助。

PayPal django Integration post should help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文