Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void testCreateSubcriptionWithPayPal() throws Exception {
- String password = "123";
- String dadUsername = newRandomUsername();
- String childUsername = newRandomUsername();
- createParentWithChild(childUsername, password, dadUsername, password);
- logout();
- login(childUsername, password);
- String childAccountId = session.getUser().getName();
- logout();
- login(dadUsername, password);
- List<SubscriptionPlan> subscriptionPlans = doGet(List.class, "subscriptionPlans");
- BillingInfo billingInfo =
- createSubscription(childAccountId, String.valueOf(subscriptionPlans.get(0).getPlanId()),
- false);
- assertNotNull(billingInfo);
- assertNotNull(billingInfo.getId());
- assertNull(billingInfo.getUrl());
- assertNotNull(billingInfo.getType());
- assertEquals(BillingInfoType.SUBSCRIPTION, billingInfo.getType());
- List<Subscription> subscriptions = (List<Subscription>)
- doGet(List.class, "secure/sessions/current/account/children/"+childAccountId+"/subscriptions");
- assertNotNull(subscriptions);
- assertFalse(subscriptions.isEmpty());
- assertEquals(1, subscriptions.size());
- assertEquals(subscriptionPlans.get(0).getPlanId(),
- subscriptions.get(0).getSubscriptionPlan().getPlanId());
- assertEquals(AccountType.PAYPAL, subscriptions.get(0).getDebitAccount().getAccountType());
- assertNull(subscriptions.get(0).getDebitAccount().getCreditCard());
- }
- /*
- * The parent must be logged.
- */
- private BillingInfo createSubscription(String childAccountId, String subscriptionPlanId,
- boolean withCreditCard) throws Exception {
- if (withCreditCard) {
- return doPost(BillingInfo.class, "secure/sessions/current/account/children/"+childAccountId+"/subscriptions",
- "subscriptionPlanId", subscriptionPlanId,
- "debitAccount", AccountType.CREDIT_CARD.toString(),
- "addrFirstName", "Samanta",
- "addrLastName", "Scott",
- "addrAddress1", "Victory Blvd",
- "addrAddress2", "Glade Ave",
- "addrCity", "Woodland Hill",
- "addrState", "CA",
- "addrCountry", "US",
- "addrZipCode", "91367",
- "addrPhoneNumber", "8185996279",
- "addrEmail", "email@email.com",
- "ccNumber", "4111111111111111",
- "ccSecurityCode", "111",
- "ccExpirationMonth", "12",
- "ccExpirationYear", "2012");
- } else {
- return doPost(BillingInfo.class, "secure/sessions/current/account/children/"+childAccountId+"/subscriptions",
- "subscriptionPlanId", subscriptionPlanId,
- "debitAccount", AccountType.PAYPAL.toString(),
- "addrFirstName", "Samanta",
- "addrLastName", "Scott",
- "addrAddress1", "Victory Blvd",
- "addrAddress2", "Glade Ave",
- "addrCity", "Woodland Hill",
- "addrState", "CA",
- "addrCountry", "US",
- "addrZipCode", "91367",
- "addrPhoneNumber", "8185996279",
- "addrEmail", "email@email.com");
- }
- }
Add Comment
Please, Sign In to add comment