【问题标题】:Flask gateway equlivent in DjangoDjango 中的 Flask 网关等价物
【发布时间】:2021-07-05 10:52:47
【问题描述】:

我正在 Django 中设置我的 Braintree 网络挂钩,因为 Braintree docs 说我必须添加此方法

from flask import Flask, request, render_template, Response
...
def webhook():
    webhook_notification = gateway.webhook_notification.parse(str(request.form['bt_signature']), request.form['bt_payload'])

    # Example values for webhook notification properties
    print(webhook_notification.kind)
    print(webhook_notification.timestamp) 

    return Response(status=200)

一切正常,除了我不知道 gateway 是什么,而且我收到 undefined name error

我的 Django 代码

@csrf_exempt
def webhook(request):
    print("post:: ", request.POST)

    webhook_notification = gateway.webhook_notification.parse(str(request.form["bt_signature"]), request.form["bt_payload"])
    
    print(webhook_notification.kind)
    print(webhook_notification.timestamp)

    return HttpResponse("Ok")

抱歉,如果遗漏了一些东西,我还没有尝试 flask

【问题讨论】:

    标签: python braintree


    【解决方案1】:

    这与 Flask 和 Django 无关。

    这是gateway object you configure任何使用 Braintree Python SDK,á la

    import braintree
    
    gateway = braintree.BraintreeGateway(
        braintree.Configuration(
            braintree.Environment.Sandbox,
            merchant_id="use_your_merchant_id",
            public_key="use_your_public_key",
            private_key="use_your_private_key",
        )
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-07
      • 2017-11-22
      • 2015-02-06
      • 2021-08-24
      • 2012-02-18
      • 2019-05-18
      • 2018-01-19
      相关资源
      最近更新 更多