Search code examples
braintree

Best practice to detect if 2 customers try to use same credit card in braintree


I want to know what's the best practice if:

  • User1 uses card xyz1 and xyz1 successfully verified and added in braintree.
  • User2 uses same card xyz1 and xyz1 verification failed and added in braintree with verification failure reason.
  • I want to find users which try xyz1 (either successful or failed) in braintree.

Anything like fingerprint in stripe.


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    You can search for transactions in your vault that used the same credit card by using the credit card unique identifier in a transaction search. This will get you a response containing all transactions that made use of the same card. From there, you can inspect the transaction response object for information about the customer that created it.

    You cannot use the credit card unique identifier in verification searches. Instead, you could search for verifications based on customer ID or payment method token, then pull the credit card unique identifier from the verification response object.

    In Ruby, the transaction search would look something like this:

    collection = Braintree::Transaction.search do |search|
      search.credit_card_unique_identifier.is "the_unique_identifier"
    end
    
    collection.each do |transaction|
      puts transaction.customer_details.id
    end