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 to create sale transactions in the sandbox that are instantly disputed:

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

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 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 either the test card number above or the constant shown in the example below.

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

Specifying the string "compelling_evidence" when adding text evidence in the sandbox 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")
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

Simulating a lost dispute

Specifying the string "losing_evidence" when adding text evidence in the sandbox 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")
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.