首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Django应用中实现PayPal网络

在Django应用中实现PayPal网络
EN

Stack Overflow用户
提问于 2018-01-02 19:39:05
回答 1查看 1.1K关注 0票数 1

我正在用Django 2.0编写一个应用程序

它是一个多成员应用程序。我必须执行PayPal支付方法,并根据收到的付款激活会员资格。

为此,我在PayPal中创建了一个按钮,生成代码如下

upgrade.html

代码语言:javascript
复制
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="<button-id>">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

views.py

代码语言:javascript
复制
class Pricing(TemplateView):
    template_name = 'membership/pricing.html'


class Upgrade(TemplateView):
    template_name = 'membership/upgrade.html'


class PaymentSuccess(TemplateView):
    template_name = 'membership/payment-success.html'


class PaymentFailed(TemplateView):
    template_name = 'membership/payment-failed.html'


def paypal_ipn(request):
    # IPN response goes here

urls.py

代码语言:javascript
复制
urlpatterns = [
    path('pricing/', Pricing.as_view(), name='pricing'),
    path('upgrade/', Upgrade.as_view(), name='upgrade'),
    path('payment-success/', PaymentSuccess.as_view(), name='payment-success'),
    path('payment-failed/', PaymentFailed.as_view(), name='payment-failed'),
    path('paypal-ipn/', paypal_ipn, name='paypal-ipn'),
]

一切都很好,因为付款和用户被重定向到payment-success页面。

但是,如何接收付款确认,以便处理成员资格并在数据库中记录交易数据?

我已经从url instant payment notification上的paypal sandbox accoun中的设置中启用了https://example.com/paypal-ipn/

由于一些限制,我不想使用django-paypal插件。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-03 03:45:43

您可以创建自己的IPN处理页面以接收PayPal IPN消息。下面是IPN示例代码。

https://github.com/paypal/ipn-code-samples

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48066824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档