Search in sources :

Example 26 with RequestOptions

use of com.stripe.net.RequestOptions in project stripe-java by stripe.

the class AccountTest method testOverloadedSingleArgumentRetrieve.

@Test
public void testOverloadedSingleArgumentRetrieve() throws StripeException {
    Account.retrieve("sk_foobar");
    RequestOptions options = (new RequestOptionsBuilder()).setApiKey("sk_foobar").build();
    verifyGet(Account.class, "https://api.stripe.com/v1/account", options);
    Account.retrieve("anything_else");
    verifyGet(Account.class, "https://api.stripe.com/v1/accounts/anything_else");
    verifyNoMoreInteractions(networkMock);
}
Also used : RequestOptions(com.stripe.net.RequestOptions) RequestOptionsBuilder(com.stripe.net.RequestOptions.RequestOptionsBuilder) BaseStripeTest(com.stripe.BaseStripeTest) Test(org.junit.Test)

Example 27 with RequestOptions

use of com.stripe.net.RequestOptions in project stripe-java by stripe.

the class EphemeralKeyTest method testVersionlessCreate.

@Test(expected = IllegalArgumentException.class)
public void testVersionlessCreate() throws StripeException {
    Stripe.apiVersion = null;
    final Map<String, Object> params = new HashMap<String, Object>();
    params.put("customer", "cus_123");
    final RequestOptions options = RequestOptions.getDefault();
    EphemeralKey.create(params, options);
}
Also used : HashMap(java.util.HashMap) RequestOptions(com.stripe.net.RequestOptions) BaseStripeTest(com.stripe.BaseStripeTest) Test(org.junit.Test)

Example 28 with RequestOptions

use of com.stripe.net.RequestOptions in project stripe-java by stripe.

the class EphemeralKeyTest method testCreate.

@Test
public void testCreate() throws StripeException {
    Stripe.apiVersion = "2016-06-05";
    final Map<String, Object> params = new HashMap<String, Object>();
    params.put("customer", "cus_123");
    final RequestOptions options = RequestOptions.builder().setStripeVersion("2017-05-25").build();
    EphemeralKey.create(params, options);
    verifyPost(EphemeralKey.class, "https://api.stripe.com/v1/ephemeral_keys", params, options);
    verifyNoMoreInteractions(networkMock);
}
Also used : HashMap(java.util.HashMap) RequestOptions(com.stripe.net.RequestOptions) BaseStripeTest(com.stripe.BaseStripeTest) Test(org.junit.Test)

Example 29 with RequestOptions

use of com.stripe.net.RequestOptions in project stripe-java by stripe.

the class PagingIteratorTest method testAutoPagination.

@Test
public void testAutoPagination() throws IOException, StripeException {
    // set some arbitrary parameters so that we can verify that they're
    // used for requests on ALL pages
    Map<String, Object> page0Params = new HashMap<String, Object>();
    page0Params.put("foo", "bar");
    Map<String, Object> page1Params = new HashMap<String, Object>();
    page1Params.put("foo", "bar");
    page1Params.put("starting_after", "pm_124");
    Map<String, Object> page2Params = new HashMap<String, Object>();
    page2Params.put("foo", "bar");
    page2Params.put("starting_after", "pm_126");
    RequestOptions options = (new RequestOptionsBuilder()).setApiKey("sk_paging_key").build();
    PageableModelCollection collection = PageableModel.list(page0Params, options);
    List<PageableModel> models = new ArrayList<PageableModel>();
    for (PageableModel model : collection.autoPagingIterable()) {
        models.add(model);
    }
    assertEquals(5, models.size());
    assertEquals("pm_123", models.get(0).getId());
    assertEquals("pm_124", models.get(1).getId());
    assertEquals("pm_125", models.get(2).getId());
    assertEquals("pm_126", models.get(3).getId());
    assertEquals("pm_127", models.get(4).getId());
    verifyGet(PageableModelCollection.class, "https://api.stripe.com/v1/pageablemodels", page0Params, options);
    verifyGet(PageableModelCollection.class, "https://api.stripe.com/v1/pageablemodels", page1Params, options);
    verifyGet(PageableModelCollection.class, "https://api.stripe.com/v1/pageablemodels", page2Params, options);
    verifyNoMoreInteractions(networkMock);
}
Also used : HashMap(java.util.HashMap) RequestOptions(com.stripe.net.RequestOptions) RequestOptionsBuilder(com.stripe.net.RequestOptions.RequestOptionsBuilder) ArrayList(java.util.ArrayList) BaseStripeTest(com.stripe.BaseStripeTest) Test(org.junit.Test)

Aggregations

RequestOptions (com.stripe.net.RequestOptions)29 Test (org.junit.Test)19 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)12 Charge (com.stripe.model.Charge)12 HashMap (java.util.HashMap)11 BaseStripeTest (com.stripe.BaseStripeTest)5 RequestOptionsBuilder (com.stripe.net.RequestOptions.RequestOptionsBuilder)4 PaymentInformation (alfio.model.PaymentInformation)3 DeletedProduct (com.stripe.model.DeletedProduct)2 DeletedSKU (com.stripe.model.DeletedSKU)2 Product (com.stripe.model.Product)2 Refund (com.stripe.model.Refund)2 SKU (com.stripe.model.SKU)2 FeeCalculator (alfio.manager.support.FeeCalculator)1 PaymentResult (alfio.manager.support.PaymentResult)1 ConfigurationManager (alfio.manager.system.ConfigurationManager)1 UserManager (alfio.manager.user.UserManager)1 Configurable (alfio.model.Configurable)1 PurchaseContext (alfio.model.PurchaseContext)1 PurchaseContextType (alfio.model.PurchaseContext.PurchaseContextType)1