@Test(groups = "integration") public void testGetBillingInfo() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); billingInfoData.setAccount(null); // need to null out test account accountData.setBillingInfo(billingInfoData); try { // Create account and fetch billing info final Account account = recurlyClient.createAccount(accountData); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); Assert.assertEquals(retrievedBillingInfo.getType(), "credit_card"); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testGetBillingInfo() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); billingInfoData.setAccount(null); // need to null out test account accountData.setBillingInfo(billingInfoData); try { // Create account and fetch billing info final Account account = recurlyClient.createAccount(accountData); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); Assert.assertEquals(retrievedBillingInfo.getType(), "credit_card"); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration", description = "See https://github.com/killbilling/recurly-java-library/issues/21") public void testGetEmptySubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { // Create a user final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Subscriptions subs = recurlyClient.getAccountSubscriptions(accountData.getAccountCode(), "active"); Assert.assertEquals(subs.size(), 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration", description = "See https://github.com/killbilling/recurly-java-library/issues/21") public void testGetEmptySubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { // Create a user final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Subscriptions subs = recurlyClient.getAccountSubscriptions(accountData.getAccountCode(), "active"); Assert.assertEquals(subs.size(), 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
recurlyClient.closeAccount(accountData.getAccountCode());
@Test(groups = "integration") public void testShippingAddressesOnAccount() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final ShippingAddress shippingAddress1 = TestUtils.createRandomShippingAddress(); final ShippingAddress shippingAddress2 = TestUtils.createRandomShippingAddress(); final ShippingAddresses shippingAddressesData = new ShippingAddresses(); try { shippingAddressesData.add(shippingAddress1); shippingAddressesData.add(shippingAddress2); accountData.setShippingAddresses(shippingAddressesData); final Account account = recurlyClient.createAccount(accountData); ShippingAddresses shippingAddresses = recurlyClient.getAccountShippingAddresses(account.getAccountCode()); Assert.assertEquals(shippingAddresses.size(), 2); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); } }
recurlyClient.closeAccount(accountData.getAccountCode());
@Test(groups = "integration") public void testShippingAddressesOnAccount() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final ShippingAddress shippingAddress1 = TestUtils.createRandomShippingAddress(); final ShippingAddress shippingAddress2 = TestUtils.createRandomShippingAddress(); final ShippingAddresses shippingAddressesData = new ShippingAddresses(); try { shippingAddressesData.add(shippingAddress1); shippingAddressesData.add(shippingAddress2); accountData.setShippingAddresses(shippingAddressesData); final Account account = recurlyClient.createAccount(accountData); ShippingAddresses shippingAddresses = recurlyClient.getAccountShippingAddresses(account.getAccountCode()); Assert.assertEquals(shippingAddresses.size(), 2); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testGetAccountBalance() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Adjustment adjustment = new Adjustment(); adjustment.setUnitAmountInCents(150); adjustment.setCurrency(CURRENCY); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustment); final AccountBalance balance = recurlyClient.getAccountBalance(account.getAccountCode()); Assert.assertEquals(balance.getBalanceInCents().getUnitAmountUSD(), new Integer(150)); Assert.assertEquals(balance.getPastDue(), Boolean.FALSE); } finally { // Clean up recurlyClient.clearBillingInfo(accountData.getAccountCode()); recurlyClient.closeAccount(accountData.getAccountCode()); } }
recurlyClient.closeAccount(accountData.getAccountCode());
@Test(groups = "integration") public void testGetAccountBalance() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Adjustment adjustment = new Adjustment(); adjustment.setUnitAmountInCents(150); adjustment.setCurrency(CURRENCY); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustment); final AccountBalance balance = recurlyClient.getAccountBalance(account.getAccountCode()); Assert.assertEquals(balance.getBalanceInCents().getUnitAmountUSD(), new Integer(150)); Assert.assertEquals(balance.getPastDue(), Boolean.FALSE); } finally { // Clean up recurlyClient.clearBillingInfo(accountData.getAccountCode()); recurlyClient.closeAccount(accountData.getAccountCode()); } }
} finally { recurlyClient.closeAccount(accountData.getAccountCode());
} finally { recurlyClient.closeAccount(accountData.getAccountCode());
@Test(groups = "integration") public void testGetSiteSubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); final Plan planData = TestUtils.createRandomPlan(); try { final Account account = recurlyClient.createAccount(accountData); billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); final Plan plan = recurlyClient.createPlan(planData); final Subscription subscriptionData = new Subscription(); subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setAccount(accountData); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); subscriptionData.setRemainingBillingCycles(1); // makes sure we have at least one subscription recurlyClient.createSubscription(subscriptionData); // make sure we return more than one subscription Assert.assertTrue(recurlyClient.getSubscriptions().size() > 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
} finally { recurlyClient.closeAccount(accountData.getAccountCode());
@Test(groups = "integration") public void testGetSiteSubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); final Plan planData = TestUtils.createRandomPlan(); try { final Account account = recurlyClient.createAccount(accountData); billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); final Plan plan = recurlyClient.createPlan(planData); final Subscription subscriptionData = new Subscription(); subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setAccount(accountData); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); subscriptionData.setRemainingBillingCycles(1); // makes sure we have at least one subscription recurlyClient.createSubscription(subscriptionData); // make sure we return more than one subscription Assert.assertTrue(recurlyClient.getSubscriptions().size() > 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
Assert.assertEquals(subscription.getTrialEndsAt().getMonthOfYear(), expectedMonth); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode()); recurlyClient.deleteCoupon(couponData.getCouponCode());
recurlyClient.closeAccount(accountData.getAccountCode());
@Test(groups = "integration") public void testShippingAddressesOnSubscription() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final Plan planData = TestUtils.createRandomPlan(CURRENCY); final ShippingAddress shippingAddressData = TestUtils.createRandomShippingAddress(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); billingInfoData.setAccount(null); // null out random account fixture accountData.setBillingInfo(billingInfoData); // add the billing info to account data try { final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); // Subscribe the user to the plan final Subscription subscriptionData = new Subscription(); // set our shipping address subscriptionData.setShippingAddress(shippingAddressData); // set our sub data subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); // attach the account final Account existingAccount = new Account(); existingAccount.setAccountCode(account.getAccountCode()); subscriptionData.setAccount(existingAccount); final Subscription subscription = recurlyClient.createSubscription(subscriptionData); Assert.assertNotNull(subscription.getHref()); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode()); } }
@Test(groups = "integration") public void testShippingAddressesOnSubscription() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final Plan planData = TestUtils.createRandomPlan(CURRENCY); final ShippingAddress shippingAddressData = TestUtils.createRandomShippingAddress(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); billingInfoData.setAccount(null); // null out random account fixture accountData.setBillingInfo(billingInfoData); // add the billing info to account data try { final Account account = recurlyClient.createAccount(accountData); final Plan plan = recurlyClient.createPlan(planData); // Subscribe the user to the plan final Subscription subscriptionData = new Subscription(); // set our shipping address subscriptionData.setShippingAddress(shippingAddressData); // set our sub data subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); // attach the account final Account existingAccount = new Account(); existingAccount.setAccountCode(account.getAccountCode()); subscriptionData.setAccount(existingAccount); final Subscription subscription = recurlyClient.createSubscription(subscriptionData); Assert.assertNotNull(subscription.getHref()); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); recurlyClient.deletePlan(planData.getPlanCode()); } }