如何在 braintree js+python 中创建没有计划的交易?(whiteout 订阅)

how to create transaction without plan in braintree js+python?(whiteout subscription)

我在我的应用程序中使用 braintree 支付网关。

我可以通过选择计划来创建交易,但我需要的是在不选择任何计划的情况下创建交易。一次性付款。

我的代码

create_sub = braintree.Subscription.create({
                            "payment_method_token": the_token,
                            "plan_id": PLAN_ID
                        })

此处创建订阅。

payment_method_result = braintree.PaymentMethod.create({
                        "customer_id": merchant_customer_id,
                        "payment_method_nonce": nonce,
                        "options": {
                            "make_default": True
                        }
                    })

此处 payment_method 已创建

这里我想要的是直接创建交易而不需要订阅。 并将所有交易相关数据保存到交易模型中。

完全披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support.

您可以使用以下调用使用 Braintree 的 Python API 库创建一次性交易:

result = braintree.Transaction.sale({
    "amount": "10.00",
    "payment_method_token": the_token,
    "options": {
        "submit_for_settlement": True
    }
})

这将创建与任何计划无关的单个事务。代替 "payment_method_token",您还可以使用 "payment_method_nonce",传入从您的客户端收到的随机数。您可以在 Braintree's API Documentation.

中找到可用参数的完整列表