Search code examples
braintree

Is Braintree_Customer::create() returns credit card object on success


Is Braintree_Customer::create() returns credit card object in braintree on success?

It returns on failure in verification object.

I want to know the best practice to access credit card object if it's present in response in case of success and failure of Braintree_Customer::create().


Solution

  • Seems like you can access the newly created customer's payment method within the successful result object (Python);

    My customer create call:

    result = braintree.Customer.create({
        'first_name': 'John',
        'last_name': 'Smith',
        'company': 'Internet',
        'email': 'john@example.com',
        'payment_method_nonce':'fake-valid-nonce'
    })
    

    so

    result.customer.payment_methods 
    

    will return an array containing the newly created payment method at index 0, which is essentially Braintree's Credit Card Result object, which contains all of the appropriate attributes for that credit card object.