【问题标题】:is a payment nonce required for every transaction with Braintrree?与 Braintree 的每笔交易都需要支付 nonce 吗?
【发布时间】:2015-11-14 18:18:28
【问题描述】:

我正在开发一个类似市场的应用程序,它支持通过 Braintree 进行支付处理。但是,我的大部分交易都会非常小,并且考虑到 Braintree 收取的费率,我无法在每次用户购买时处理交易。

因此,我想在后端汇总付款,并在用户累计支出达到 $X 或 Y 天过去后向用户收费。

鉴于每笔 Braintree 交易似乎都需要支付 nonce,这种方法是否可以实施?如果没有,任何人都可以提出替代解决方案吗?

非常感谢。

【问题讨论】:

标签: paypal transactions payment stripe-payments braintree


【解决方案1】:

一句话回答你标题中的问题:不,与 Braintree 的每笔交易都不需要支付随机数。

理论上,可以通过将买家的付款方式信息保管到您的 Braintree 帐户中,然后使用保管的付款方式进行收费。付款方式在 Braintree 中使用令牌进行保管。然后可以使用付款方式令牌进行付款,而无需买家在场。

但是,买方必须将付款方式授予您。这通常由买家通过 dropin 表单或自定义表单向您提供他/她的付款方式信息来完成,该表单将 nonce 和信息返回给您。这需要买家在场。

我建议按照 Braintree (https://developers.braintreepayments.com) 参考部分的以下步骤进行操作

  • 交易(如何进行基本的一次性交易)
  • 客户
  • 信用卡
  • 交易(如何在没有买家在场的情况下进行交易)

PS,我在一开始就说“理论上”,因为如果您可以/不能通过 vaulting 做到这一点,取决于您的购买流程以及您的买家是否愿意这样做。

再次PS,可以通过这种方式使用保险支付方式令牌(在PHP中):

Braintree_Transaction::sale(array(
        'amount' => '10.00',
        'paymentMethodToken' => $the_payment_method_token,
        'options' => array(
                'submitForSettlement' => true
        )
));

【讨论】:

    【解决方案2】:

    对于每个 Braintree 交易的付款方式,不需要随机数。买家通过 dropin form 或 custom form 提供他/她的信息,返回付款 nonce 方式,我们将信息发送到 Braintree 并获得payment_method_token。用python写的。

    @login_required
    def clienttoken(request):
        result = braintree.Customer.create({
            "first_name": "XXXX",
            "last_name": "XXX",
            "company": "XXX",
            "email": "XXXX",
            "phone": "312.555.1234",
            "fax": "614.555.5678",
            "website": "www.example.com",
            "credit_card": {
                "cardholder_name": "XXX",
                "number": "XXXX",
                "expiration_date": "XXX",
                "options": {
                    "verify_card": True,
                },
            },
        })
        client_token = braintree.ClientToken.generate({"customer_id": result.customer.id})
        request.session['customer_id'] = result.customer.id
        return render(request, "braintree/checkout.html", {"client_token": client_token})
    
    @csrf_exempt
    def checkout(request):    
        customer_id = request.session['customer_id']
        nonce = request.POST['payment_method_nonce']
        result = braintree.PaymentMethod.create({
            "customer_id": customer_id,
            "payment_method_nonce": nonce,
            "options": {
                "verify_card": True,
            }
        })
        return HttpResponse(result.payment_method.token)
    

    我们在braintree的每一笔交易中都使用payment_method_token。

    result = braintree.Transaction.sale({
        "amount": "400",
        "payment_method_token": "token",
        "options": {
            "submit_for_settlement": "true",
         }
    })
    

    【讨论】:

      猜你喜欢
      • 2013-10-28
      • 1970-01-01
      • 2016-03-17
      • 2021-12-02
      • 2013-10-24
      • 2015-08-04
      • 2013-09-06
      • 2018-06-04
      • 2020-12-16
      相关资源
      最近更新 更多