集成 django-paypal

发布于 2024-08-27 12:30:18 字数 407 浏览 3 评论 0原文

我正在尝试将 Django-Paypal 集成到一个网站上,一旦客户付款,我需要发送一个动态 URL,用户可以从中下载一些特定信息。

我将所有用户注册到一个 URL,允许他们购买该文档。该 URL 只能由使用 django-registration 验证电子邮件 ID 的注册用户访问,允许用户连接到 paypal 并进行付款。

如何捕获信号并根据此信息验证哪个用户已为他/她购买的产品付款

1)我需要知道两个信息,哪个用户进行了付款,以及他或她为哪个产品付款付款吗?

2) 只有当我有了这些信息,我才能通过电子邮件发送正确的 UR:L。

任何帮助表示赞赏。我不太确定 django-signals 是如何工作的。 payment_was_successful 信号返回哪些详细信息?

我正在使用IPN

I am trying to integrate Django-Paypal onto a site, where once the customer makes a payment I need to send a dynamic URL from which the user can download some specific information.

I am registering all users to a URL which allows them to buy the document. The URL which can only be accessed by a registered user with a verified email ids using django-registration, allows the user to connect to paypal and make payment.

How do I capture the signal and verify which user has made the payment for which product he/she is purchased, based on this information

1) I need to know two information, which user made the payment, and for which product did he or she make the payment?

2) Only if I have these information can I send the right UR:L by email.

Any help appreciated. I am not very sure how django-signals work. What all details does payment_was_successful signal return?

I am using IPN

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

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

发布评论

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

评论(1

萤火眠眠 2024-09-03 12:30:18

要捕获信号,您需要定义函数,并将其连接到信号,如下所示:

from paypal.standard.ipn.signals import payment_was_successful
def my_payment_was_successful_handler(sender, **kwargs):
    pass

payment_was_successful.connect(my_payment_was_successful_handler)

为了能够识别 IPN 消息所涉及的用户,我通常修改 paypal 按钮以传递名为 custom 在表单中设置为 django user.id 或其他一些您可以查找以识别您的用户的标识符。 custom 变量在 sender 参数中发回,您可以找到用户。

为了查找产品,product_name 也会在 sender 中发送到上面列出的处理程序。您可能会有一个产品模型,并且您需要通过此产品名称查找它们,以便通过电子邮件发送适当的内容。

To capture the signal, you define your function, and connect it to the signal like this:

from paypal.standard.ipn.signals import payment_was_successful
def my_payment_was_successful_handler(sender, **kwargs):
    pass

payment_was_successful.connect(my_payment_was_successful_handler)

To be able to identify the user the IPN message is about, I usually modify the paypal button to pass a field named custom along in the form set to the django user.id or some other identifier you can look up to identify your user. The custom variable is sent back in the sender argument and you can find the user.

To find the product, the product_name is also sent in the sender to the handler listed above. You'll probably have a model for your products, and you'll want to look them up by this product_name to send the appropriate thing in email.

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