Search code examples
braintree

Payment method nonces expire after 24 hours in Brain Tree


We are making a bidding app in which highest bid will commit but after the completion of auction time (suppose 2 days).

As user may have provided me Payment method nonce 48 hours ago, than I have to save nonce and commit after 48 hours. Is there any solution to handle it?


Solution

  • Finally with help of Braintree Support I find a way to handle this. Payment method nonce actually expires after 24 hours but there is an alternate way to use payment method token instead of payment method nonce to commit transaction after desired time. I'm working on Rails.

    First, create a customer with given payment method nonce from client

    result = Braintree::Customer.create(
                :first_name => "Faisal",
                :last_name => "Iqbal",
                :payment_method_nonce => 'fake-valid-nonce' )
    

    It will create a customer on vault of your Braintree account and generate a payment_method_token, you can get it as

    token_generated=result.customer.payment_methods[0].token
    

    then use it to commit transaction at any time using

    transation = Braintree::Transaction.sale(
                :amount => "5000.00",
                :payment_method_token => token_generated)