Invalid payment method token in Braintree

I want to test it on the functionality side of the Braintree subscription payment gateway - for my application using Django (python).

In your code, I have only one py file. (without interface). When I want to create a subscription, I get an error:

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

How can I get a token payment method?

Here is my code:

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"
})
+4
source share
1 answer

I work at Braintree. Contact our support team if you have further questions.

, , Braintree, , , Braintree, , 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"
})
+4

All Articles