/** * Creates a random {@link com.ning.billing.recurly.model.BillingInfo} object for testing use given a seed * * @param seed The RNG seed * @return The random {@link com.ning.billing.recurly.model.BillingInfo} object */ public static BillingInfo createRandomBillingInfo(final int seed) { final BillingInfo info = new BillingInfo(); info.setAccount(createRandomAccount(seed)); info.setFirstName(randomAlphaNumericString(5, seed)); info.setLastName(randomAlphaNumericString(6, seed)); info.setCompany(randomAlphaNumericString(10, seed)); info.setAddress1(randomAlphaNumericString(10, seed)); info.setAddress2(randomAlphaNumericString(10, seed)); info.setCity(randomAlphaNumericString(10, seed)); info.setState("CA"); info.setZip("94110"); info.setCountry("US"); info.setPhone(randomInteger(8, seed)); info.setVatNumber(randomNumericString(8, seed)); info.setYear(createTestCCYear()); info.setMonth(createTestCCMonth()); info.setNumber(createTestCCNumber()); info.setVerificationValue(createTestCCVerificationNumber()); return info; }
public void setUpdatedAt(final Object updatedAt) { this.updatedAt = dateTimeOrNull(updatedAt); }
return false; if (billingInfo != null ? !billingInfo.equals(account.billingInfo) : account.billingInfo != null) { return false;
/** * Update an account's billing info * <p> * When new or updated credit card information is updated, the billing information is only saved if the credit card * is valid. If the account has a past due invoice, the outstanding balance will be collected to validate the * billing information. * <p> * If the account does not exist before the API request, the account will be created if the billing information * is valid. * <p> * Please note: this API end-point may be used to import billing information without security codes (CVV). * Recurly recommends requiring CVV from your customers when collecting new or updated billing information. * * @param billingInfo billing info object to create or update * @return the newly created or update billing info object on success, null otherwise */ public BillingInfo createOrUpdateBillingInfo(final BillingInfo billingInfo) { final String accountCode = billingInfo.getAccount().getAccountCode(); // Unset it to avoid confusing Recurly billingInfo.setAccount(null); return doPUT(Account.ACCOUNT_RESOURCE + "/" + accountCode + BillingInfo.BILLING_INFO_RESOURCE, billingInfo, BillingInfo.class); }
@Test(groups = "fast") public void testSerialization() throws Exception { final BillingInfo billingInfo = new BillingInfo(); billingInfo.setAddress1(randomString()); billingInfo.setAddress2(randomString()); billingInfo.setCardType(randomString()); billingInfo.setCity(randomString()); billingInfo.setCompany(randomString()); billingInfo.setCountry(randomString()); billingInfo.setFirstName(randomString()); billingInfo.setFirstSix(randomString()); billingInfo.setIpAddress(randomString()); billingInfo.setIpAddressCountry(randomString()); billingInfo.setLastFour(randomString()); billingInfo.setLastName(randomString()); billingInfo.setMonth(3); billingInfo.setNumber(randomString()); billingInfo.setPhone(randomString()); billingInfo.setState(randomString()); billingInfo.setVatNumber(randomString()); billingInfo.setVerificationValue("009"); //CVV can have leading zeroes billingInfo.setYear(Integer.MIN_VALUE); billingInfo.setZip(randomString()); billingInfo.setGeoCode(randomString()); billingInfo.setGatewayToken(randomString()); billingInfo.setGatewayCode(randomString()); final String xml = xmlMapper.writeValueAsString(billingInfo); Assert.assertEquals(xmlMapper.readValue(xml, BillingInfo.class), billingInfo); }
Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getFirstName(), "0dec5"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getLastName(), "91faa8"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getAddress1(), "680a5d6012"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getAddress2(), "cf66c41dea"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getCity(), "b77f65bff7"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getState(), "c3274dd270"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getZip(), "b12f7"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getCountry(), "f0ba2"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getPhone(), "6"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getVatNumber(), "7"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getCardType(), "Visa"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getYear(), (Integer) 2015); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getMonth(), (Integer) 11); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getFirstSix(), "400000"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getLastFour(), "0093");
assertEquals(billingInfo.getAddress1(), "400 Alabama St"); assertEquals(billingInfo.getCity(), "San Francisco"); assertEquals(billingInfo.getState(), "CA"); assertEquals(billingInfo.getCountry(), "US"); assertEquals(billingInfo.getZip(), "94110"); assertEquals(billingInfo.getFirstName(), "Benjamin"); assertEquals(billingInfo.getLastName(), "Du Monde"); assertEquals(billingInfo.getMonth(), new Integer(12)); assertEquals(billingInfo.getYear(), new Integer(2019)); assertEquals(billingInfo.getNumber(), "4000-0000-0000-0000");
Assert.assertEquals(billingInfo.getFirstName(), "Verena"); Assert.assertEquals(billingInfo.getLastName(), "Example"); Assert.assertEquals(billingInfo.getAddress1(), "123 Main St."); Assert.assertNull(billingInfo.getAddress2()); Assert.assertEquals(billingInfo.getCity(), "San Francisco"); Assert.assertEquals(billingInfo.getZip(), "94105"); Assert.assertEquals(billingInfo.getCountry(), "US"); Assert.assertNull(billingInfo.getPhone()); Assert.assertNull(billingInfo.getVatNumber());
@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()); } }
billingInfoData.setAccount(account); Assert.assertEquals(billingInfoData.getFirstName(), billingInfo.getFirstName()); Assert.assertEquals(billingInfoData.getLastName(), billingInfo.getLastName()); Assert.assertEquals(billingInfoData.getMonth(), billingInfo.getMonth()); Assert.assertEquals(billingInfoData.getYear(), billingInfo.getYear()); Assert.assertEquals(billingInfo.getCardType(), "Visa");
@Test(groups = "integration") public void testCreateAccountWithBadBillingInfo() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); // See http://docs.recurly.com/payment-gateways/test billingInfoData.setNumber("4000-0000-0000-0093"); try { final Account account = recurlyClient.createAccount(accountData); billingInfoData.setAccount(account); recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.fail("Should have thrown transaction exception"); } catch (TransactionErrorException e) { Assert.assertEquals(e.getErrors().getTransactionError().getErrorCode(), "fraud_ip_address"); Assert.assertEquals(e.getErrors().getTransactionError().getMerchantMessage(), "The payment gateway declined the transaction because it originated from an IP address known for fraudulent transactions."); Assert.assertEquals(e.getErrors().getTransactionError().getCustomerMessage(), "The transaction was declined. Please contact support."); } }
@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()); } }
billingInfoData.setAccount(null); // null out random account fixture billingInfoData.setExternalHppType("adyen"); // set the external hpp collection to adyen accountData.setEmail("benjamin.dumonde@example.com");
/** * Account object associated to this BillingInfo * <p> * Note: when fetching a BillingInfo object from Recurly, the account object is not guaranteed to be populated. * * @return account object */ public Account getAccount() { if (account != null && account.getCreatedAt() == null) { account = fetch(account, Account.class); } return account; }
@Test(groups = "fast") public void testSerialization() throws Exception { final BillingInfo billingInfo = new BillingInfo(); billingInfo.setAddress1(randomString()); billingInfo.setAddress2(randomString()); billingInfo.setCardType(randomString()); billingInfo.setCity(randomString()); billingInfo.setCompany(randomString()); billingInfo.setCountry(randomString()); billingInfo.setFirstName(randomString()); billingInfo.setFirstSix(randomString()); billingInfo.setIpAddress(randomString()); billingInfo.setIpAddressCountry(randomString()); billingInfo.setLastFour(randomString()); billingInfo.setLastName(randomString()); billingInfo.setMonth(3); billingInfo.setNumber(randomString()); billingInfo.setPhone(randomString()); billingInfo.setState(randomString()); billingInfo.setVatNumber(randomString()); billingInfo.setVerificationValue("009"); //CVV can have leading zeroes billingInfo.setYear(Integer.MIN_VALUE); billingInfo.setZip(randomString()); billingInfo.setGeoCode(randomString()); billingInfo.setGatewayToken(randomString()); billingInfo.setGatewayCode(randomString()); final String xml = xmlMapper.writeValueAsString(billingInfo); Assert.assertEquals(xmlMapper.readValue(xml, BillingInfo.class), billingInfo); }
Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getFirstName(), "0dec5"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getLastName(), "91faa8"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getAddress1(), "680a5d6012"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getAddress2(), "cf66c41dea"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getCity(), "b77f65bff7"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getState(), "c3274dd270"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getZip(), "b12f7"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getCountry(), "f0ba2"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getPhone(), "6"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getVatNumber(), "7"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getCardType(), "Visa"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getYear(), (Integer) 2015); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getMonth(), (Integer) 11); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getFirstSix(), "400000"); Assert.assertEquals(errors.getTransaction().getDetails().getAccount().getBillingInfo().getLastFour(), "0093");
assertEquals(billingInfo.getAddress1(), "400 Alabama St"); assertEquals(billingInfo.getCity(), "San Francisco"); assertEquals(billingInfo.getState(), "CA"); assertEquals(billingInfo.getCountry(), "US"); assertEquals(billingInfo.getZip(), "94110"); assertEquals(billingInfo.getFirstName(), "Benjamin"); assertEquals(billingInfo.getLastName(), "Du Monde"); assertEquals(billingInfo.getMonth(), new Integer(12)); assertEquals(billingInfo.getYear(), new Integer(2019)); assertEquals(billingInfo.getNumber(), "4000-0000-0000-0000");
Assert.assertEquals(billingInfo.getFirstName(), "Verena"); Assert.assertEquals(billingInfo.getLastName(), "Example"); Assert.assertEquals(billingInfo.getAddress1(), "123 Main St."); Assert.assertNull(billingInfo.getAddress2()); Assert.assertEquals(billingInfo.getCity(), "San Francisco"); Assert.assertEquals(billingInfo.getZip(), "94105"); Assert.assertEquals(billingInfo.getCountry(), "US"); Assert.assertNull(billingInfo.getPhone()); Assert.assertNull(billingInfo.getVatNumber());
@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()); } }
billingInfoData.setAccount(account); Assert.assertEquals(billingInfoData.getFirstName(), billingInfo.getFirstName()); Assert.assertEquals(billingInfoData.getLastName(), billingInfo.getLastName()); Assert.assertEquals(billingInfoData.getMonth(), billingInfo.getMonth()); Assert.assertEquals(billingInfoData.getYear(), billingInfo.getYear()); Assert.assertEquals(billingInfo.getCardType(), "Visa");