Search in sources :

Example 1 with Dispute

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());
}
Also used : Charge(com.stripe.model.Charge) Dispute(com.stripe.model.Dispute) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with Dispute

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);
}
Also used : EvidenceSubObject(com.stripe.model.EvidenceSubObject) HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) Dispute(com.stripe.model.Dispute) EvidenceSubObject(com.stripe.model.EvidenceSubObject) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 3 with Dispute

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());
}
Also used : RequestOptions(com.stripe.net.RequestOptions) Charge(com.stripe.model.Charge) Dispute(com.stripe.model.Dispute) EvidenceSubObject(com.stripe.model.EvidenceSubObject) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 4 with Dispute

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());
}
Also used : EvidenceSubObject(com.stripe.model.EvidenceSubObject) EvidenceDetails(com.stripe.model.EvidenceDetails) HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) Dispute(com.stripe.model.Dispute) EvidenceSubObject(com.stripe.model.EvidenceSubObject) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 5 with Dispute

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());
}
Also used : Charge(com.stripe.model.Charge) Dispute(com.stripe.model.Dispute) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)7 Charge (com.stripe.model.Charge)7 Dispute (com.stripe.model.Dispute)7 Test (org.junit.Test)7 EvidenceSubObject (com.stripe.model.EvidenceSubObject)4 HashMap (java.util.HashMap)3 Card (com.stripe.model.Card)1 EvidenceDetails (com.stripe.model.EvidenceDetails)1 RequestOptions (com.stripe.net.RequestOptions)1 LinkedList (java.util.LinkedList)1