availability

Managing disputes via the API is only available to merchants who can access disputes in the Braintree Control Panel.

We strongly recommend that you test your dispute workflows in the sandbox before using them in production.

You can use the following test card number in the sandbox to create sale transactions of any amount* that are instantly disputed:

Test Value Card Type Description
4023898493988028 Visa Creates a settled sale transaction that has a dispute with an open status

*Some transaction amounts trigger specific dispute behavior in the sandbox; see creating test disputes that require compelling evidence below.

In addition to creating a test dispute, using this test card to create sandbox transactions will allow you to:

  • Receive a dispute email notification
  • Receive a Dispute Opened webhook (if set up)
  • Search for or find the dispute in the Control Panel or via the API
  • Respond to the dispute in the Control Panel or via the API with specific evidence that will update the dispute status to won or lost
Creating test disputes that require compelling evidence

The following transaction amounts will set the dispute reason_code accordingly:

Amount Dispute Reason Code
83.00 83 Visa Fraud
10.40 1040 Visa Fraud
13.10 1310 Visa Fraud
70.30 7030 Discover Fraud

Creating a disputed test transaction

Use Transaction.sale() to create a test transaction via the API. When specifying a credit card number for the test transaction, you can use the test card number above.

Ruby
Copy
Copied
result = gateway.transaction.sale(
 :amount => '10.00',
 :credit_card => {
   :expiration_date => '01/2020',
   :number => Braintree::Test::CreditCardNumbers::Disputes::Chargeback
 },
)

if result.success?
  # Do something with the result.transaction.disputes
end
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

Simulating a won dispute

Specify the string "compelling_evidence" when adding text evidence in the sandbox. Once finalized, this will update the dispute status to won.

Ruby
Copy
Copied
dispute = gateway.dispute.find("a_dispute_id")

gateway.dispute.add_text_evidence(dispute.id, "compelling_evidence")

gateway.dispute.finalize(dispute.id)
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

Simulating a lost dispute

Specify the string "losing_evidence" when adding text evidence in the sandbox. Once finalized, this will update the dispute status to lost.

Ruby
Copy
Copied
dispute = gateway.dispute.find("a_dispute_id")

gateway.dispute.add_text_evidence(dispute.id, "losing_evidence")

gateway.dispute.finalize(dispute.id)
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

Still have questions?

If you can’t find an answer, contact our Support team