use of com.stripe.model.Dispute in project stripe-java by stripe.
the class DisputeTest method testDisputedCharge.
@Test
public void testDisputedCharge() throws StripeException, InterruptedException {
int chargeValueCents = 100;
Charge disputedCharge = createDisputedCharge(chargeValueCents, null);
Dispute dispute = disputedCharge.getDisputeObject();
assertNotNull(dispute);
assertFalse(dispute.getIsChargeRefundable());
assertEquals(1, dispute.getBalanceTransactions().size());
assertEquals(-chargeValueCents, dispute.getBalanceTransactions().get(0).getAmount().intValue());
}
use of com.stripe.model.Dispute in project stripe-java by stripe.
the class DisputeTest method testUpdateDispute.
@Test
public void testUpdateDispute() throws StripeException, InterruptedException {
int chargeValueCents = 100;
Charge disputedCharge = createDisputedCharge(chargeValueCents, null);
Dispute initialDispute = disputedCharge.getDisputeObject();
EvidenceSubObject emptyEvidence = new EvidenceSubObject();
assertEquals(emptyEvidence, initialDispute.getEvidenceSubObject());
assertEquals(new HashMap<String, String>(), initialDispute.getMetadata());
Map<String, Object> evidence = new HashMap<String, Object>();
evidence.put("product_description", "my productDescription");
evidence.put("customer_name", "my customerName");
evidence.put("uncategorized_text", "my uncategorizedText");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("some_info", "about the dispute");
metadata.put("a_little_more", "12345");
Map<String, Object> params = new HashMap<String, Object>();
params.put("evidence", evidence);
params.put("metadata", metadata);
Dispute updatedDispute = initialDispute.update(params);
assertNotNull(updatedDispute);
EvidenceSubObject evidenceSubObject = updatedDispute.getEvidenceSubObject();
assertEquals(evidence.get("product_description"), evidenceSubObject.getProductDescription());
assertEquals(evidence.get("customer_name"), evidenceSubObject.getCustomerName());
assertEquals(evidence.get("uncategorized_text"), evidenceSubObject.getUncategorizedText());
// Ensure this didn't get stored in the deprecated evidence field.
assertNull(updatedDispute.getEvidence());
Map<String, String> disputeMetadata = updatedDispute.getMetadata();
assertNotNull(disputeMetadata);
assertEquals(metadata, disputeMetadata);
}
use of com.stripe.model.Dispute in project stripe-java by stripe.
the class DisputeTest method testSubmitOldStyleEvidence.
@Test
public void testSubmitOldStyleEvidence() throws StripeException, InterruptedException {
RequestOptions options = RequestOptions.builder().setStripeVersion("2014-11-20").build();
int chargeValueCents = 100;
// Stripe.apiVersion = "2014-11-20";
Charge disputedCharge = createDisputedCharge(chargeValueCents, options);
String myEvidence = "Here's evidence showing this charge is legitimate.";
Dispute initialDispute = disputedCharge.getDisputeObject();
assertNull(initialDispute.getEvidence());
assertNull(initialDispute.getEvidenceSubObject());
Map<String, Object> disputeParams = ImmutableMap.<String, Object>of("evidence", myEvidence);
Dispute updatedDispute = disputedCharge.updateDispute(disputeParams, options);
assertNotNull(updatedDispute);
assertEquals(myEvidence, updatedDispute.getEvidence());
assertNull(updatedDispute.getEvidenceSubObject());
}
use of com.stripe.model.Dispute in project stripe-java by stripe.
the class DisputeTest method testSubmitEvidence.
@Test
public void testSubmitEvidence() throws StripeException, InterruptedException {
int chargeValueCents = 100;
Charge disputedCharge = createDisputedCharge(chargeValueCents, null);
Dispute initialDispute = disputedCharge.getDisputeObject();
assertNull(initialDispute.getEvidence());
EvidenceSubObject emptyEvidence = new EvidenceSubObject();
assertEquals(emptyEvidence, initialDispute.getEvidenceSubObject());
assertEquals(0, initialDispute.getEvidenceDetails().getSubmissionCount().intValue());
Map<String, Object> evidenceHashParams = new HashMap<String, Object>();
// TODO: assert on all param types
evidenceHashParams.put("product_description", "my productDescription");
evidenceHashParams.put("customer_name", "my customerName");
evidenceHashParams.put("uncategorized_text", "my uncategorizedText");
Map<String, Object> providedEvidenceParams = ImmutableMap.<String, Object>of("evidence", evidenceHashParams);
Dispute updatedDispute = disputedCharge.updateDispute(providedEvidenceParams);
assertNotNull(updatedDispute);
EvidenceSubObject evidenceSubObject = updatedDispute.getEvidenceSubObject();
assertNotSame(emptyEvidence, evidenceSubObject);
assertEquals(1, updatedDispute.getEvidenceDetails().getSubmissionCount().intValue());
assertNull(updatedDispute.getEvidence());
assertEquals("my productDescription", evidenceSubObject.getProductDescription());
assertEquals("my customerName", evidenceSubObject.getCustomerName());
assertEquals("my uncategorizedText", evidenceSubObject.getUncategorizedText());
EvidenceDetails evidenceDetails = updatedDispute.getEvidenceDetails();
assertNotNull(evidenceDetails);
assertEquals(1, evidenceDetails.getSubmissionCount().intValue());
}
use of com.stripe.model.Dispute in project stripe-java by stripe.
the class DisputeTest method testRetrieveDispute.
@Test
public void testRetrieveDispute() throws StripeException, InterruptedException {
int chargeValueCents = 100;
Charge disputedCharge = createDisputedCharge(chargeValueCents, null);
Dispute dispute = disputedCharge.getDisputeObject();
Dispute retrievedDispute = Dispute.retrieve(dispute.getId());
assertEquals(dispute.getId(), retrievedDispute.getId());
}
Aggregations