/** * Create an account. */ public static Account create(Map<String, Object> params) throws StripeException { return create(params, null); }
/** * Delete an account. */ public Account delete(Map<String, Object> params) throws StripeException { return delete(params, null); }
public void setDestinationObject(Account c) { this.destination = new ExpandableField<>(c.getId(), c); } // </editor-fold>
/** * List all connected accounts. */ public static AccountCollection list(Map<String, Object> params, RequestOptions options) throws StripeException { return requestCollection(classUrl(Account.class), params, AccountCollection.class, options); } // </editor-fold>
/** * List an account's persons. */ public PersonCollection persons(Map<String, Object> params, RequestOptions options) throws StripeException { String url = instanceUrl(Account.class, this.getId()) + "/persons"; return requestCollection(url, params, PersonCollection.class, options); } // </editor-fold>
@Test public void testCreate() throws StripeException { final Account account = Account.retrieve(ACCOUNT_ID, null); final PersonCollection personsTmp = getPersonCollectionFixture(account); final Map<String, Object> params = new HashMap<>(); params.put("first_name", "John"); final Person person = personsTmp.create(params); assertNotNull(person); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/accounts/%s/persons", account.getId()), params ); }
@Test public void testPersons() throws StripeException { final Account resource = Account.retrieve(ACCOUNT_ID, null); final Map<String, Object> params = new HashMap<>(); params.put("limit", 1); final PersonCollection persons = resource.persons(params); assertNotNull(persons); verifyRequest( ApiResource.RequestMethod.GET, String.format("/v1/accounts/%s/persons", resource.getId()), params ); } }
@Test public void testCreate() throws IOException, StripeException { final Account account = Account.retrieve(ACCOUNT_ID, null); // stripe-mock doesn't support this final LoginLinkCollection stubbedCollection = new LoginLinkCollection(); stubbedCollection.setUrl(String.format("/v1/accounts/%s/login_links", account.getId())); account.setLoginLinks(stubbedCollection); stubRequest( ApiResource.RequestMethod.POST, String.format("/v1/accounts/%s/login_links", account.getId()), null, LoginLink.class, getResourceAsString("/api_fixtures/login_link.json") ); final LoginLink link = account.getLoginLinks().create(); assertNotNull(link); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/accounts/%s/login_links", account.getId()) ); } }
@Test public void testAccountCreateExternalAccount() throws StripeException { final Account resource = Account.retrieve(ACCOUNT_ID, null); final Map<String, Object> params = new HashMap<>(); params.put("external_account", "tok_123"); final ExternalAccount ea = resource.getExternalAccounts().create(params); assertNotNull(ea); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/accounts/%s/external_accounts", resource.getId()), params ); }
@Test public void testDelete() throws StripeException { final Account account = getAccountFixture(); final Account deletedAccount = account.delete(); assertNotNull(deletedAccount); assertTrue(deletedAccount.getDeleted()); verifyRequest( ApiResource.RequestMethod.DELETE, String.format("/v1/accounts/%s", account.getId()) ); }
/** * Reject an account. */ public Account reject(Map<String, Object> params, RequestOptions options) throws StripeException { return request(RequestMethod.POST, String.format("%s/reject", instanceUrl(Account.class, this.getId())), params, Account.class, options); } // </editor-fold>
/** * Retrieve account details. */ public static Account retrieve(String id, RequestOptions options) throws StripeException { return retrieve(id, null, options); }
@Test public void testReject() throws StripeException { final Account account = getAccountFixture(); final Map<String, Object> params = new HashMap<>(); params.put("reason", "fraud"); Account rejectedAccount = account.reject(params); assertNotNull(rejectedAccount); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/accounts/%s/reject", account.getId()), params ); }
@Test public void testUpdate() throws StripeException { final Account account = getAccountFixture(); final Map<String, Object> legalEntity = new HashMap<>(); legalEntity.put("type", "individual"); final Map<String, Object> params = new HashMap<>(); params.put("legal_entity", legalEntity); final Account updatedAccount = account.update(params); assertNotNull(updatedAccount); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/accounts/%s", account.getId()), params ); }
/** * List an account's persons. */ public PersonCollection persons() throws StripeException { return persons(null, null); }
/** * List all connected accounts. */ public static AccountCollection list(Map<String, Object> params) throws StripeException { return list(params, null); }
/** * Update an account. */ @Override public Account update(Map<String, Object> params) throws StripeException { return update(params, null); }
/** * Reject an account. */ public Account reject(Map<String, Object> params) throws StripeException { return reject(params, null); }
@Test public void testRetrieve() throws StripeException { final Account account = Account.retrieve(ACCOUNT_ID, null); final PersonCollection personsTmp = getPersonCollectionFixture(account); Person person = personsTmp.retrieve(PERSON_ID); assertNotNull(person); verifyRequest( ApiResource.RequestMethod.GET, String.format("/v1/accounts/%s/persons/%s", account.getId(), PERSON_ID) ); }