Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Accounts

Lucas Garcia edited this page Sep 6, 2018 · 20 revisions

Introduction

TO DO

Dependencies

import static br.com.moip.helpers.PayloadFactory.payloadFactory;
import static br.com.moip.helpers.PayloadFactory.value;

Features

Index

Check account existence

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: 123.123.123-99, 36.933.105/0001-40 or [email protected].

response account
200 exist
400 invalid
404 does not exist

Create account

authorization able
Basic Auth
OAuth

Classical account

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);

Company account

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 = payloadFactory(
    value("type", "CNPJ"),
    value("number", "25.789.340/0001-74")
);

Map<String, Object> mainActivity = payloadFactory(
    value("cnae", "82.91-1/00"),
    value("description", "Description of main activity")
);

Map<String, Object> phone = new payloadFactory(
    value("countryCode", "55"),
    value("areaCode", "11"),
    value("number", "56784321")
);

Map<String, Object> address = payloadFactory(
    value("street", "Av. Company"),
    value("streetNumber", "123"),
    value("complement", "Address complement"),
    value("district", "The District"),
    value("city", "New City"),
    value("state", "SP"),
    value("country", "BRA"),
    value("zipCode", "43210-01")
);

Map<String, Object> company = payloadFactory(
    value("name", "Name INC."),
    value("businessName", "Business Name"),
    value("openingDate", "2018-08-21"),
    value("taxDocument", taxDocument),
    value("mainActivity", mainActivity),
    value("phone", phone),
    value("address", address)
);

So, the request body should be:

Map<String, Object> body = payloadFactory(
    value("email", email),
    value("person", person),
    value("company", company),
    value("type", "MERCHANT")
);

Map<String, Object> hasAccount = Moip.API.accounts().create(body, setup);

Transparent account

To create a transparent Moip account, just add an extra attribute transparentAccount like this:

Map<String, Object> body = payloadFactory(
    value("email", email),
    value("person", person),
    value("company", company),
    value("type", "MERCHANT"),
    value("transparentAccount", true)
);

Map<String, Object> hasAccount = Moip.API.accounts().create(body, setup);

Get account

authorization able
Basic Auth
OAuth

To get the details of an account, you just need to pass the ID of the account. It's important to remember that the Authorization used must be the authorization of the account being checked.

Map<String, Object> hasAccount = Moip.API.accounts().get("MPA-XXXXXXXXXXXX", setup);

Get public keys

authorization able
Basic Auth
OAuth
Map<String, Object> keys = Moip.API.accounts(). getKeys(setup);