This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Accounts
somentelucas edited this page Aug 27, 2018
·
20 revisions
TO DO
TO DO
authorization | able |
---|---|
Basic Auth | ❌ |
OAuth | ✅ |
Map<String, Object> hasAccount = Moip.API.accounts().checkExistence("[email protected]", setup);
The search argument can be a tax document number (with punctuation) or an e-mail. Exemple:
cpf=123.123.123-99
,cnpj=36.933.105/0001-40
or[email protected]
.
response | account |
---|---|
200 | exist |
400 | invalid |
404 | does not exist |
authorization | able |
---|---|
Basic Auth | ❌ |
OAuth | ✅ |
Map<String, Object> email = payloadFactory(
value("address", "[email protected]")
);
Map<String, Object> taxDocument = payloadFactory(
value("type", "CPF"),
value("number", "123.456.789-00")
);
Map<String, Object> identityDocument = payloadFactory(
value("type", "RG"),
value("number", "434322344"),
value("issuer", "SSP"),
value("issueDate", "2010-01-01")
);
Map<String, Object> phone = payloadFactory(
value("countryCode", "55"),
value("areaCode", "11"),
value("number", "43215678")
);
Map<String, Object> address = payloadFactory(
value("street", "Av. Brigadeiro Faria Lima"),
value("streetNumber", "2927"),
value("district", "Itaim Bibi"),
value("city", "São Paulo"),
value("state", "SP"), // UF
value("country", "BRA"),
value("zipCode", "01234-000")
);
Map<String, Object> person = payloadFactory(
value("name", "Name"),
value("lastName", "Last Name"),
value("taxDocument", taxDocument),
value("identityDocument", identityDocument),
value("birthDate", "2000-01-01"),
value("phone", phone),
value("address", address)
);
Map<String, Object> body = payloadFactory(
value("email", email),
value("person", person),
value("type", "MERCHANT")
);
Map<String, Object> hasAccount = Moip.API.accounts().create(body, setup);
To create a company account you have to create the same structure of the previous example and add the company object in the request body.
Map<String, Object> taxDocument = new HashMap<>();
taxDocument.put("type", "CNPJ");
taxDocument.put("number", "25.789.340/0001-74");
Map<String, Object> mainActivity = new HashMap<>();
mainActivity.put("cnae", "82.91-1/00");
mainActivity.put("description", "Description of main activity");
Map<String, Object> phone = new HashMap<>();
phone.put("countryCode", "55");
phone.put("areaCode", "11");
phone.put("number", "56784321");
Map<String, Object> address = new HashMap<>();
address.put("street", "Av. Company");
address.put("streetNumber", "123");
address.put("complement", "Address complement");
address.put("district", "The District");
address.put("city", "New City");
address.put("state", "SP");
address.put("country", "BRA");
address.put("zipCode", "43210-01");
Map<String, Object> company = new HashMap<>();
company.put("name", "Name INC.");
company.put("businessName", "Business Name");
company.put("openingDate", "2018-08-21");
company.put("taxDocument", taxDocument);
company.put("mainActivity", mainActivity);
company.put("phone", phone);
company.put("address", address);
So, the request body should be:
Map<String, Object> body = new HashMap<>();
body.put("email", email);
body.put("person", person);
body.put("company", company);
body.put("type", "MERCHANT");
Map<String, Object> hasAccount = Moip.API.accounts().create(body, setup);