Search in sources :

Example 1 with BalanceTransaction

use of com.stripe.model.BalanceTransaction in project stripe-java by stripe.

the class RefundTest method testChargeRefundListWithExpand.

@Test
public void testChargeRefundListWithExpand() throws StripeException {
    Charge ch = Charge.create(defaultChargeParams);
    ch = ch.refund();
    List<String> expandList = new LinkedList<String>();
    expandList.add("data.balance_transaction");
    expandList.add("data.balance_transaction.source");
    expandList.add("data.charge");
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("charge", ch.getId());
    listParams.put("count", 1);
    listParams.put("expand", expandList);
    Refund refund = Refund.list(listParams).getData().get(0);
    Charge expCharge = refund.getChargeObject();
    assertNotNull(expCharge);
    assertEquals(ch.getId(), expCharge.getId());
    BalanceTransaction expBT = refund.getBalanceTransactionObject();
    assertNotNull(expBT);
    Refund expRefundInBT = (Refund) expBT.getSourceObject();
    assertEquals(refund.getId(), expRefundInBT.getId());
}
Also used : Refund(com.stripe.model.Refund) HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BalanceTransaction(com.stripe.model.BalanceTransaction) LinkedList(java.util.LinkedList) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with BalanceTransaction

use of com.stripe.model.BalanceTransaction in project stripe-java by stripe.

the class BalanceTransactionTest method testBalanceTransactionRetrieval.

@Test
public void testBalanceTransactionRetrieval() throws StripeException {
    Charge.create(defaultChargeParams);
    BalanceTransactionCollection balanceTransactions = BalanceTransaction.all(null);
    assertFalse(balanceTransactions.getData().isEmpty());
    BalanceTransaction first = balanceTransactions.getData().get(0);
    assertNotNull(first.getStatus());
    HashMap<String, Object> fetchParams = new HashMap<String, Object>();
    fetchParams.put("count", 2);
    assertEquals(BalanceTransaction.all(fetchParams).getData().size(), 2);
    BalanceTransaction retrieved = BalanceTransaction.retrieve(first.getId());
    assertEquals(retrieved.getId(), first.getId());
    assertEquals(retrieved.getSource(), first.getSource());
}
Also used : BalanceTransactionCollection(com.stripe.model.BalanceTransactionCollection) HashMap(java.util.HashMap) BalanceTransaction(com.stripe.model.BalanceTransaction) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)2 BalanceTransaction (com.stripe.model.BalanceTransaction)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 BalanceTransactionCollection (com.stripe.model.BalanceTransactionCollection)1 Charge (com.stripe.model.Charge)1 Refund (com.stripe.model.Refund)1 LinkedList (java.util.LinkedList)1