Guest User

Untitled

a guest
Jul 22nd, 2018
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. @Test
  2. public void testCreateSubcriptionWithPayPal() throws Exception {
  3. String password = "123";
  4. String dadUsername = newRandomUsername();
  5. String childUsername = newRandomUsername();
  6. createParentWithChild(childUsername, password, dadUsername, password);
  7. logout();
  8. login(childUsername, password);
  9. String childAccountId = session.getUser().getName();
  10. logout();
  11. login(dadUsername, password);
  12. List<SubscriptionPlan> subscriptionPlans = doGet(List.class, "subscriptionPlans");
  13. BillingInfo billingInfo =
  14. createSubscription(childAccountId, String.valueOf(subscriptionPlans.get(0).getPlanId()),
  15. false);
  16. assertNotNull(billingInfo);
  17. assertNotNull(billingInfo.getId());
  18. assertNull(billingInfo.getUrl());
  19. assertNotNull(billingInfo.getType());
  20. assertEquals(BillingInfoType.SUBSCRIPTION, billingInfo.getType());
  21. List<Subscription> subscriptions = (List<Subscription>)
  22. doGet(List.class, "secure/sessions/current/account/children/"+childAccountId+"/subscriptions");
  23. assertNotNull(subscriptions);
  24. assertFalse(subscriptions.isEmpty());
  25. assertEquals(1, subscriptions.size());
  26. assertEquals(subscriptionPlans.get(0).getPlanId(),
  27. subscriptions.get(0).getSubscriptionPlan().getPlanId());
  28. assertEquals(AccountType.PAYPAL, subscriptions.get(0).getDebitAccount().getAccountType());
  29. assertNull(subscriptions.get(0).getDebitAccount().getCreditCard());
  30. }
  31.  
  32.  
  33. /*
  34. * The parent must be logged.
  35. */
  36. private BillingInfo createSubscription(String childAccountId, String subscriptionPlanId,
  37. boolean withCreditCard) throws Exception {
  38. if (withCreditCard) {
  39. return doPost(BillingInfo.class, "secure/sessions/current/account/children/"+childAccountId+"/subscriptions",
  40. "subscriptionPlanId", subscriptionPlanId,
  41. "debitAccount", AccountType.CREDIT_CARD.toString(),
  42. "addrFirstName", "Samanta",
  43. "addrLastName", "Scott",
  44. "addrAddress1", "Victory Blvd",
  45. "addrAddress2", "Glade Ave",
  46. "addrCity", "Woodland Hill",
  47. "addrState", "CA",
  48. "addrCountry", "US",
  49. "addrZipCode", "91367",
  50. "addrPhoneNumber", "8185996279",
  51. "addrEmail", "email@email.com",
  52. "ccNumber", "4111111111111111",
  53. "ccSecurityCode", "111",
  54. "ccExpirationMonth", "12",
  55. "ccExpirationYear", "2012");
  56. } else {
  57. return doPost(BillingInfo.class, "secure/sessions/current/account/children/"+childAccountId+"/subscriptions",
  58. "subscriptionPlanId", subscriptionPlanId,
  59. "debitAccount", AccountType.PAYPAL.toString(),
  60. "addrFirstName", "Samanta",
  61. "addrLastName", "Scott",
  62. "addrAddress1", "Victory Blvd",
  63. "addrAddress2", "Glade Ave",
  64. "addrCity", "Woodland Hill",
  65. "addrState", "CA",
  66. "addrCountry", "US",
  67. "addrZipCode", "91367",
  68. "addrPhoneNumber", "8185996279",
  69. "addrEmail", "email@email.com");
  70. }
  71. }
Add Comment
Please, Sign In to add comment