【问题标题】:Payment method token is invalid in BraintreeBraintree 中的付款方式令牌无效
【发布时间】:2015-05-30 05:47:22
【问题描述】:

我想在订阅支付网关 Braintree 的功能方面对其进行测试 - 对于我使用 Django (python) 的应用程序。

您的代码我只有一个 py 文件。 (没有前端)。当我想创建订阅时,出现错误:

<ErrorResult 'Payment method token is invalid.' at 7f101d301390>

如何获取token支付方式?

这是我所有的代码:

import braintree

braintree.Configuration.configure(braintree.Environment.Sandbox,
                                  merchant_id="myMechrantId",
                                  public_key="myPublicKey",
                                  private_key="myPrivateKey")

client_token = braintree.ClientToken.generate()

client = braintree.Customer.create({
    "first_name": 'Mike',
    "last_name": "Smith",
    "company": "Braintree",
    "email": "jen@example.com",
    "phone": "312.555.1234",
    "fax": "614.555.5678",
    "website": "www.example.com"
})

result = braintree.Subscription.create({
    "payment_method_token": "the_token",
    "plan_id": "Here is my plan ID"
})

【问题讨论】:

    标签: python token payment-gateway braintree


    【解决方案1】:

    我在布伦特里工作。如果您还有其他问题,请get in touch with our support team

    一般来说,像 Braintree 这样的服务的主要好处之一是您无需处理信用卡号码,因此您最好使用following the Braintree recurring billing guide,这将更好地匹配与 Braintree 的真正集成。

    也就是说,如果您确实想在没有前端的情况下对其进行测试,您可以这样进行测试:

    result = braintree.Customer.create({
        "credit_card": {
            "number": "4111111111111111",
            "expiration_date": "12/16"
        }
    })
    
    result = braintree.Subscription.create({
        "payment_method_token": result.customer.credit_cards[0].token,
        "plan_id": "my_plan_id"
    })
    

    【讨论】:

    • @AwaisMustafa 是的,使用 PayPal 帐户的付款方式令牌创建订阅。
    • @agf 你能告诉我我们如何获得令牌 frim paypal acc 吗?
    • @SachinShah 请向 Braintree 支持提出您的问题,但除了替换 credit_cards 位之外基本相同。
    • 我花了很长时间才找到对 payment_method_toke 的价值有意义的东西。为什么他们不能直接称之为 payment_method_id
    • @BogdanM。一般来说,区别在于_tokens可以由商家通过API设置,而_ids不能。
    【解决方案2】:

    已经很晚了,但我最近被这个问题卡住了,这是帮助我的解决方案

    customer_create_result = gateway.customer.create({
            "first_name": user.first_name,
            "last_name": user.middle_name + '' + user.last_name,
            "payment_method_nonce": payment_method_nonce
        })
    subscription_create_result = gateway.subscription.create({
            "payment_method_token":
            customer_create_result.customer.payment_methods[0].token,
            "plan_id": braintree_plan_id
        })
    

    其中 payment_method_nonce 可以在点击付款按钮时从 payload.nonce 获得,braintree_plan_id 是您在 Braintree 控制中创建的计划的 ID面板

    这是帮助我的大脑树参考 https://developer.paypal.com/braintree/docs/guides/customers#create-with-payment-method

    【讨论】:

      猜你喜欢
      • 2015-06-05
      • 2011-11-15
      • 2017-08-17
      • 2013-06-14
      • 2018-05-12
      • 2015-11-22
      • 1970-01-01
      • 2015-09-16
      • 2015-03-11
      相关资源
      最近更新 更多