Ofereça o meio de pagamento que encanta seus clientes

Integre o checkout preferido de quem mais consome na internet e crie uma experiência “WOW”!


API Reference

Intro

Welcome to Moip new payments API documentation. Here you'll find all reference of our APIS.
If you want to take a look at the business documentation click here.

RESTful

V2 APIs are based on RESTful architecture design and use JSON as content-type UTF-8 encoded. Our API resources are named after the objects they represent (like orders, payments, customers, refunds, etc.) and we support many HTTP verbs for each resource.
This way, one resource (for example: "v2/customers/") can be used to create a customer through the POST method as well as listing customers through the GET method.
The APIs were designed with the hypermedia concept (HATEOAS) so you can use our links structure between resources to automate your application and simplify your integration.

Error states

Every API request will return a HTTP Status and a JSON showing the objects you have interacted with.

Attributes

namedescriptiondetails
codeERROR IDstring
pathAttribute related to the errorstring
descriptionA brief description (in Portuguese)string

All mapped errors will return a http status 4xx to your application. If you get a 5xx error, please send us an email giving details of your request and we'll fix it asap.

  • 400 errors Must be treated from your application. The APIs will return a JSON with details of the problem.
  • 401 errors Indicates an authentication problem. Make sure you are using the right keys to authenticate and if you are pointing to the right environment.
  • 500 errors are internal errors. that shouldn't happen but if it does please send an email to [email protected]

Example:

{
  "errors": [
    {
      "code": "ORD-001",
      "path": "ownId",
      "description": "É necessário informar seu identificador próprio"
    }
  ]
}

Click here to see the complete error list.

Response pattern

For POST /resources and GET /resources/:id methods you will receive a full representation of the resource requested, except by null or empty attributes which will be omitted.
In case of nested resources (like payments inside orders) when consulting the main resource, you'll also receive a minimal view of the nested one. The minimal view is small version of a resource, containing only the most relevant attributes.

Versions

The APIs are now on its 2.0 version. All parameters and attributes available for every request are represented in this documentation.
Any future changes that may be incompatible with current integrations will be treated as new versions. Any other changes that don't affect compatibility will be documented in the Changelog section.

What are considered changes that don't affect compatibility?

  • Including new resources or new attributes in an existent resource
  • Including new optional parameters in existent methods
  • Changing the order of attributes in a response
  • Changing null attributes format. Your application must understand null, "" attributes or attributes that are not returned
  • Including new webhooks events

Listing and searching

Some APIs have available a resource that allows you to retrieve details from an object.
To do so you have 3 parameters to refine your request.

  • Pagination - Determines how many objects will be returned.
  • Generic search - Search a string that you have used to create a resource (IDs, Emails, Name, etc.)
  • Filters - Specifies parameters for searching.

Pagination

The objects have a descendant order by creation date.

NameTypeDescription
limitintegerNumber of objects returned (by page). Default value is 20.
offsetintegerThe resource where the search started. Default value is 0.

Example:

GET: v2/recurso?limit=100&offset=300

When listing a resource, the API will return two hyperlinks of next and previous pages (`_links.next` e `_links.previous`).

Generic search

This is the easiest method to search for a resource inside the APIs.

namedescription
qSearch for a specific string.

example

GET: v2/resource?q=my_own_id

Filters

Filters can be used to refine your search, for example you can request orders on a specific status or between dates.
Not all resources have attributes available for filtering. Take a look at the resource you want to filter to know what attributes you can use as a parameter.

Delimiters:

The URI must be built with the attributes using delimiters inside the parameter filters.
Use delimiters :: to represent a key and a value and | to represent the end of a filter and the beginning of a new one.

nametypedescription
gt(x)number or date“Greater Than”
ge(x)number or date“Greater than or Equal”
lt(x)number or date“Less Than”
le(x)number or date“Less than or Equal”
bt(x,y)string- “BeTween”
in(x,y…z)string- “IN”

Short example

GET: v2/resource?filters=status::in(PAID,WAITING)

Complete example

A search for payments having amount between 5000 and 10000 (in cents), paid with credit card or boleto and status paid or waiting.
This search also includes the customer's name (in this case Mr. Ken Masters) and will contain 3 objects.

GET: https://sandbox.moip.com.br/v2/orders?q=Ken Masters&filters=status::in(PAID,WAITING)|paymentMethod::in(CREDIT_CARD,BOLETO)|value::bt(5000,10000)&limit=3&offset=0

Environments

All examples available in this documentation are referring to the sandbox environment where real transactions don’t happen.
However, the sandbox behaves exactly like the production environment and follows all other aspects of it.

Once you finish to integrate with the sandbox you need to change your API keys and URI to point to the production environment.

  • Production: https://api.moip.com.br
  • Sandbox: https://sandbox.moip.com.br

Changelog

Our changelog is available here. There you can follow the changes we have implemented and you can also enter on our notification list.

Getting started

We strongly recommend you to take a look at the Getting Started topics here to have a full understanding of the services we offer and which one of them will be necessary for you and your business.
If you have any questions or need any help just send an email to [email protected] and we'll gladly take some time to make you start playing the game. ;)

Customers

The Customer is the user of a service or a person buying a product. This API allows you to create a retrieve a customer object.

Attributes:

NameDescriptionDetails
__
idMoip customer ID.string(16), response
ownIdCustomer ownId. External reference.string(65)
fullnameCustomer's fullname.string(90)
emailEmail.string(45)
phonePhone.structured
├─countryCodeCountry code. Possible values: 55.integer(2)
├─areaCodeArea code.integer(2)
└─numberPhone number.integer(9)
birthDateBirth date.date (YYYY-MM-DD)
taxDocumentDocument.structured
├─typeType of document. Possible values: CPF for social security number, CNPJ for tax identification number.string
└─numberDocument number.string(11)
shippingAddressShipping address.Object Address
fundingInstrumentFunding instrument. DEPRECATED removed in 15/01/16structured
├─methodFunding instrument method. Possible values: CREDIT_CARDstring
└─creditCardCredit card.[object Credit card
fundingInstrumentsFunding instruments.structured list
├─methodFunding instrument methods. Possible values: CREDIT_CARDstring
└─creditCardCredit card.object Credit card
createdAtResource creation date.datetime, response
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
└─└─hrefResource URI.link
├─hostedAccountHyperlink to the hosted account.structured
└─└─redirectUrlURL redirecting to the hostedAccount.link

Create a customer [POST]

Through this API you can create a Customer with credit card info for future use.

Endpoint

POST https://sandbox.moip.com.br/v2/customers

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
  "ownId": "meu_id_sandbox_1231234",
  "fullname": "Jose Silva",
  "email": "[email protected]",
  "birthDate": "1988-12-30",
  "taxDocument": {
    "type": "CPF",
    "number": "22222222222"
  },
  "phone": {
    "countryCode": "55",
    "areaCode": "11",
    "number": "66778899"
  },
  "shippingAddress": {
    "city": "Sao Paulo",
    "complement": "8",
    "district": "Itaim",
    "street": "Avenida Faria Lima",
    "streetNumber": "2927",
    "zipCode": "01234000",
    "state": "SP",
    "country": "BRA"
  }
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = '{
  "ownId": "meu_id_sandbox_1231234",
  "fullname": "Jose Silva",
  "email": "[email protected]",
  "birthDate": "1988-12-30",
  "taxDocument": {
    "type": "CPF",
    "number": "22222222222"
  },
  "phone": {
    "countryCode": "55",
    "areaCode": "11",
    "number": "66778899"
  },
  "shippingAddress": {
    "city": "Sao Paulo",
    "complement": "8",
    "district": "Itaim",
    "street": "Avenida Faria Lima",
    "streetNumber": "2927",
    "zipCode": "01234000",
    "state": "SP",
    "country": "BRA"
  }
}'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MEVSVkROMzg2V0UzUlpSSTRZWUc2UUNETE1KNTdMQlI6U1JaR0hSWFlPVDBQVkRMUkIzWUU4WFFXTE5MQTBKUlhUS09JRFZEUQ=='
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/customers', values, headers
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MEVSVkROMzg2V0UzUlpSSTRZWUc2UUNETE1KNTdMQlI6U1JaR0hSWFlPVDBQVkRMUkIzWUU4WFFXTE5MQTBKUlhUS09JRFZEUQ=='
}

values = """
  {
  "ownId": "meu_id_sandbox_1231234",
  "fullname": "Jose Silva",
  "email": "[email protected]",
  "birthDate": "1988-12-30",
  "taxDocument": {
    "type": "CPF",
    "number": "22222222222"
  },
  "phone": {
    "countryCode": "55",
    "areaCode": "11",
    "number": "66778899"
  },
  "shippingAddress": {
    "city": "Sao Paulo",
    "complement": "8",
    "district": "Itaim",
    "street": "Avenida Faria Lima",
    "streetNumber": "2927",
    "zipCode": "01234000",
    "state": "SP",
    "country": "BRA"
  }
}
"""

request = Request('https://sandbox.moip.com.br/v2/customers', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Customer customer = moip.customers()
                        .setOwnId("sandbox_v2_1401147277")
                        .setFullname("Jose Silva")
                        .setEmail("[email protected]")
                        .setBirthDate("1988-12-30")
                        .setTaxDocument("33333333333", "CPF")
                        .setPhone("11", "66778899", "55")
                        .addAddress("BILLING",
                                    "Avenida Faria Lima", "2927",
                                    "Itaim", "Sao Paulo", "SP",
                                    "01234000", "8")
                        .create();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$customer = $moip->customers()->setOwnId('sandbox_v2_1401147277')
                              ->setFullname('Jose Silva')
                              ->setEmail('[email protected]')
                              ->setBirthDate('1988-12-30')
                              ->setTaxDocument('33333333333')
                              ->setPhone(11, 66778899)
                              ->addAddress('BILLING',
                                           'Avenida Faria Lima', 2927,
                                           'Itaim', 'Sao Paulo', 'SP',
                                           '01234000', 8)
                              ->create();

Response:

201 (Created)
Content-Type: application/json
{
  "id": "CUS-Y6L4AGQN8HKQ",
  "ownId": "meu_id_sandbox_1231234",
  "fullname": "Jose Silva",
  "createdAt": "2015-01-14T11:28:22-0200",
  "birthDate": "1988-12-30",
  "email": "[email protected]",
  "phone": {
    "countryCode": "55",
    "areaCode": "11",
    "number": "66778899"
  },
  "taxDocument": {
    "type": "CPF",
    "number": "22222222222"
  },
  "shippingAddress": {
    "zipCode": "01234000",
    "street": "Avenida Faria Lima",
    "streetNumber": "2927",
    "complement": "8",
    "city": "Sao Paulo",
    "district": "Itaim",
    "state": "SP",
    "country": "BRA"
  },
  "_links": {
    "self": {
      "href": "https://sandbox.moip.com.br/v2/customers/CUS-Y6L4AGQN8HKQ"
    },
    "hostedAccount": {
      "redirectHref": "http://hostedaccount.moip.com.br?token=97aa89b7-89bb-4a48-89eb-52d679dbc7c7&id=CUS-Y6L4AGQN8HKQ&mpa=MPA-M1VCC0UNt"
  }
}

Parameters:

NameDescriptionDetails
__
ownIdCustomer ownId. External reference.string (65), required
fullnameCustomer's fullname.string(90), required
emailEmail.string(45), required
phonePhone.structured
├─countryCodeCountry code. Possible values: 55.integer(2), optional *
├─areaCodeArea code.integer(2), optional *
└─numberPhone number.integer(9), optional *
birthDateBirth date.date(YYYY-MM-DD), optional *
taxDocumentDocument.structured
├─typeType of document. Possible values: CPF for social security number, CNPJ for tax identification number.string(3), optional *
└─numberDocument number.string(11), optional *
shippingAddressShipping address.Object Address, optional *
fundingInstrumentsFunding instruments.structured list
├─methodFunding instrument methods. Possible values: CREDIT_CARDstring optional
└─creditCardCredit card.object Credit card optional

*These fields are required for the Protected Sales Program

Retrieve a customer [GET]

This APIs is used to retrieve and consult customer details.

Endpoint

GET https://sandbox.moip.com.br/v2/customers/{customer_id}

Example

GET https://sandbox.moip.com.br/v2/customers/CUS-Y6L4AGQN8HKQ

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.get 'https://sandbox.moip.com.br/v2/customers/id', headers
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/customers/id', headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Customer customer = moip.customers().get("CUS-Y6L4AGQN8HKQ");
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$customer = $moip->customers()->get('CUS-Y6L4AGQN8HKQ');

Response:

200 (OK)
Content-Type: application/json
 {
  "id": "CUS-Y6L4AGQN8HKQ",
  "ownId": "meu_id_sandbox_1231234",
  "fullname": "Jose Silva",
  "createdAt": "2015-01-14T11:28:22-0200",
  "birthDate": "1988-12-30T00:00:00-0200",
  "email": "[email protected]",
  "phone": {
    "countryCode": "55",
    "areaCode": "11",
    "number": "66778899"
  },
  "taxDocument": {
    "type": "CPF",
    "number": "22222222222"
  },
  "shippingAddress": {
    "zipCode": "01234000",
    "street": "Avenida Faria Lima",
    "streetNumber": "2927",
    "complement": "8",
    "city": "Sao Paulo",
    "district": "Itaim",
    "state": "SP",
    "country": "BRA"
  },
  "_links": {
    "self": {
      "href": "https://sandbox.moip.com.br/v2/customers/CUS-Y6L4AGQN8HKQ"
    }
  }
}

Parameters:

NameDescriptionDetails
idCustomer ID. Example: CUS-Y6L4AGQN8HKQstring(16), required

Add a credit card [POST]

This API allows you to add a credit card for a customer.

Endpoint

POST https://sandbox.moip.com.br/v2/customers/{customer_id}/fundinginstruments

Example

POST https://sandbox.moip.com.br/v2/customers/CUS-Y6L4AGQN8HKQ/fundinginstruments

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
  "method": "CREDIT_CARD",
  "creditCard": {
    "expirationMonth": "05",
    "expirationYear": "18",
    "number": "5555666677778884",
    "cvc": "123",
    "holder": {
      "fullname": "Jose Portador da Silva",
      "birthdate": "1988-12-30",
      "taxDocument": {
        "type": "CPF",
        "number": "33333333333"
      },
      "phone": {
        "countryCode": "55",
        "areaCode": "11",
        "number": "66778899"
      }
    }
  }
}
# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

201 (Created)
Content-Type: application/json
{
  "method": "CREDIT_CARD",
  "creditCard": {
    "id": "CRC-NLBLOTNB6LLT",
    "brand": "MASTERCARD",
    "first6": "555566",
    "last4": "8884"
  }
}

Parameters:

NameDescriptionDetails
idCustomer ID.string(16), required
methodMethod of the fundingInstrument. Possible values: CREDIT_CARDstring optional
creditCardCreditCard.object Credit Card optional
phonePhone.structured
├─countryCodeCountry code. Possible values: 55.integer(2), optional *
├─areaCodeArea code.integer(2), optional *
└─numberPhone number.integer(9), optional *

Orders

An Order is the representation of the product or service offered. This API allows you to create and retrieve an order.

Attributes:

NameDescriptionDetails
____
idOrder ID.string(16), response
ownIdOwn id of an order. External reference.string(65)
statusOrders status. Possible values: CREATED, WAITING, PAID, NOT_PAID, REVERTED.string, response
createdAtResource creation date.datetime, response
amountOrder values.structured
├─totalTotal amount charged in cents. Ex: R$10,32 must be informed as 1032integer(12), response
├─feesMoip fees.integer(12), response
├─refundsTotal amount refunded.integer(12), response
├─liquidLiquid amount.integer(12), response
├─otherReceiversSum of amount sent to other receivers.integer(12), response
├─currencyCurrency. Possible values: BRL.string
├─subtotalsEstrutura de valores adicionais do pedido.structured
├ ├─shippingShipping cost. It will be added to the items amount. Ex: R$10,32 must be informed as 1032integer(12)
├ ├─additionAdition amount. It will be added to the items amount. Ex: R$10,32 must be informed as 1032integer(12)
├ ├─discountDiscount amount. This value will be deducted from the total amount. Ex: R$10,32 must be informed as 1032integer(12)
└ └─itemsSum of the amount from all items.integer(12), response
itemsItems structure.structured list
├─productProduct name.string(256)
├─quantityQuantity of products.integer(12)
├─detailDescription.string(250)
└─pricePrice of 1 product. (The value is multiplied according to the number of products.). In cents Ex: R$10,32 must be informed as 1032integer(12)
checkoutPreferencesCheckout setup.structured
├─redirectUrlsRedirect URLs.string(256)
├ ├─urlSuccessRedirect URL for successful payments.link
└ └─urlFailureRedirect URL for failed payments.link
├─installmentsInstallments setup.structured list
├ ├─quantityDelimiters for installments. Example: [1, 3];tupla
├ ├─discountDiscount for installments number.integer
└ └─additionAdition for installments number.integer
shippingAddressEndereço de entrega.structured Objeto: Address, response
customerCustomer related to the order.Customer
paymentsPayments attached to the order. For more information take a look at the resource payments. Payment.Collection of Payments, response
refundsRefunds attached to the order. For more information take a look at the resource Refunds.Collection of Refunds, response
entriesEntries related to the order. For more information take a look at the resource Entry.Collection of Entries, response
eventsEvents related to the payment.structured list, response
├─createdAtEvent date.date(YYYY-MM-DD), response
├─typeEvent type. Possible values:ORDER.CREATED, ORDER.WAITING, ORDER.PAID, ORDER.NOT_PAID, ORDER.REVERTED.string, response
└─descriptionEvent description.string(65), response
receiversReceivers structure.structured list
├─typeReceiver type. Possible values: PRIMARY, SECONDARY.string
├─moipAccountMoip account structure.structured
├ ├─loginLogin.string(256)
├ ├─fullnameName of the account holder.string(256)
├ └─idAccount ID.string(16)
├─amountStructure of the amount to be received.structured
├ ├─refundsTotal amount refunded from this receiver.integer(12)
├ ├─feesTotal fees charged from this receiver.integer(12)
└ └─totalTotal received. Ex: R$10,32 must be informed as 1032integer(12)
updatedAtDate when the resource was last updated.datetime, response
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
├ └─hrefResource URI.link
└─checkoutCheckout links.object Moip Checkout

Create an order [POST]

Through this API you can create an Order containing details of the product or service you are offering.
You can create a customer using customer’s API or orders API. If a customer doesn't exist, the orders API will create it automatically.

Endpoint

POST https://sandbox.moip.com.br/v2/orders

Example

Below we have a sample of an order bring created with all attributes required by the Protected Sales Program.

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
  "ownId": "seu_identificador_proprio",
  "amount": {
    "currency": "BRL",
    "subtotals": {
      "shipping": 1000
    }
  },
  "items": [
    {
      "product": "Descrição do pedido",
      "quantity": 1,
      "detail": "Mais info...",
      "price": 1000
    }
  ],
  "customer": {
    "ownId": "seu_identificador_proprio_de_cliente",
    "fullname": "Jose Silva",
    "email": "[email protected]",
    "birthDate": "1988-12-30",
    "taxDocument": {
      "type": "CPF",
      "number": "22222222222"
    },
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "66778899"
    },
    "shippingAddress": {
      "street": "Avenida Faria Lima",
      "streetNumber": 2927,
      "complement": 8,
      "district": "Itaim",
      "city": "Sao Paulo",
      "state": "SP",
      "country": "BRA",
      "zipCode": "01234000"
    }
  }
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = '{
  "ownId": "seu_identificador_proprio",
  "amount": {
    "currency": "BRL",
    "subtotals": {
      "shipping": 1000
    }
  },
  "items": [
    {
      "product": "Descrição do pedido",
      "quantity": 1,
      "detail": "Mais info...",
      "price": 1000
    }
  ],
  "customer": {
    "ownId": "seu_identificador_proprio_de_cliente",
    "fullname": "Jose Silva",
    "email": "[email protected]",
    "birthDate": "1988-12-30",
    "taxDocument": {
      "type": "CPF",
      "number": "22222222222"
    },
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "66778899"
    },
    "shippingAddress": {
      "street": "Avenida Faria Lima",
      "streetNumber": 2927,
      "complement": 8,
      "district": "Itaim",
      "city": "Sao Paulo",
      "state": "SP",
      "country": "BRA",
      "zipCode": "01234000"
    }
  }
}'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/orders', values, headers
puts response
from urllib2 import Request, urlopen

values = """
{
  "ownId": "seu_identificador_proprio",
  "amount": {
    "currency": "BRL",
    "subtotals": {
      "shipping": 1000
    }
  },
  "items": [
    {
      "product": "Descrição do pedido",
      "quantity": 1,
      "detail": "Mais info...",
      "price": 1000
    }
  ],
  "customer": {
    "ownId": "seu_identificador_proprio_de_cliente",
    "fullname": "Jose Silva",
    "email": "[email protected]",
    "birthDate": "1988-12-30",
    "taxDocument": {
      "type": "CPF",
      "number": "22222222222"
    },
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "66778899"
    },
    "shippingAddress": {
      "street": "Avenida Faria Lima",
      "streetNumber": 2927,
      "complement": 8,
      "district": "Itaim",
      "city": "Sao Paulo",
      "state": "SP",
      "country": "BRA",
      "zipCode": "01234000"
    }
  }
}
"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/orders', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Order order = moip.orders().setOwnId("seu_identificador_proprio")
                   .addItem("Descrição do pedido", 1, "Mais info...", 10000)
                   .setShippingAmount(100)
                   .setCustomer(moip.customers().setOwnId("seu_identificador_proprio_de_cliente")
                                        .setFullname("Jose da Silva")
                                        .setEmail("[email protected]")
                                        .setBirthDate("1988-12-30")
                                        .setTaxDocument("33333333333")
                                        .setPhone("11", "66778899", "55")
                                        .addAddress("BILLING",
                                                    "Avenida Faria Lima", "2927",
                                                    "Itaim", "Sao Paulo", "SP",
                                                "01234000", "8"))
                           .create();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br/orders';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$order = $moip->orders()->setOwnId('seu_identificador_proprio')
                        ->addItem('Descrição do pedido', 1, 'Mais info...', 10000)
                        ->setShippingAmount(100)
                        ->setCustomer($moip->customers()->setOwnId('seu_identificador_proprio_de_cliente')
                                           ->setFullname('Jose Silva')
                                           ->setEmail('[email protected]')
                                           ->setBirthDate('1988-12-30')
                                           ->setTaxDocument('33333333333')
                                           ->setPhone(11, 66778899)
                                           ->addAddress('BILLING',
                                                        'Avenida Faria Lima', 2927,
                                                        'Itaim', 'Sao Paulo', 'SP',
                                                        '01234000', 8))
                        ->create();

Response:

201 (Created)
Content-Type: application/json

{
  "id": "ORD-NY92W6N4S220",
  "ownId": "seu_identificador_proprio",
  "status": "CREATED",
  "createdAt": "2015-01-14T11:25:10-0200",
  "amount": {
    "total": 2000,
    "fees": 0,
    "refunds": 0,
    "liquid": 0,
    "otherReceivers": 0,
    "currency": "BRL",
    "subtotals": {
      "shipping": 1000,
      "addition": 0,
      "discount": 0,
      "items": 1000
    }
  },
  "items": [
    {
      "detail": "Mais info...",
      "quantity": 1,
      "price": 1000,
      "product": "Descrição do pedido"
    }
  ],
  "customer": {
    "id": "CUS-73HWY5J45TLO",
    "ownId": "seu_identificador_proprio_de_cliente",
    "fullname": "Jose Silva",
    "createdAt": "2015-01-14T11:25:10-0200",
    "birthDate": "1988-12-30T00:00:00-0200",
    "email": "[email protected]",
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "66778899"
    },
    "taxDocument": {
      "type": "CPF",
      "number": "22222222222"
    },
    "shippingAddress": {
      "zipCode": "01234000",
      "street": "Avenida Faria Lima",
      "streetNumber": "2927",
      "complement": "8",
      "city": "Sao Paulo",
      "district": "Itaim",
      "state": "SP",
      "country": "BRA"
    },
    "_links": {
      "self": {
        "href": "https://sandbox.moip.com.br/v2/customers/CUS-73HWY5J45TLO"
      }
    }
  },
  "payments": [],
  "refunds": [],
  "entries": [],
  "events": [
    {
      "createdAt": "2015-01-14T11:25:10-0200",
      "description": "",
      "type": "ORDER.CREATED"
    }
  ],
  "receivers": [
    {
      "amount": {
        "fees": 0,
        "refunds": 0,
        "total": 2000
      },
      "moipAccount": {
        "fullname": "Moip SandBox",
        "login": "[email protected]",
        "id": "MPA-CULBBYHD11"
      },
      "type": "PRIMARY"
    }
  ],
  "shippingAddress": {
    "zipCode": "01234000",
    "street": "Avenida Faria Lima",
    "streetNumber": "2927",
    "complement": "8",
    "city": "Sao Paulo",
    "district": "Itaim",
    "state": "SP",
    "country": "BRA"
  },
  "_links": {
    "self": {
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-NY92W6N4S220"
    },
    "checkout": {
      "payOnlineBankDebitItau": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/itau/ORD-NY92W6N4S220"
      },
      "payOnlineBankDebitBB": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/bancobrasil/ORD-NY92W6N4S220"
      },
      "payCreditCard": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/creditcard/ORD-NY92W6N4S220"
      },
      "payOnlineBankDebitBradesco": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/bradesco/ORD-NY92W6N4S220"
      },
      "payBoleto": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/boleto/ORD-NY92W6N4S220"
      },
      "payOnlineBankDebitBanrisul": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/banrisul/ORD-NY92W6N4S220"
      }
    }
  }
}

Parameters:

NameDescriptionDetails
____
ownIdOwn id of an order. External reference.string(65), required
amountOrder values.structured
├─currencyCurrency. Possible values: BRL.string, optional
├─subtotalsEstrutura de valores adicionais do pedido.structured
├ ├─shippingShipping cost. It will be added to the items amount. Ex: R$10,32 must be informed as 1032integer(12), optional
├ ├─additionAddition amount. It will be added to the items amount. Ex: R$10,32 must be informed as 1032integer(12), optional
├ ├─discountDiscount amount. This value will be deducted from the total amount. Ex: R$10,32 must be informed as 1032integer(12), optional
└ └─itemsSum of the amount from all items.integer(12), response
itemsItems structure.structured list
├─productProduct name.string(256), required *
├─quantityQuantity of products.integer(12), required *
├─detailDescription.string(250), optional *
└─pricePrice of 1 product. (The value is multiplied according to the number of products.). In cents Ex: R$10,32 must be informed as 1032integer(12), required *
customerCustomer. It can be an ID for a customer previously created or the collection of attributes to create a new one.Customer, required *
checkoutPreferencesCheckout setup.structured
├─redirectUrlsRedirect URLs.string(256)
├ ├─urlSuccessRedirect URL for successful payments.link, optional
└ └─urlFailureRedirect URL for failed payments.link, optional
├─installmentsInstallments setup.structured list
├ ├─quantityDelimiters for installments. Example: [1, 3];tupla optional
├ ├─discountDiscount for installments number.integer
└ └─additionAddition for installments number.integer
receiversReceivers structure.structured list
├─typeReceiver type. Possible values: PRIMARY, SECONDARY.string, conditional
├─moipAccountMoip account structure.structured
├ └─idAccount ID.string(16), optional
├─amountStructure of the amount to be received.structured
└ └─fixedFixed amount to be sent to a receiver.integer(12), optional
└ └─percentualPercentual amount to be sent to a receiver.integer(12), optional

*These fields are required for the Protected Sales Program

Retrieve an order [GET]

This API allows you to retrieve details of an order.

Endpoint

GET https://sandbox.moip.com.br/v2/orders/{order_id}

Example

GET https://sandbox.moip.com.br/v2/orders/ORD-4HY0KOA9Q73F

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.get 'https://sandbox.moip.com.br/v2/orders/id', headers
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/orders/id', headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Order order = moip.orders().get("ORD-4HY0KOA9Q73F");
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$order = $moip->orders()->get('ORD-4HY0KOA9Q73F');

Response:

200 (OK)
Content-Type: application/json
{
  "id": "ORD-4HY0KOA9Q73F",
  "ownId": "meu_pedido_sandbox_xxxxx",
  "status": "CREATED",
  "createdAt": "2015-01-14T11:39:15-0200",
  "amount": {
    "total": 2000,
    "fees": 0,
    "refunds": 0,
    "liquid": 0,
    "otherReceivers": 0,
    "currency": "BRL",
    "subtotals": {
      "shipping": 1000,
      "addition": 0,
      "discount": 0,
      "items": 1000
    }
  },
  "items": [
    {
      "detail": "Mais info...",
      "quantity": 1,
      "price": 1000,
      "product": "Produto de testes Sandbox - xxxx"
    }
  ],
  "addresses": [
    {
      "city": "Sao Paulo",
      "complement": "8",
      "street": "Avenida Faria Lima",
      "streetNumber": "2927",
      "zipCode": "01234000",
      "district": "Itaim",
      "state": "SP",
      "type": "SHIPPING",
      "country": "BRA"
    }
  ],
  "customer": {
    "id": "CUS-Y6L4AGQN8HKQ",
    "ownId": "meu_id_sandbox_1231234",
    "fullname": "Jose Silva",
    "createdAt": "2015-01-14T11:28:22-0200",
    "birthDate": "1988-12-30T00:00:00-0200",
    "email": "[email protected]",
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "66778899"
    },
    "taxDocument": {
      "type": "CPF",
      "number": "22222222222"
    },
    "addresses": [
      {
        "city": "Sao Paulo",
        "complement": "8",
        "street": "Avenida Faria Lima",
        "streetNumber": "2927",
        "zipCode": "01234000",
        "district": "Itaim",
        "state": "SP",
        "type": "SHIPPING",
        "country": "BRA"
      }
    ],
    "shippingAddress": {
      "zipCode": "01234000",
      "street": "Avenida Faria Lima",
      "streetNumber": "2927",
      "complement": "8",
      "city": "Sao Paulo",
      "district": "Itaim",
      "state": "SP",
      "country": "BRA"
    },
    "_links": {
      "self": {
        "href": "https://sandbox.moip.com.br/v2/customers/CUS-Y6L4AGQN8HKQ"
      }
    }
  },
  "payments": [],
  "refunds": [],
  "entries": [],
  "events": [
    {
      "createdAt": "2015-01-14T11:39:15-0200",
      "description": "",
      "type": "ORDER.CREATED"
    }
  ],
  "receivers": [
    {
      "amount": {
        "fees": 0,
        "refunds": 0,
        "total": 2000
      },
      "moipAccount": {
        "fullname": "Moip SandBox",
        "login": "[email protected]",
        "id": "MPA-CULBBYHD11"
      },
      "type": "PRIMARY"
    }
  ],
  "_links": {
    "self": {
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-4HY0KOA9Q73F"
    },
    "checkout": {
      "payOnlineBankDebitItau": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/itau/ORD-4HY0KOA9Q73F"
      },
      "payOnlineBankDebitBB": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/bancobrasil/ORD-4HY0KOA9Q73F"
      },
      "payCreditCard": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/creditcard/ORD-4HY0KOA9Q73F"
      },
      "payOnlineBankDebitBradesco": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/bradesco/ORD-4HY0KOA9Q73F"
      },
      "payBoleto": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/boleto/ORD-4HY0KOA9Q73F"
      },
      "payOnlineBankDebitBanrisul": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/banrisul/ORD-4HY0KOA9Q73F"
      }
    }
  }
}

Retrieve orders list [GET]

With this API you can list all orders previously created. The orders are shown from the newest to the oldest. In this version of the API this list only works for order that have at least one payment related. It also possible to use filters.

Endpoint

GET https://sandbox.moip.com.br/v2/orders

Example

A search for payments having amount between 5000 and 10000 (in cents), paid with credit card or boleto and status paid or waiting.
This search also includes the customer's name (in this case Mr. Ken Masters) and will contain 3 objects.

https://sandbox.moip.com.br/v2/orders?q=Ken Masters&filters=status::in(PAID,WAITING)|paymentMethod::in(CREDIT_CARD,BOLETO)|value::bt(5000,10000)&limit=3&offset=0

**IMPORTANT:** Make sure you are using **"[URL Encode](http://en.wikipedia.org/wiki/Percent-encoding)"** to make requests with filters. ### example: - URL com Encode:

GET https://sandbox.moip.com.br/v2/orders?q=jose%20silva&filters%3Dstatus%3A%3Ain(PAID%2CWAITING)%7CpaymentMethod%3A%3Ain(CREDIT_CARD%2CBOLETO)%7Camount%3A%3Abt(5000%2C10000)&limit=3&offset=0)))

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

Response:

200 (OK)
Content-Type: application/json
{
  "_links": {
    "next": {
      "href": "https://sandbox.moip.com.br/v2/orders?q=jose silva&filters=createdAt::bt(2014-11-08,2015-05-07)&limit=3&offset=3"
    },
    "previous": {
      "href": "https://sandbox.moip.com.br/v2/orders?q=jose silva&filters=createdAt::bt(2014-11-08,2015-05-07)&limit=3&offset=0"
    }
  },
  "summary": {
    "count": 497,
    "amount": 1914750
  },
  "orders": [
    {
      "id": "380561",
      "ownId": "sandbox_v2_1430950122",
      "externalId": "ORD-U052MFZ4M414",
      "status": "PAID",
      "blocked": false,
      "amount": {
        "total": 4000,
        "addition": 0,
        "fees": 335,
        "deduction": 0,
        "otherReceivers": 0,
        "currency": "BRL"
      },
      "receivers": [
        {
          "type": "PRIMARY",
          "moipAccount": {
            "id": "MPA-CULBBYHD11"
          }
        }
      ],
      "customer": {
        "fullname": "jose silva",
        "email": "[email protected]"
      },
      "items": [
        {
          "product": null
        }
      ],
      "payments": [
        {
          "installmentCount": 1,
          "fundingInstrument": {
            "method": "CREDIT_CARD",
            "institution": "VISA"
          }
        }
      ],
      "events": [
        {
          "type": "PAYMENT.AUTHORIZED",
          "createdAt": "2015-05-06T19:09:06Z"
        }
      ],
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-U052MFZ4M414"
        }
      },
      "createdAt": "2015-05-06T19:08:43Z",
      "updatedAt": "2015-05-06T19:08:48Z"
    },
    {
      "id": "380560",
      "ownId": "sandbox_v2_1430950121",
      "externalId": "ORD-8MFXXQTTPEJ4",
      "status": "PAID",
      "blocked": false,
      "amount": {
        "total": 4000,
        "addition": 0,
        "fees": 335,
        "deduction": 0,
        "otherReceivers": 0,
        "currency": "BRL"
      },
      "receivers": [
        {
          "type": "PRIMARY",
          "moipAccount": {
            "id": "MPA-CULBBYHD11"
          }
        }
      ],
      "customer": {
        "fullname": "jose silva",
        "email": "[email protected]"
      },
      "items": [
        {
          "product": null
        }
      ],
      "payments": [
        {
          "installmentCount": 1,
          "fundingInstrument": {
            "method": "CREDIT_CARD",
            "institution": "VISA"
          }
        }
      ],
      "events": [
        {
          "type": "PAYMENT.AUTHORIZED",
          "createdAt": "2015-05-06T19:09:06Z"
        }
      ],
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-8MFXXQTTPEJ4"
        }
      },
      "createdAt": "2015-05-06T19:08:41Z",
      "updatedAt": "2015-05-06T19:08:48Z"
    },
    {
      "id": "380456",
      "ownId": "sandbox_v2_1430942777",
      "externalId": "ORD-3XCFS4BTBO38",
      "status": "PAID",
      "blocked": false,
      "amount": {
        "total": 4000,
        "addition": 0,
        "fees": 335,
        "deduction": 0,
        "otherReceivers": 0,
        "currency": "BRL"
      },
      "receivers": [
        {
          "type": "PRIMARY",
          "moipAccount": {
            "id": "MPA-CULBBYHD11"
          }
        }
      ],
      "customer": {
        "fullname": "jose silva",
        "email": "[email protected]"
      },
      "items": [
        {
          "product": null
        }
      ],
      "payments": [
        {
          "installmentCount": 1,
          "fundingInstrument": {
            "method": "CREDIT_CARD",
            "institution": "VISA"
          }
        }
      ],
      "events": [
        {
          "type": "PAYMENT.AUTHORIZED",
          "createdAt": "2015-05-06T17:06:53Z"
        }
      ],
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-3XCFS4BTBO38"
        }
      },
      "createdAt": "2015-05-06T17:06:23Z",
      "updatedAt": "2015-05-06T17:06:42Z"
    }
  ]
}

Parameters:

NameDescriptionType
_
createdAtResource creation date. Available with all delimiters.date, optional
paymentMethodPayment method used in the last payment created for the order. Possible values: DEBIT_CARD, BOLETO, ONLINE_BANK_FINANCING, ONLINE_BANK_DEBIT,WALLET. Use delimiter in.string, optional
valueOrder value. Available with all delimiters.integer, optional
statusOrder status, Possible values: WAITING, NOT_PAID, PAID, REVERTED. Use delimiter in.string, optional
limitQuantity of objects per search (page). Default is 100.integer, optional
offsetThe object where the search started. Default value is 0.integer, optional

Atributes from response:

NameDescriptionTipo
_
summarySummary of resultsstructured
├─countNumber of objects returned.integer(12)
└─amountTotal amount of the objects returned. In cents.integer(12)
ordersList with the minimal representation of orders.Collection of Orders
_linksLinks structure (HATEOAS) of resource.structured

Payments

The payment represents the actual financial transaction happening between Customer and Seller by credit card, payment slip or online bank debit.
This API allows you to create, retrieve and list payments.

Attributes

NameDescriptionType
idPayment IDstring(16), response
statusStatus of a payment. Possible values: CREATED,WAITING, IN_ANALYSIS, PRE_AUTHORIZED,AUTHORIZED, CANCELLED, REFUNDED, REVERSED, SETTLED.string, response
amountOrder amountsstructured, response
├─refundsTotal amount refunded.integer(12)
├─feesMoip fees.integer(12)
├─liquidLiquid amount.integer(12)
├─currencyCurrency. Possible values: BRL.string
└─totalTotal amount charged in cents. Ex: R$10,32 must be informed as 1032integer(12)
installmentCountNumber of installments. Minimum 1 and maximum 12.integer(2)
delayCaptureUsed if you need to pre-capture a payment. Only available for credit cards.boolean
fundingInstrumentsPayment method used.structured
├─methodMethod used. Possible values: CREDIT_CARD, BOLETO, ONLINE_BANK_DEBIT, WALLETstring
├─creditCardCredit card ID. This ID can be used in the future to create new payments. Internal reference.object Credit Card
├─boletoInfo about payment slip.structured object Payment Slip
├─onlineBankDebitInfo about online bank debit payment.object Online Bank Debit
feesPayment fees.structured list, response
├─typeFee type. Possible values: TRANSACTION, PRE_PAYMENT.string
└─amountAmount charged. In cents Ex: R$10,32 must be informed as 1032integer(12)
eventsEvents related to the payment.structured list, response
├─createdAtEvent date.date
├─typeEvent type. Possible values: PAYMENT.WAIING, PAYMENT.AUTHORIZED, PAYMENT.IN_ANALYSIS, PRE_AUTHORIZED, PAYMENT.REFUNDED, PAYMENT.REVERSEDstring
└─descriptionEvent description.string
cancellationDetailsDetails about credit card denial.structured
├─cancelledByThe agent that denied the transactionstring, response
├─codeDenial codenumber, response
└─descriptionA brief description of the denial code.string, response
updatedAtDate when the resource was last updated.datetime, response
createdAtResource creation date.datetime, response
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
├ └─hrefResource URI.link
├─orderOrder reference.structured
├ ├─titleOrder ID.string
├ └─hrefOrder URI.link
└─checkoutLinks to checkout. This link will redirect to the fundingInstrument informed. object Checkout Moipobject Moip Checkout

Create a payment [POST]

With this API is possible to request Moip to charge an order.

Important: Unless you are certified with PCI DSS you must [encrypt](/docs/#criptografia) credit card data before sending it to Moip.

Endpoint

POST https://sandbox.moip.com.br/v2/orders/{order_id}/payments

Example:

Below there is an example of a credit card payment using an encrypted hash.

POST https://sandbox.moip.com.br/v2/orders/ORD-VULX1EWDKXHF/payments

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
  "installmentCount": 1,
  "fundingInstrument": {
    "method": "CREDIT_CARD",
    "creditCard": {
        "hash": "HhL0kbhfid+jwgj5l6Kt9EPdetDxQN8s7uKUHDYxDC/XoULjzik44rSda3EcWuOcL17Eb8JjWc1JI7gsuwg9P0rJv1mJQx+d3Dv1puQYz1iRjEWWhnB1bw0gTvnnC/05KbWN5M8oTiugmhVK02Rt2gpbcTtpS7VWyacfgesBJFavYYMljYg8p2YGHXkXrMuQiOCeemKLk420d0OTMBba27jDVVJ663HZDrObnjFXJH/4B5irkj+HO5genV+V4PYoLcOESG4nrI3oFAsMGsLLcdJo0NNvkEmJpn0e9GzureKKFYisYU+BEd9EMr/odS0VMvOYRV65HbPTspIkjl2+3Q==",
      "holder": {
        "fullname": "Jose Portador da Silva",
        "birthdate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "33333333333"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        }
      }
    }
  }
}
Requestrequire 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = {
    "installmentCount": 1,
    "fundingInstrument": {
        "method": "CREDIT_CARD",
        "creditCard": {
            "expirationMonth": 05,
            "expirationYear": 18,
            "number": "5555666677778884",
            "cvc": "123",
            "holder": {
                "fullname": "Jose Portador da Silva",
                "birthdate": "1988-12-30",
                "taxDocument": {
                    "type": "CPF",
                    "number": "33333333333"
                },
                "phone": {
                    "countryCode": "55",
                    "areaCode": "11",
                    "number": "66778899"
                }
            }
        }
    }
}

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MEVSVkROMzg2V0UzUlpSSTRZWUc2UUNETE1KNTdMQlI6U1JaR0hSWFlPVDBQVkRMUkIzWUU4WFFXTE5MQTBKUlhUS09JRFZEUQ=='
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/orders/id/payments', values, headers
puts response
from urllib2 import Request, urlopen

values = """
{
    "installmentCount": 1,
    "fundingInstrument": {
        "method": "CREDIT_CARD",
        "creditCard": {
            "expirationMonth": 05,
            "expirationYear": 18,
            "number": "5555666677778884",
            "cvc": "123",
            "holder": {
                "fullname": "Jose Portador da Silva",
                "birthdate": "1988-12-30",
                "taxDocument": {
                    "type": "CPF",
                    "number": "33333333333"
                },
                "phone": {
                    "countryCode": "55",
                    "areaCode": "11",
                    "number": "66778899"
                }
            }
        }
    }
}"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MEVSVkROMzg2V0UzUlpSSTRZWUc2UUNETE1KNTdMQlI6U1JaR0hSWFlPVDBQVkRMUkIzWUU4WFFXTE5MQTBKUlhUS09JRFZEUQ=='
}
request = Request('https://sandbox.moip.com.br/v2/orders/id/payments', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

String ccNumber = "5555666677778884";

String cvcNumber = "123";

Order order = moip.orders().get("ORD-VULX1EWDKXHF");

Payment payment = order.payments()
               .setCreditCard("12","15",ccNumber,cvcNumber,
                            moip.customers().setOwnId("sandbox_v2_1401147277")
                                      .setFullname("Jose Portador da Silva")
                                      .setEmail("[email protected]")
                                      .setBirthDate("1988-12-30")
                                      .setTaxDocument("33333333333")
                                      .setPhone("11", "66778899")
                       .execute();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$ccNumber = '5555666677778884';

$cvcNumber = '123'

$order = $moip->orders()->get('ORD-VULX1EWDKXHF');

$payment = $order->payments()
                 ->setCreditCard('05', '18', $ccNumber, $cvcNumber,
                                 $moip->customers()->setOwnId('sandbox_v2_1401147277')
                                                   ->setFullname('Jose Portador da Silva')
                                                   ->setEmail('[email protected]')
                                                   ->setBirthDate('1988-12-30')
                                                   ->setTaxDocument('33333333333')
                                                   ->setPhone(11, 66778899))
                 ->execute();

Response:

201 (Created)
Content-Type: application/json
{
  "id": "PAY-VZ1HI48256ZX",
  "status": "IN_ANALYSIS",
  "amount": {
    "fees": 187,
    "refunds": 0,
    "liquid": 1813,
    "currency": "BRL",
    "total": 2000
  },
  "installmentCount": 1,
  "fundingInstrument": {
    "creditCard": {
      "id": "CRC-V0AAG27AAFG7",
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884",
      "holder": {
        "birthdate": "30/12/1988",
        "taxDocument": {
          "type": "CPF",
          "number": "33333333333"
        },
        "fullname": "Jose Portador da Silva"
      }
    },
    "method": "CREDIT_CARD"
  },
  "fees": [
    {
      "type": "TRANSACTION",
      "amount": 187
    }
  ],
  "events": [
    {
      "createdAt": "2015-01-14T12:17:50-0200",
      "type": "PAYMENT.IN_ANALYSIS"
    },
    {
      "createdAt": "2015-01-14T12:17:48-0200",
      "type": "PAYMENT.CREATED"
    }
  ],
  "_links": {
    "order": {
      "title": "ORD-VULX1EWDKXHF",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-VULX1EWDKXHF"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-VZ1HI48256ZX"
    }
  },
  "updatedAt": "2015-01-14T12:17:50-0200",
  "createdAt": "2015-01-14T12:17:48-0200"
}

Parameters:

NameDescriptionType
_
installmentCountNumber of installments. Minimum 1 and maximum 12.integer(2), optional
delayCaptureUsed if you need to pre-capture a payment. Only available for credit cards.boolean, optional
fundingInstrumentsPayment method.structured
├─methodMethod used. Possible values: CREDIT_CARD, BOLETO, ONLINE_BANK_DEBIT, WALLETstring, required
├─creditCardCredit Card data. It can be the ID of a credit card previously saved, an encrypted credit card hash or the whole collection of credit card attributes (in case you have PCI DSS certificate).structured
├ ├─idCredit card ID. This ID can be used in the future to create new payments. Internal reference.string(16), conditional
├ ├─hashEncrypted credit card datastring, conditional
├ ├─numberCredit Card number. Requires PCI certification.string(19), conditional
├ ├─expirationMonthCredit card expiration month. Requires PCI certification.integer(2), required only when the request has the credit card number
├ ├─expirationYearCredit card expiration year. Requires PCI certification.integer(4), required only when the request has the credit card number
├ ├─cvcCredit card security code.integer, optional
├ ├─holderPortador do cartão.structured, do not send when the request is using credit card id
├ ├─├─fullnameHolder name.string(90), required *
├ ├─├─birthdateHolder birth date.date(AAAA-MM-DD), required *
├ ├─├─phoneCustomer's phone.structured
├ ├─├ ├─countryCodeArea codeinteger(2), optional *
├ ├─├ ├─areaCodeCountry codeinteger(2), optional *
├ ├─└ └─numberPhone number.integer(9), optional *
├ ├─├─taxDocumentDocumentstructured
├ ├─├ ├─typeDocument type. Possible values: CPF for social security number, CNPJ for tax identification number.string(3), required
├ ├─└ └─numberDocument number.string(11), required
├ └─└─billingAddressBilling address.object Address optional *
├─boletoPayment slip attributes.structured
├ ├─expirationDatePayment slip expiration datedate, required
├ ├─instructionLinesPayment slip instructions.structured
├ ├─├─firstPayment slip instructions, line 1string, optional
├ ├─├─secondPayment slip instructions, line 2string, optional
├ ├─└─thirdPayment slip instructions, line 3string, optional
├ └─logoUriReturn URI.link, optional
├─onlineBankDebitOnline bank debit attributes.structured
├ ├─bankNumberBank number. Possible values: 001, 237, 341, 041. List available HEREstring, conditional
├ ├─expirationDateDebit expiration date.date, conditional
└ └─returnUriRedirect URL (not available in the actual version of the APIs)link, conditional

*These fields are required for the Protected Sales Program

Retrieve a payment [GET]

Through this API you can retrieve details about a payment.

Endpoint

GEThttps://sandbox.moip.com.br/v2/payments/{payment_id}

Example:

GET https://sandbox.moip.com.br/v2/payments/PAY-VZ1HI48256ZX

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.get 'https://sandbox.moip.com.br/v2/payments/id', headers
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/payments/id', headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Payment payment = moip.orders().get("ORD-VULX1EWDKXHF").payments().get("PAY-VZ1HI48256ZX");
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$payment = $moip->orders()->get('ORD-VULX1EWDKXHF')->payments()->get('PAY-VZ1HI48256ZX');

Response:

200 (OK)
Content-Type: application/json
 {
  "id": "PAY-VZ1HI48256ZX",
  "status": "IN_ANALYSIS",
  "amount": {
    "fees": 187,
    "refunds": 0,
    "liquid": 1813,
    "currency": "BRL",
    "total": 2000
  },
  "installmentCount": 1,
  "fundingInstrument": {
    "creditCard": {
      "id": "CRC-V0AAG27AAFG7",
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884",
      "holder": {
        "birthdate": "30/12/1988",
        "taxDocument": {
          "type": "CPF",
          "number": "33333333333"
        },
        "fullname": "Jose Portador da Silva"
      }
    },
    "method": "CREDIT_CARD"
  },
  "fees": [
    {
      "type": "TRANSACTION",
      "amount": 187
    }
  ],
  "events": [
    {
      "createdAt": "2015-01-14T12:17:50-0200",
      "type": "PAYMENT.IN_ANALYSIS"
    },
    {
      "createdAt": "2015-01-14T12:17:48-0200",
      "type": "PAYMENT.CREATED"
    }
  ],
  "_links": {
    "order": {
      "title": "ORD-VULX1EWDKXHF",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-VULX1EWDKXHF"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-VZ1HI48256ZX"
    }
  },
  "updatedAt": "2015-01-14T12:17:50-0200",
  "createdAt": "2015-01-14T12:17:48-0200"
}
NameDescriptionType
idPayment ID.string(16), required

Capture a pre-authorized payment [POST]

This API allows you to capture a payment that is pre-authorized (if you are using the delayCapture attribute as true).
If you are using preauthorized payments on multipayments API, you must use the accessToken from your seller to capture a payment.

Endpoint

POST https://sandbox.moip.com.br/v2/payments/{id}/capture

Example:

POST https://sandbox.moip.com.br/v2/payments/PAY-ZJOE0VPNGIM5/capture

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{}
# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

200 (OK)
Content-Type: application/json
{
  "id": "PAY-ZJOE0VPNGIM5",
  "status": "AUTHORIZED",
  "amount": {
    "refunds": 0,
    "fees": 187,
    "liquid": 1813,
    "currency": "BRL",
    "total": 2000
  },
  "installmentCount": 1,
  "fundingInstrument": {
    "creditCard": {
      "id": "CRC-8XPB5E78J3C5",
      "brand": "VISA",
      "first6": "401200",
      "last4": "3335",
      "holder": {
        "birthdate": "30/12/1988",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "fullname": "Jose Portador da Silva"
      }
    },
    "method": "CREDIT_CARD"
  },
  "fees": [
    {
      "type": "TRANSACTION",
      "amount": 187
    }
  ],
  "events": [
    {
      "createdAt": "2015-03-30T09:51:58-0300",
      "type": "PAYMENT.AUTHORIZED"
    },
    {
      "createdAt": "2015-03-30T09:51:41-0300",
      "type": "PAYMENT.IN_ANALYSIS"
    },
    {
      "createdAt": "2015-03-30T09:51:41-0300",
      "type": "PAYMENT.PRE_AUTHORIZED"
    },
    {
      "createdAt": "2015-03-30T09:51:38-0300",
      "type": "PAYMENT.CREATED"
    }
  ],
  "_links": {
    "order": {
      "title": "ORD-Y3HRHLCNQ4VO",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-Y3HRHLCNQ4VO"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-ZJOE0VPNGIM5"
    }
  },
  "createdAt": "2015-03-30T09:51:38-0300",
  "updatedAt": "2015-03-30T09:51:58-0300"
}

Cancel a pre-authorized payment [POST]

This API allows you to cancel the capture of a preauthorized payment.

Endpoint

POST https://sandbox.moip.com.br/v2/payments/{id}/void

Example:

POST https://sandbox.moip.com.br/v2/payments/PAY-ZJOE0VPNGIM5/void

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{}
# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

200 (OK)
Content-Type: application/json
{
  "id": "PAY-ZJOE0VPNGIM5",
  "status": "CANCELLED",
  "amount": {
    "refunds": 0,
    "fees": 187,
    "liquid": 1813,
    "currency": "BRL",
    "total": 2000
  },
  "installmentCount": 1,
  "fundingInstrument": {
    "creditCard": {
      "id": "CRC-8XPB5E78J3C5",
      "brand": "VISA",
      "first6": "401200",
      "last4": "3335",
      "holder": {
        "birthdate": "30/12/1988",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "fullname": "Jose Portador da Silva"
      }
    },
    "method": "CREDIT_CARD"
  },
  "fees": [
    {
      "type": "TRANSACTION",
      "amount": 187
    }
  ],
  "events": [
    {
      "createdAt": "2015-03-30T09:51:58-0300",
      "type": "PAYMENT.CANCELLED"
    },
    {
      "createdAt": "2015-03-30T09:51:41-0300",
      "type": "PAYMENT.PRE_AUTHORIZED"
    },
    {
      "createdAt": "2015-03-30T09:51:41-0300",
      "type": "PAYMENT.IN_ANALYSIS"
    },
    {
      "createdAt": "2015-03-30T09:51:38-0300",
      "type": "PAYMENT.CREATED"
    }
  ],
  "_links": {
    "order": {
      "title": "ORD-Y3HRHLCNQ4VO",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-Y3HRHLCNQ4VO"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-ZJOE0VPNGIM5"
    }
  },
  "createdAt": "2015-03-30T09:51:38-0300",
  "updatedAt": "2015-03-30T09:51:58-0300"
}

Refunds

This API allows you to refund a payment. This same process is also available on orders.

It is possible to refund payments and order totally or partially. In case the attribute amount is not specified than the API will consider as a total refund.
When refunding a credit card payment, the amount refunded will be credited in the credit card automatically. For payment slips and online bank debit a refund can be made through on a Moip account or a Bank account.

Attributes:

NameDescriptionType
idRefund IDstring(16), response
statusRefund status. Possible values: REQUESTED, COMPLETED, FAILED.string, response
amountAmount to be refunded. Ex: R$10,32 must be informed as 1032structured
├─feesRefund fees.integer(12), response
├─currencyCurrency.string, response
└─totalTotal amount refunded. Ex: R$10,32 must be informed as 1032integer(12), response
typeRefund type. Possible values: FULL, PARTIAL.string, response
refundingInstrumentRefunding instrument used.structured
├─methodMethod to refund a payment. Possible values: BANK_ACCOUNT, MOIP_ACCOUNT and CREDIT_CARDstring
├─creditCardCredit card refunded.Object Credit Card
├─moipAccountMoip account that will receive the refund.Object Moip account
└─bankAccountBank account that will receive the refund.Object Bank account
eventsRefund events.structured
├─createdAtRefund event creation date.integer(12), response
├─typeRefund event type. Possible values: REFUND.REQUESTED, REFUND.WAITING, REFUND.FAILED, REFUND.COMPLETED.string, response
createdAtResource creation date.datetime, response
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
├ └─hrefResource URI.link
├─orderOrder reference.structured
├ ├─titleOrder ID.string
├ └─hrefOrder URI.link
├─paymentPayment reference.structured
├ ├─titlePayment ID.string
└ └─hrefPayment URI.link

Refund a payment [POST]

It is possible to refund payments and order totally or partially. In case the attribute amount is not specified than the API will consider as a total refund.
When refunding a credit card payment, the amount refunded will be credited in the credit card automatically. For payment slips and online bank debit a refund can be made through on a Moip account or a Bank account.

A payment can be refunded only by the its primary receiver.

Endpoint

POST https://sandbox.moip.com.br/v2/payments/{payment_id}/refunds

Example of a full refund to a credit card.

POST https://sandbox.moip.com.br/v2/payments/PAY-X2VXEGV7WVFB/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{}
# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

201 (Created)
Content-Type: application/json

{
  "id": "REF-BP8AAGSG7OTY",
  "status": "COMPLETED",
  "events": [
    {
      "createdAt": "2015-02-26T19:14:25-0300",
      "type": "REFUND.COMPLETED"
    },
    {
      "createdAt": "2015-02-26T19:14:23-0300",
      "type": "REFUND.REQUESTED"
    }
  ],
  "amount": {
    "fees": 0,
    "currency": "BRL",
    "total": 2000
  },
  "type": "FULL",
  "refundingInstrument": {
    "creditCard": {
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884"
    },
    "method": "CREDIT_CARD"
  },
  "createdAt": "2015-02-26T19:14:23-0300",
  "_links": {
    "payment": {
      "title": "PAY-X2VXEGV7WVFB",
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-X2VXEGV7WVFB"
    },
    "order": {
      "title": "ORD-44GC0PFGU42M",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-44GC0PFGU42M"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/refunds/REF-BP8AAGSG7OTY"
    }
  }
}

Example of a partial refund to a credit card.

POST https://sandbox.moip.com.br/v2/payments/PAY-3N7TSKQ26L2I/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
    "amount": 1000   
}

# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

201 (Created)
Content-Type: application/json

{
  "id": "REF-I7IEV1RG9T1L",
  "status": "COMPLETED",
  "events": [
    {
      "createdAt": "2015-02-27T11:28:11-0300",
      "type": "REFUND.COMPLETED"
    },
    {
      "createdAt": "2015-02-27T11:28:10-0300",
      "type": "REFUND.REQUESTED"
    }
  ],
  "amount": {
    "fees": 0,
    "currency": "BRL",
    "total": 1000
  },
  "type": "PARTIAL",
  "refundingInstrument": {
    "creditCard": {
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884"
    },
    "method": "CREDIT_CARD"
  },
  "createdAt": "2015-02-27T11:28:10-0300",
  "_links": {
    "payment": {
      "title": "PAY-3N7TSKQ26L2I",
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-3N7TSKQ26L2I"
    },
    "order": {
      "title": "ORD-1RQDM20CQW8T",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-1RQDM20CQW8T"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/refunds/REF-I7IEV1RG9T1L"
    }
  }
}

Parameters:

NameDescriptionType
_
amountAmount to be refunded. Ex: R$10,32 must be informed as 1032structured, optional
refundingInstrumentRefunding instrument used.structured
├─methodMethod to refund a payment. Possible values: BANK_ACCOUNT, MOIP_ACCOUNT and CREDIT_CARD.string, conditional
├─BANK_ACCOUNTBank account that will receive the refund.Bank account, conditional
└─MOIP_ACCOUNTMoip account that will receive the refund.e-Wallet, condicional

Refund an order [POST]


It is possible to refund payments and order totally or partially. In case the attribute amount is not specified than the API will consider as a total refund.
When refunding a credit card payment, the amount refunded will be credited in the credit card automatically. For payment slips and online bank debit a refund can be made through on a Moip account or a Bank account.

An order can be refunded only by the its primary receiver.

Endpoint

POST https://sandbox.moip.com.br/v2/orders/{order_id}/refunds

Example of a full refund to a credit card.

POST https://sandbox.moip.com.br/v2/orders/ORD-44GC0PFGU42M/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = '{}
'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/orders/id/refunds', values, headers
puts response
from urllib2 import Request, urlopen

values = """
  {}

"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/orders/id/refunds', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Refund refund = moip.orders().get("ORD-OBXYNHIXBNSO").refund().creditCardFull().execute();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$refund = $moip->orders()->get('ORD-VULX1EWDKXHF')->refunds()->creditCardFull();

Response:

201 (Created)
Content-Type: application/json

{
  "id": "REF-BP8AAGSG7OTY",
  "status": "COMPLETED",
  "events": [
    {
      "createdAt": "2015-02-26T19:14:25-0300",
      "type": "REFUND.COMPLETED"
    },
    {
      "createdAt": "2015-02-26T19:14:23-0300",
      "type": "REFUND.REQUESTED"
    }
  ],
  "amount": {
    "fees": 0,
    "currency": "BRL",
    "total": 2000
  },
  "type": "FULL",
  "refundingInstrument": {
    "creditCard": {
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884"
    },
    "method": "CREDIT_CARD"
  },
  "createdAt": "2015-02-26T19:14:23-0300",
  "_links": {
    "payment": {
      "title": "PAY-X2VXEGV7WVFB",
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-X2VXEGV7WVFB"
    },
    "order": {
      "title": "ORD-44GC0PFGU42M",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-44GC0PFGU42M"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/refunds/REF-BP8AAGSG7OTY"
    }
  }
}

Example of a partial refund to a credit card.

POST https://sandbox.moip.com.br/v2/orders/ORD-PCVWZGGH3BPM/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
    "amount": 1000   
}

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = '{
    "amount": 1000   
}
'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/orders/id/refunds', values, headers
puts response
from urllib2 import Request, urlopen

values = """
  {
    "amount": 1000   
}

"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/orders/id/refunds', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Refund refund = moip.orders().get("ORD-OBXYNHIXBNSO").refund().creditCardPartial(1000).execute();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$refund = $moip->orders()->get('ORD-VULX1EWDKXHF')->refunds()->creditCardPartial('1000');

Response:

201 (Created)
Content-Type: application/json

{
  "id": "REF-I7IEV1RG9T1L",
  "status": "COMPLETED",
  "events": [
    {
      "createdAt": "2015-02-27T11:28:11-0300",
      "type": "REFUND.COMPLETED"
    },
    {
      "createdAt": "2015-02-27T11:28:10-0300",
      "type": "REFUND.REQUESTED"
    }
  ],
  "amount": {
    "fees": 0,
    "currency": "BRL",
    "total": 1000
  },
  "type": "PARTIAL",
  "refundingInstrument": {
    "creditCard": {
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884"
    },
    "method": "CREDIT_CARD"
  },
  "createdAt": "2015-02-27T11:28:10-0300",
  "_links": {
    "payment": {
      "title": "PAY-3N7TSKQ26L2I",
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-3N7TSKQ26L2I"
    },
    "order": {
      "title": "ORD-1RQDM20CQW8T",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-1RQDM20CQW8T"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/refunds/REF-I7IEV1RG9T1L"
    }
  }
}

Example of a full refund to a Bank account.

POST https://sandbox.moip.com.br/v2/orders/ORD-C8LDLESE7Z2A/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{
  "refundingInstrument": {
    "method": "BANK_ACCOUNT",
    "bankAccount": {
      "type": "CHECKING",
      "bankNumber": "001",
      "agencyNumber": 4444444,
      "agencyCheckNumber": 2,
      "accountNumber": 1234,
      "accountCheckNumber": 1,
      "holder": {
        "fullname": "Nome do Portador",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        }
      }
    }
  }
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = '{
  "refundingInstrument": {
    "method": "BANK_ACCOUNT",
    "bankAccount": {
      "type": "CHECKING",
      "bankNumber": "001",
      "agencyNumber": 4444444,
      "agencyCheckNumber": 2,
      "accountNumber": 1234,
      "accountCheckNumber": 1,
      "holder": {
        "fullname": "Nome do Portador",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        }
      }
    }
  }
}
'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/orders/id/refunds', values, headers
puts response
from urllib2 import Request, urlopen

values = """
  {
  "refundingInstrument": {
    "method": "BANK_ACCOUNT",
    "bankAccount": {
      "type": "CHECKING",
      "bankNumber": "001",
      "agencyNumber": 4444444,
      "agencyCheckNumber": 2,
      "accountNumber": 1234,
      "accountCheckNumber": 1,
      "holder": {
        "fullname": "Nome do Portador",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        }
      }
    }
  }
}

"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/orders/id/refunds', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Customer customer = moip.customers().setOwnId("sandbox_v2_1401147277")
                            .setFullname("Nome do Portador")
                            .setTaxDocument("33333333333");

Refund refund = moip.orders().get("ORD-VULX1EWDKXHF").refund().bankAccountFull("CHECKING", "001",
                                                                               "4444444", "2",
                                                                               "1234", "1",
                                                                               customer);
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$customer = $moip->customers()->setOwnId('sandbox_v2_1401147277')
                              ->setFullname('Nome do Portador')
                              ->setTaxDocument('33333333333');

$refund = $moip->orders()->get('ORD-VULX1EWDKXHF')->refunds()->bankAccountFull('CHECKING',
                                                                               '001',
                                                                               '4444444',
                                                                               '2',
                                                                               '1234',
                                                                               '1',
                                                                                $customer);

Response:

200 (Created)
Content-Type: application/json
{
  "id": "REF-Q62KXZ2R69SW",
  "status": "REQUESTED",
  "events": [
    {
      "createdAt": "2015-02-27T11:35:04-0300",
      "type": "REFUND.REQUESTED"
    }
  ],
  "amount": {
    "fees": 0,
    "currency": "BRL",
    "total": 2000
  },
  "type": "FULL",
  "refundingInstrument": {
    "bankAccount": {
      "bankNumber": "001",
      "bankName": "BANCO DO BRASIL S.A.",
      "agencyNumber": "44444",
      "agencyCheckNumber": "2",
      "accountNumber": "1234",
      "accountCheckNumber": "1",
      "type": "CHECKING",
      "holder": {
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "fullname": "Jose Silva"
      }
    },
    "method": "BANK_ACCOUNT"
  },
  "createdAt": "2015-02-27T11:35:04-0300",
  "_links": {
    "payment": {
      "title": "PAY-T9DSISNJZ9LP",
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-T9DSISNJZ9LP"
    },
    "order": {
      "title": "ORD-724JCGAOIVHZ",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-724JCGAOIVHZ"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/refunds/REF-Q62KXZ2R69SW"
    }
  }
}

Parameters:

NameDescriptionType
_
amountAmount to be refunded. Ex: R$10,32 must be informed as 1032structured, optional
refundingInstrumentRefunding instrument used.structured
├─methodMethod to refund a payment. Possible values: BANK_ACCOUNT, MOIP_ACCOUNT and CREDIT_CARD.string, conditional
├─BANK_ACCOUNTBank account that will receive the refund.Bank account, conditional
└─MOIP_ACCOUNTMoip account that will receive the refund.e-Wallet, condicional

Retrieve a refund [GET]

Through this API you can retrieve details about a refund.

Endpoint

GEThttps://sandbox.moip.com.br/v2/refunds/{refund_id}

Example:

GET https://sandbox.moip.com.br/v2/refunds/REF-BO0ABQCGVZVD

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.get 'https://sandbox.moip.com.br/v2/refunds/id', headers
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/v2/refunds/id', headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String token = "01010101010101010101010101010101";
String key = "ABABABABABABABABABABABABABABABABABABABAB";

Moip moip = new Moip(new MoipBasicAuth(token, key), endpoint);

Refund refund = moip.orders().get("'ORD-VULX1EWDKXHF").refund().get("REF-BO0ABQCGVZVD");
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$token = '01010101010101010101010101010101';
$key = 'ABABABABABABABABABABABABABABABABABABABAB';

$moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

$refund = $moip->orders()->get('ORD-VULX1EWDKXHF')->refunds()->get('REF-BO0ABQCGVZVD');

Response:

200 (OK)
Content-Type: application/json
 {
  "id": "REF-BO0ABQCGVZVD",
  "status": "COMPLETED",
  "amount": {
    "fees": 0,
    "currency": "BRL",
    "total": 1000
  },
  "type": "PARTIAL",
  "refundingInstrument": {
    "creditCard": {
      "brand": "MASTERCARD",
      "first6": "555566",
      "last4": "8884"
    },
    "method": "CREDIT_CARD"
  },
  "createdAt": "2015-01-13T18:13:06-0200",
  "_links": {
    "payment": {
      "title": "PAY-6N4P8COQU6OS",
      "href": "https://sandbox.moip.com.br/v2/payments/PAY-6N4P8COQU6OS"
    },
    "order": {
      "title": "ORD-F78K9QTS1UN6",
      "href": "https://sandbox.moip.com.br/v2/orders/ORD-F78K9QTS1UN6"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/refunds/REF-BO0ABQCGVZVD"
    }
  }
}

Parameters:

NameDescriptionType
idRefund ID.string(16), required

Retrieve a refunds list [GET]

This APIs allows you to retrieve all refunds related to a given payment.

Endpoint

GET https://sandbox.moip.com.br/v2/payments/{payment_id}/refunds

Example:

GET https://sandbox.moip.com.br/v2/payments/PAY-3N7TSKQ26L2I/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{}
# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

200 (Ok)
Content-Type: application/json
{
  "refunds": [
    {
      "id": "REF-J4DZBVSRSRMU",
      "status": "COMPLETED",
      "type": "FULL",
      "amount": {
        "fees": 0,
        "currency": "BRL",
        "total": 10000
      },
      "refundingInstrument": {
        "method": "CREDIT_CARD",
        "creditCard": {
          "brand": "VISA",
          "first6": "401200",
          "last4": "3335"
        }
      },
      "events": [
        {
          "createdAt": "2015-12-05T18:57:17-0200",
          "type": "REFUND.COMPLETED"
        },
        {
          "createdAt": "2015-12-05T18:57:15-0200",
          "type": "REFUND.REQUESTED"
        }
      ],
      "_links": {
        "payment": {
          "title": "PAY-3N7TSKQ26L2I",
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-3N7TSKQ26L2I"
        },
        "order": {
          "title": "ORD-1RQDM20CQW8T",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-1RQDM20CQW8T"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/refunds/REF-I7IEV1RG9T1L"
        }
      },
      "createdAt": "2015-12-05T18:57:15-0200"
    }
  ]
}

Parameters:

NameDescriptionType
_
idPayment ID.string(16), required

Retrieve all refunds from an order [GET]

This APIs allows you to retrieve all refunds related to a given order.

Endpoint

GET https://sandbox.moip.com.br/v2/orders/{orders_id}/refunds

Example:

GET https://sandbox.moip.com.br/v2/orders/ORD-1RQDM20CQW8T/refunds

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="

{}
# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

200 (Ok)
Content-Type: application/json
{
  "refunds": [
    {
      "id": "REF-J4DZBVSRSRMU",
      "status": "COMPLETED",
      "type": "FULL",
      "amount": {
        "fees": 0,
        "currency": "BRL",
        "total": 10000
      },
      "refundingInstrument": {
        "method": "CREDIT_CARD",
        "creditCard": {
          "brand": "VISA",
          "first6": "401200",
          "last4": "3335"
        }
      },
      "events": [
        {
          "createdAt": "2015-12-05T18:57:17-0200",
          "type": "REFUND.COMPLETED"
        },
        {
          "createdAt": "2015-12-05T18:57:15-0200",
          "type": "REFUND.REQUESTED"
        }
      ],
      "_links": {
        "payment": {
          "title": "PAY-3N7TSKQ26L2I",
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-3N7TSKQ26L2I"
        },
        "order": {
          "title": "ORD-1RQDM20CQW8T",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-1RQDM20CQW8T"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/refunds/REF-J4DZBVSRSRMU"
        }
      },
      "createdAt": "2015-12-05T18:57:15-0200"
    }
  ]
}

Parameters:

NameDescriptionType
_
idOrder ID.string(16), required

Multiorders

A multiorder is a collection of orders used to create transactions involving more than one seller in the same cart.
When you charge a multiorder, Moip creates one payment for each order involved.

IMPORTANT: Refunding a multiorder is not possible, however the order can be refunded individually. To do so you can use the refunds API.
IMPORTANT: Multiorder requires the use of OAuth permissions. To do so, use Moip Connect.

Attributes:

NameDescriptionDetails
_
idMultiorder ID.string(16), response
ownIdMultiorder ownId . External reference.string(65)
statusMultiorder status. Possible values: WAITING, PAID, NOT_PAID, REVERTED.string(65), response
amountAmounts.structured, response
├─currencyCurrency. Possible values: BRL.string
└─totalTotal amount charged in cents. Ex: R$10,32 must be informed as 1032.integer(12)
ordersOrderscollection of Orders
createdAtResource creation date.datetime, response
updatedAtMultiorder last update.datetime, response
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
├ └─hrefResource URI.link
└─checkoutLinks to checkout. This link will redirect to the fundingInstrument informed. object Checkout Moipobject Moip Checkout

Create a multiorder [POST]

With this API is possible to create collections of orders and a shared cart.

Endpoint

POST https://sandbox.moip.com.br/v2/multiorders

Request:

Content-Type: application/json
Authorization: "OAuth qguusgp05mxaa9adyy8kvo4nuq380z7"
{
  "ownId": "meu_multiorder_id",
  "orders": [
    {
      "ownId": "pedido_1_id",
      "amount": {
        "currency": "BRL",
        "subtotals": {
          "shipping": 2000
        }
      },
      "items": [
        {
          "product": "Camisa Verde e Amarelo - Brasil",
          "quantity": 1,
          "detail": "Seleção Brasileira",
          "price": 2000
        }
      ],
      "customer": {
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "email": "[email protected]",
        "birthDate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "shippingAddress": 
          {
            "street": "Avenida Faria Lima",
            "streetNumber": 2927,
            "complement": 8,
            "district": "Itaim",
            "city": "Sao Paulo",
            "state": "SP",
            "country": "BRA",
            "zipCode": "01234000"
          }
      },
      "receivers": [
        {
          "moipAccount": {
            "id": "MPA-VB5OGTVPCI52"
          },
          "type": "PRIMARY"
        }
      ]
    },
    {
      "ownId": "pedido_2_id",
      "amount": {
        "currency": "BRL",
        "subtotals": {
          "shipping": 3000
        }
      },
      "items": [
        {
          "product": "Camisa Preta - Alemanha",
          "quantity": 1,
          "detail": "Camiseta da Copa 2014",
          "price": 1000
        }
      ],
      "customer": {
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "email": "[email protected]",
        "birthDate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "shippingAddress": 
          {
            "street": "Avenida Faria Lima",
            "streetNumber": 2927,
            "complement": 8,
            "district": "Itaim",
            "city": "Sao Paulo",
            "state": "SP",
            "country": "BRA",
            "zipCode": "01234000"
          }
      },
      "receivers": [
        {
          "moipAccount": {
            "id": "MPA-IFYRB1HBL73Z"
          },
          "type": "PRIMARY"
        },
        {
          "moipAccount": {
            "id": "MPA-KQB1QFWS6QNM"
          },
          "type": "SECONDARY",
          "amount": {
            "fixed": 55
          }
        }
      ]
    }
  ]
}

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = '{
  "ownId": "meu_multiorder_id",
  "orders": [
    {
      "ownId": "pedido_1_id",
      "amount": {
        "currency": "BRL",
        "subtotals": {
          "shipping": 2000
        }
      },
      "items": [
        {
          "product": "Camisa Verde e Amarelo - Brasil",
          "quantity": 1,
          "detail": "Seleção Brasileira",
          "price": 2000
        }
      ],
      "customer": {
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "email": "[email protected]",
        "birthDate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "shippingAddress": {
          "type": "BILLING",
          "street": "Avenida Faria Lima",
          "streetNumber": 2927,
          "complement": 8,
          "district": "Itaim",
          "city": "Sao Paulo",
          "state": "SP",
          "country": "BRA",
          "zipCode": "01234000"
        }
      },
      "receivers": [
        {
          "moipAccount": {
            "id": "MPA-VB5OGTVPCI52"
          },
          "type": "PRIMARY"
        }
      ]
    },
    {
      "ownId": "pedido_2_id",
      "amount": {
        "currency": "BRL",
        "subtotals": {
          "shipping": 2000
        }
      },
      "items": [
        {
          "product": "Camisa Verde e Amarelo - Brasil",
          "quantity": 1,
          "detail": "Seleção Brasileira",
          "price": 2000
        }
      ],
      "customer": {
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "email": "[email protected]",
        "birthDate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "shippingAddress": {
          "type": "BILLING",
          "street": "Avenida Faria Lima",
          "streetNumber": 2927,
          "complement": 8,
          "district": "Itaim",
          "city": "Sao Paulo",
          "state": "SP",
          "country": "BRA",
          "zipCode": "01234000"
        }
      },
      "receivers": [
        {
          "moipAccount": {
            "id": "MPA-IFYRB1HBL73Z"
          },
          "type": "PRIMARY"
        },
        {
          "moipAccount": {
            "id": "MPA-KQB1QFWS6QNM"
          },
          "type": "SECONDARY",
          "amount": {
            "fixed": 55
          }
        }
      ]
    }
  ]
}'

headers = {
  :content_type => application/json,
  :authorization => "OAuth qguusgp05mxaa9adyy8kvo4nuq380z7"
}

response = RestClient.post 'https://sandbox.moip.com.br/v2/multiorders', values, headers
puts response
from urllib2 import Request, urlopen

values = """
  {
  "ownId": "meu_multiorder_id",
  "orders": [
    {
      "ownId": "pedido_1_id",
      "amount": {
        "currency": "BRL",
        "subtotals": {
          "shipping": 2000
        }
      },
      "items": [
        {
          "product": "Camisa Verde e Amarelo - Brasil",
          "quantity": 1,
          "detail": "Seleção Brasileira",
          "price": 2000
        }
      ],
      "customer": {
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "email": "[email protected]",
        "birthDate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "shippingAddress": 
          {
            "street": "Avenida Faria Lima",
            "streetNumber": 2927,
            "complement": 8,
            "district": "Itaim",
            "city": "Sao Paulo",
            "state": "SP",
            "country": "BRA",
            "zipCode": "01234000"
          }
      },
      "receivers": [
        {
          "moipAccount": {
            "id": "MPA-VB5OGTVPCI52"
          },
          "type": "PRIMARY"
        }
      ]
    },
    {
      "ownId": "pedido_2_id",
      "amount": {
        "currency": "BRL",
        "subtotals": {
          "shipping": 3000
        }
      },
      "items": [
        {
          "product": "Camisa Preta - Alemanha",
          "quantity": 1,
          "detail": "Camiseta da Copa 2014",
          "price": 1000
        }
      ],
      "customer": {
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "email": "[email protected]",
        "birthDate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "shippingAddress": 
          {
            "street": "Avenida Faria Lima",
            "streetNumber": 2927,
            "complement": 8,
            "district": "Itaim",
            "city": "Sao Paulo",
            "state": "SP",
            "country": "BRA",
            "zipCode": "01234000"
          }
      },
      "receivers": [
        {
          "moipAccount": {
            "id": "MPA-VB5OGTVPCI52"
          },
          "type": "PRIMARY"
        },
        {
          "moipAccount": {
            "id": "MPA-KQB1QFWS6QNM"
          },
          "type": "SECONDARY",
          "amount": {
            "fixed": 55
          }
        }
      ]
    }
  ]
}
"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}
request = Request('https://sandbox.moip.com.br/v2/multiorders', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
# Por enquanto não disponível no SDK JAVA, veja nosso exemplo em JSON.
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$accessToken = 'qguusgp05mxaa9adyy8kvo4nuq380z7';

$moip = new Moip(new MoipOAuth($accessToken), $endpoint);

$customer = $moip->customers()->setOwnId('sandbox_v2_1401147277')
                              ->setFullname('Jose Silva')
                              ->setEmail('[email protected]')
                              ->setBirthDate('1988-12-30')
                              ->setTaxDocument('33333333333')
                              ->setPhone(11, 66778899)
                              ->addAddress('SHIPPING',
                                           'Avenida Faria Lima', 2927,
                                           'Itaim', 'Sao Paulo', 'SP',
                                           '01234000', 8);

$order1 = $moip->orders()->setOwnId('multi-pedido-1')
                        ->addItem('Camisa Verde e Amarelo - Brasil', 1, 'Seleção Brasileira', 10000)
                        ->setShippingAmount(100)
                        ->setCustomer($customer)
                        ->addReceiver('MPA-VB5OGTVPCI52');

$order2 = $moip->orders()->setOwnId('multi-pedido-2')
                        ->addItem('Camisa Preta - Alemanha', 1, 'Camisa da Copa 2014', 10000)
                        ->setShippingAmount(100)
                        ->setCustomer($customer)
                        ->addReceiver('MPA-IFYRB1HBL73Z');

$multiorder = $moip->multiorders()->addOrder($order1)
                                  ->addOrder($order2)
                                  ->setOwnId('multi-pedido')
                                  ->create();

Response:

201 (Created)
Content-Type: application/json
{
  "id": "MOR-9241K3EFW5DV",
  "ownId": "meu_multiorder_id",
  "status": "CREATED",
  "createdAt": "2015-02-27T11:39:02-0300",
  "updatedAt": "",
  "amount": {
    "currency": "BRL",
    "total": 8000
  },
  "orders": [
    {
      "id": "ORD-4LFGB72U2OK1",
      "ownId": "pedido_1_id",
      "status": "CREATED",
      "createdAt": "2015-02-27T11:39:02-0300",
      "amount": {
        "total": 4000,
        "fees": 0,
        "refunds": 0,
        "liquid": 0,
        "otherReceivers": 4000,
        "currency": "BRL",
        "subtotals": {
          "shipping": 2000,
          "addition": 0,
          "discount": 0,
          "items": 2000
        }
      },
      "items": [
        {
          "product": "Camisa Verde e Amarelo - Brasil",
          "price": 2000,
          "detail": "Seleção Brasileira",
          "quantity": 1
        }
      ],
      "customer": {
        "id": "CUS-IRDAWA6Q260J",
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "createdAt": "2015-02-27T11:39:02-0300",
        "birthDate": "1988-12-30T00:00:00-0200",
        "email": "[email protected]",
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "shippingAddress": {
          "zipCode": "01234000",
          "street": "Avenida Faria Lima",
          "streetNumber": "2927",
          "complement": "8",
          "city": "Sao Paulo",
          "district": "Itaim",
          "state": "SP",
          "country": "BRA"
        },
        "_links": {
          "self": {
            "href": "https://sandbox.moip.com.br/v2/customers/CUS-IRDAWA6Q260J"
          }
        }
      },
      "payments": [],
      "refunds": [],
      "entries": [],
      "events": [
        {
          "createdAt": "2015-02-27T11:39:02-0300",
          "description": "",
          "type": "ORDER.CREATED"
        }
      ],
      "receivers": [
        {
          "amount": {
            "fees": 0,
            "refunds": 0,
            "total": 4000
          },
          "moipAccount": {
            "fullname": "Lojista 4 Moip",
            "login": "[email protected]",
            "id": "MPA-VB5OGTVPCI52"
          },
          "type": "PRIMARY"
        }
      ],
      "shippingAddress": {
        "zipCode": "01234000",
        "street": "Avenida Faria Lima",
        "streetNumber": "2927",
        "complement": "8",
        "city": "Sao Paulo",
        "district": "Itaim",
        "state": "SP",
        "country": "BRA"
      },
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-4LFGB72U2OK1"
        }
      }
    },
    {
      "id": "ORD-29P0JCAJY8ZU",
      "ownId": "pedido_2_id",
      "status": "CREATED",
      "createdAt": "2015-02-27T11:39:02-0300",
      "amount": {
        "total": 4000,
        "fees": 0,
        "refunds": 0,
        "liquid": 0,
        "otherReceivers": 4000,
        "currency": "BRL",
        "subtotals": {
          "shipping": 3000,
          "addition": 0,
          "discount": 0,
          "items": 1000
        }
      },
      "items": [
        {
          "product": "Camisa Preta - Alemanha",
          "price": 1000,
          "detail": "Camiseta da Copa 2014",
          "quantity": 1
        }
      ],
      "customer": {
        "id": "CUS-RE6XARTZD2K7",
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "createdAt": "2015-02-27T11:39:02-0300",
        "birthDate": "1988-12-30T00:00:00-0200",
        "email": "[email protected]",
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "shippingAddress": {
          "zipCode": "01234000",
          "street": "Avenida Faria Lima",
          "streetNumber": "2927",
          "complement": "8",
          "city": "Sao Paulo",
          "district": "Itaim",
          "state": "SP",
          "country": "BRA"
        },
        "_links": {
          "self": {
            "href": "https://sandbox.moip.com.br/v2/customers/CUS-RE6XARTZD2K7"
          }
        }
      },
      "payments": [],
      "refunds": [],
      "entries": [],
      "events": [
        {
          "createdAt": "2015-02-27T11:39:02-0300",
          "description": "",
          "type": "ORDER.CREATED"
        }
      ],
      "receivers": [
        {
          "amount": {
            "fees": 0,
            "refunds": 0,
            "total": 3945
          },
          "moipAccount": {
            "fullname": "Lojista 3 Moip",
            "login": "[email protected]",
            "id": "MPA-IFYRB1HBL73Z"
          },
          "type": "PRIMARY"
        },
        {
          "amount": {
            "refunds": 0,
            "total": 55
          },
          "moipAccount": {
            "fullname": "Maria da Silva Santos",
            "login": "[email protected]",
            "id": "MPA-KQB1QFWS6QNM"
          },
          "type": "SECONDARY"
        }
      ],
      "shippingAddress": {
        "zipCode": "01234000",
        "street": "Avenida Faria Lima",
        "streetNumber": "2927",
        "complement": "8",
        "city": "Sao Paulo",
        "district": "Itaim",
        "state": "SP",
        "country": "BRA"
      },
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-29P0JCAJY8ZU"
        }
      }
    }
  ],
  "_links": {
    "self": {
      "href": "https://sandbox.moip.com.br/v2/orders/MOR-9241K3EFW5DV"
    },
    "checkout": {
      "payOnlineBankDebitItau": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/itau/MOR-9241K3EFW5DV"
      },
      "payCreditCard": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/creditcard/MOR-9241K3EFW5DV"
      }
    }
  }
}

Parameters:

NameDescriptionDetails
_
ownIdMultiorder ID. External reference.string(65), required
ordersOrders. The attribute receiver of each order must be filled indicating who is the primary receiver.collection of Orders, required

Retrieve a multiorder [GET]

This API can be used to retrieve a multiorder.

Endpoint

GEThttps://sandbox.moip.com.br/v2/multiorders/{multiorder_id}

Example:

GET https://sandbox.moip.com.br/v2/multiorders/MOR-9241K3EFW5DV

Request:

Content-Type: application/json
Authorization: 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

headers = {
  :content_type => 'application/json',
  :authorization => 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}

response = RestClient.get 'https://sandbox.moip.com.br/v2/multiorders/id', headers
puts response
String endpoint = "sandbox.moip.com.br";
String accessToken = "m9mq5lni241ngslgpl910ew45bxnnez";

Moip moip = new Moip(new MoipOAuth(accessToken), endpoint);

Multiorder multiorder = moip.multiorders().get("MOR-P4JBIAG5L5KM");
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$accessToken = 'qguusgp05mxaa9adyy8kvo4nuq380z7';

$moip = new Moip(new MoipOAuth($accessToken), $endpoint);

$multiorder = $moip->multiorders()->get('MOR-P4JBIAG5L5KM');

Response:

200 (Ok)
Content-Type: application/json
 {
  "id": "MOR-9241K3EFW5DV",
  "ownId": "meu_multiorder_id",
  "status": "CREATED",
  "createdAt": "2015-02-27T11:39:02-0300",
  "updatedAt": "",
  "amount": {
    "currency": "BRL",
    "total": 8000
  },
  "orders": [
    {
      "id": "ORD-4LFGB72U2OK1",
      "ownId": "pedido_1_id",
      "status": "CREATED",
      "createdAt": "2015-02-27T11:39:02-0300",
      "amount": {
        "total": 4000,
        "fees": 0,
        "refunds": 0,
        "liquid": 0,
        "otherReceivers": 4000,
        "currency": "BRL",
        "subtotals": {
          "shipping": 2000,
          "addition": 0,
          "discount": 0,
          "items": 2000
        }
      },
      "items": [
        {
          "product": "Camisa Verde e Amarelo - Brasil",
          "price": 2000,
          "detail": "Seleção Brasileira",
          "quantity": 1
        }
      ],
      "customer": {
        "id": "CUS-IRDAWA6Q260J",
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "createdAt": "2015-02-27T11:39:02-0300",
        "birthDate": "1988-12-30T00:00:00-0200",
        "email": "[email protected]",
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "shippingAddress": {
          "zipCode": "01234000",
          "street": "Avenida Faria Lima",
          "streetNumber": "2927",
          "complement": "8",
          "city": "Sao Paulo",
          "district": "Itaim",
          "state": "SP",
          "country": "BRA"
        },
        "_links": {
          "self": {
            "href": "https://sandbox.moip.com.br/v2/customers/CUS-IRDAWA6Q260J"
          }
        }
      },
      "payments": [],
      "refunds": [],
      "entries": [],
      "events": [
        {
          "createdAt": "2015-02-27T11:39:02-0300",
          "description": "",
          "type": "ORDER.CREATED"
        }
      ],
      "receivers": [
        {
          "amount": {
            "fees": 0,
            "refunds": 0,
            "total": 4000
          },
          "moipAccount": {
            "fullname": "Lojista 4 Moip",
            "login": "[email protected]",
            "id": "MPA-VB5OGTVPCI52"
          },
          "type": "PRIMARY"
        }
      ],
      "shippingAddress": {
        "zipCode": "01234000",
        "street": "Avenida Faria Lima",
        "streetNumber": "2927",
        "complement": "8",
        "city": "Sao Paulo",
        "district": "Itaim",
        "state": "SP",
        "country": "BRA"
      },
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-4LFGB72U2OK1"
        }
      }
    },
    {
      "id": "ORD-29P0JCAJY8ZU",
      "ownId": "pedido_2_id",
      "status": "CREATED",
      "createdAt": "2015-02-27T11:39:02-0300",
      "amount": {
        "total": 4000,
        "fees": 0,
        "refunds": 0,
        "liquid": 0,
        "otherReceivers": 4000,
        "currency": "BRL",
        "subtotals": {
          "shipping": 3000,
          "addition": 0,
          "discount": 0,
          "items": 1000
        }
      },
      "items": [
        {
          "product": "Camisa Preta - Alemanha",
          "price": 1000,
          "detail": "Camiseta da Copa 2014",
          "quantity": 1
        }
      ],
      "customer": {
        "id": "CUS-RE6XARTZD2K7",
        "ownId": "customer[1234]",
        "fullname": "Joao Sousa",
        "createdAt": "2015-02-27T11:39:02-0300",
        "birthDate": "1988-12-30T00:00:00-0200",
        "email": "[email protected]",
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        },
        "taxDocument": {
          "type": "CPF",
          "number": "22222222222"
        },
        "shippingAddress": {
          "zipCode": "01234000",
          "street": "Avenida Faria Lima",
          "streetNumber": "2927",
          "complement": "8",
          "city": "Sao Paulo",
          "district": "Itaim",
          "state": "SP",
          "country": "BRA"
        },
        "_links": {
          "self": {
            "href": "https://sandbox.moip.com.br/v2/customers/CUS-RE6XARTZD2K7"
          }
        }
      },
      "payments": [],
      "refunds": [],
      "entries": [],
      "events": [
        {
          "createdAt": "2015-02-27T11:39:02-0300",
          "description": "",
          "type": "ORDER.CREATED"
        }
      ],
      "receivers": [
        {
          "amount": {
            "fees": 0,
            "refunds": 0,
            "total": 3945
          },
          "moipAccount": {
            "fullname": "Lojista 3 Moip",
            "login": "[email protected]",
            "id": "MPA-IFYRB1HBL73Z"
          },
          "type": "PRIMARY"
        },
        {
          "amount": {
            "refunds": 0,
            "total": 55
          },
          "moipAccount": {
            "fullname": "Maria da Silva Santos",
            "login": "[email protected]",
            "id": "MPA-KQB1QFWS6QNM"
          },
          "type": "SECONDARY"
        }
      ],
      "shippingAddress": {
        "zipCode": "01234000",
        "street": "Avenida Faria Lima",
        "streetNumber": "2927",
        "complement": "8",
        "city": "Sao Paulo",
        "district": "Itaim",
        "state": "SP",
        "country": "BRA"
      },
      "_links": {
        "self": {
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-29P0JCAJY8ZU"
        }
      }
    }
  ],
  "_links": {
    "self": {
      "href": "https://sandbox.moip.com.br/v2/orders/MOR-9241K3EFW5DV"
    },
    "checkout": {
      "payOnlineBankDebitItau": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/itau/MOR-9241K3EFW5DV"
      },
      "payCreditCard": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/creditcard/MOR-9241K3EFW5DV"
      }
    }
  }
}
NameDescriptionType
idMultiorder ID.string(16), required

Multipayments

A Multipayment is a collection of payments related to a multiorder.
When you create a multipayment, Moip automatically creates one payment for each order inside the multiorder.
If a credit card is chosen as a funding instrument, Moip application will create one transaction for each payment, so the customer will have more than one debit in his credit card invoices.

Attributes:

NameDescriptionType
_
idMultipayment IDstring(16), response
statusStatus of a multipayment. Possible values: WAITING, IN_ANALYSIS, PRE_AUTHORIZED,AUTHORIZED, CANCELLED, REFUNDED, REVERSED, SETTLED.string, response
amountMultipayment amounts.structured
├─currencyCurrency. Possible values: BRL.string, response
└─totalTotal amount charged in cents. Ex: R$10,32 must be informed as 1032integer(12), response
installmentCountNumber of installments. Minimum 1 and maximum 12.integer(2)
delayCaptureUsed if you need to pre-capture a multipayment. Only available for credit cards.boolean
fundingInstrumentFunding instrument.structured
├─methodMethod used. Possible values: CREDIT_CARD, BOLETO, ONLINE_BANK_DEBIT, WALLETstring
├─creditCardCredit card ID, HASH or attributes.Object Credit card
├─boletoPayment slip attributes.Object Payment slip
├─onlineBankDebitOnline bank debit attributes.Object Online bank debit
└─walleteWallet attributes. SOON.Object e-Wallet
cancellationDetailsCancellation detailsstructured
├─cancelledByThe agent that denied the transaction.string, response
├─codeDenial codenumber, response
└─descriptionA brief description of the denial code.string, response
updatedAtDate when the resource was last updated.datetime, response
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
├─└─hrefResource URI.link, response
└─checkoutLinks to checkout. This link will redirect to the fundingInstrument informed. object Checkout MoipObject [Moip Checkout](#Checkout Moip), response

Create a multipayment [POST]

This API allows you to create automatically one payment for each order inside a multiorder.

Important: Unless you are certified with PCI DSS you must [encrypt](/docs/#criptografia) credit card data before sending it to Moip.

Endpoint

POST https://sandbox.moip.com.br/v2/multiorders/{multiorder_id}/multipayments

Example of a multipayment with credit card.

POST https://sandbox.moip.com.br/v2/multiorders/MOR-8H8VSF36G5HT/multipayments

Request:

Content-Type: application/json
Authorization: "OAuth qguusgp05mxaa9adyy8kvo4nuq380z7"
{
  "installmentCount": 1,
  "fundingInstrument": {
    "method": "CREDIT_CARD",
    "creditCard": {
      "hash": "HhL0kbhfid+jwgj5l6Kt9EPdetDxQN8s7uKUHDYxDC/XoULjzik44rSda3EcWuOcL17Eb8JjWc1JI7gsuwg9P0rJv1mJQx+d3Dv1puQYz1iRjEWWhnB1bw0gTvnnC/05KbWN5M8oTiugmhVK02Rt2gpbcTtpS7VWyacfgesBJFavYYMljYg8p2YGHXkXrMuQiOCeemKLk420d0OTMBba27jDVVJ663HZDrObnjFXJH/4B5irkj+HO5genV+V4PYoLcOESG4nrI3oFAsMGsLLcdJo0NNvkEmJpn0e9GzureKKFYisYU+BEd9EMr/odS0VMvOYRV65HbPTspIkjl2+3Q==",
      "holder": {
        "fullname": "Jose Portador da Silva",
        "birthdate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "33333333333"
        },
        "phone": {
          "countryCode": "55",
          "areaCode": "11",
          "number": "66778899"
        }
      }
    }
  }
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = {
    "installmentCount": 1,
    "fundingInstrument": {
        "method": "CREDIT_CARD",
        "creditCard": {
            "expirationMonth": 05,
            "expirationYear": 18,
            "number": "5555666677778884",
            "cvc": "123",
            "holder": {
                "fullname": "Jose Portador da Silva",
                "birthdate": "1988-12-30",
                "taxDocument": {
                    "type": "CPF",
                    "number": "22222222222"
                },
                "phone": {
                    "countryCode": "55",
                    "areaCode": "11",
                    "number": "66778899"
                }
            }
        }
    }
}
from urllib2 import Request, urlopen

values = """
{
    "installmentCount": 1,
    "fundingInstrument": {
        "method": "CREDIT_CARD",
        "creditCard": {
            "expirationMonth": 05,
            "expirationYear": 18,
            "number": "5555666677778884",
            "cvc": "123",
            "holder": {
                "fullname": "Jose Portador da Silva",
                "birthdate": "1988-12-30",
                "taxDocument": {
                    "type": "CPF",
                    "number": "22222222222"
                },
                "phone": {
                    "countryCode": "55",
                    "areaCode": "11",
                    "number": "66778899"
                }
            }
        }
    }
}"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}
request = Request('https://sandbox.moip.com.br/v2/multiorders/id/multipayments', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String accessToken = "m9mq5lni241ngslgpl910ew45bxnnez";

Moip moip = new Moip(new MoipOAuth(accessToken), endpoint);

Customer customer = moip.customers().setFullname("Jose Portador da Silva")
                                    .setBirthDate("1988-12-30")
                                    .setTaxDocument("33333333333", "CPF")
                                    .setPhone("11", "66778899", "55");

String ccNumber = "5555666677778884";

String cvcNumber = "123";

Payment multipayment = moip.multiorders().get("MOR-8H8VSF36G5HY").multipayments();

multipayment.setCreditCard("05", "18", ccNumber, cvcNumber, customer)
            .execute();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$accessToken = 'qguusgp05mxaa9adyy8kvo4nuq380z7';

$moip = new Moip(new MoipOAuth($accessToken), $endpoint);

$customer = $moip->customers()->setFullname('Jose Portador da Silva')
                              ->setBirthDate('1988-12-30')
                              ->setTaxDocument('33333333333')
                              ->setPhone(11, 66778899);

$ccNumber = '5555666677778884';

$cvcNumber = '123';

$multipayments = $moip->multiorders()->get('MOR-8H8VSF36G5HT')->multipayments();

$multipayments->setCreditCard('05','18', $ccNumber, $cvcNumver, $customer)
              ->execute();

Response:

201 (Created)
Content-Type: application/json
{
  "id": "MPY-8MMS9Y8TE2IK",
  "status": "WAITING",
  "amount": {
    "currency": "BRL",
    "total": 8000
  },
  "installmentCount": 1,
  "payments": [
    {
      "id": "PAY-YVP2NVPMV6YC",
      "status": "WAITING",
      "amount": {
        "fees": 335,
        "refunds": 0,
        "liquid": 3665,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "creditCard": {
          "id": "CRC-31VUZTMZVION",
          "brand": "MASTERCARD",
          "first6": "555566",
          "last4": "8884",
          "holder": {
            "birthdate": "30/12/1988",
            "taxDocument": {
              "type": "CPF",
              "number": "33333333333"
            },
            "fullname": "Jose Portador da Silva"
          }
        },
        "method": "CREDIT_CARD"
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 335
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:07:34-0200",
          "type": "PAYMENT.WAITING"
        },
        {
          "createdAt": "2015-01-14T14:07:32-0200",
          "type": "PAYMENT.CREATED"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-H31PC0X9WTHR",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-H31PC0X9WTHR"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-YVP2NVPMV6YC"
        }
      },
      "updatedAt": "2015-01-14T14:07:34-0200",
      "createdAt": "2015-01-14T14:07:32-0200"
    },
    {
      "id": "PAY-78WM5WUDITVI",
      "status": "WAITING",
      "amount": {
        "fees": 335,
        "refunds": 0,
        "liquid": 3665,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "creditCard": {
          "id": "CRC-GTVZJDJ47I34",
          "brand": "MASTERCARD",
          "first6": "555566",
          "last4": "8884",
          "holder": {
            "birthdate": "30/12/1988",
            "taxDocument": {
              "type": "CPF",
              "number": "33333333333"
            },
            "fullname": "Jose Portador da Silva"
          }
        },
        "method": "CREDIT_CARD"
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 335
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:07:34-0200",
          "type": "PAYMENT.WAITING"
        },
        {
          "createdAt": "2015-01-14T14:07:33-0200",
          "type": "PAYMENT.CREATED"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-3PJ1LMDGGAZ1",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-3PJ1LMDGGAZ1"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-78WM5WUDITVI"
        }
      },
      "updatedAt": "2015-01-14T14:07:34-0200",
      "createdAt": "2015-01-14T14:07:33-0200"
    }
  ],
  "_links": {
    "multiorder": {
      "href": "https://sandbox.moip.com.br/v2/multiorders/MOR-DT554VQVBYCY"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/multipayments/MPY-8MMS9Y8TE2IK"
    }
  }
}

Example of a multipayment with payment slip

POST https://sandbox.moip.com.br/v2/multiorders/MOR-QXZKIF6GPN5V/multipayments

Request:

Content-Type: application/json
Authorization: "OAuth qguusgp05mxaa9adyy8kvo4nuq380z7"
{
  "fundingInstrument": {
    "method": "BOLETO",
    "boleto": {
      "expirationDate": "2016-09-30",
      "instructionLines": {
        "first": "Primeira linha se instrução",
        "second": "Segunda linha se instrução",
        "third": "Terceira linha se instrução"
      },
      "logoUri": "http://"
    }
  }
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = {
  "fundingInstrument": {
    "method": "BOLETO",
    "boleto": {
      "expirationDate": "2016-09-30",
      "instructionLines": {
        "first": "Primeira linha se instrução",
        "second": "Segunda linha se instrução",
        "third": "Terceira linha se instrução"
      },
      "logoUri": "http://"
    }
  }
}
from urllib2 import Request, urlopen

values = """
{
  "fundingInstrument": {
    "method": "BOLETO",
    "boleto": {
      "expirationDate": "2016-09-30",
      "instructionLines": {
        "first": "Primeira linha se instrução",
        "second": "Segunda linha se instrução",
        "third": "Terceira linha se instrução"
      },
      "logoUri": "http://"
    }
  }
}"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}
request = Request('https://sandbox.moip.com.br/v2/multiorders/id/multipayments', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String accessToken = "m9mq5lni241ngslgpl910ew45bxnnez";

Moip moip = new Moip(new MoipOAuth(accessToken), endpoint);

Payment multipayment = moip.multiorders().get("MOR-8H8VSF36G5HY").multipayments();

multipayment.setBoleto("2015-09-30",
             "https://logo-uri.com",
             new String[] {"Primeira linha do boleto",
                     "Segunda linha do boleto",
                     "Terceira linha do boleto"})
            .execute();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$accessToken = 'qguusgp05mxaa9adyy8kvo4nuq380z7';

$moip = new Moip(new MoipOAuth($accessToken), $endpoint);

$multipayments = $moip->multiorders()->get('MOR-8H8VSF36G5HT')->multipayments();

$multipayments->setBoleto('2016-09-30', 'https://logo-uri.com', array('Primeira linha se instrução',
                                                                      'Segunda linha se instrução',
                                                                      'Terceira linha se instrução'))
              ->execute();

Response:

201 (Created)
Content-Type: application/json
{
  "id": "MPY-7X3JO2E2AMFL",
  "status": "WAITING",
  "amount": {
    "currency": "BRL",
    "total": 8000
  },
  "installmentCount": 1,
  "fundingInstrument": {
    "boleto": {
      "expirationDate": "2016-09-30",
      "lineCode": "23793.39126 60000.032957 96001.747904 7 69330000008000",
      "instructionLines": {
        "third": "Terceira linha se instrução",
        "second": "Segunda linha se instrução",
        "first": "Primeira linha se instrução"
      }
    },
    "method": "BOLETO"
  },
  "payments": [
    {
      "id": "PAY-FJ6MWU4YM7YO",
      "status": "WAITING",
      "amount": {
        "fees": 155,
        "refunds": 0,
        "liquid": 3845,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "boleto": {
          "expirationDate": "2016-09-30",
          "instructionLines": {
            "third": "Terceira linha se instrução",
            "second": "Segunda linha se instrução",
            "first": "Primeira linha se instrução"
          }
        },
        "method": "BOLETO"
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 155
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:08:27-0200",
          "type": "PAYMENT.CREATED"
        },
        {
          "createdAt": "2015-01-14T14:08:27-0200",
          "type": "PAYMENT.WAITING"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-OK8E3Z5FDBHQ",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-OK8E3Z5FDBHQ"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-FJ6MWU4YM7YO"
        }
      },
      "updatedAt": "2015-01-14T14:08:27-0200",
      "createdAt": "2015-01-14T14:08:27-0200"
    },
    {
      "id": "PAY-TRYJXY9V2KR0",
      "status": "WAITING",
      "amount": {
        "fees": 155,
        "refunds": 0,
        "liquid": 3845,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "boleto": {
          "expirationDate": "2016-09-30",
          "instructionLines": {
            "third": "Terceira linha se instrução",
            "second": "Segunda linha se instrução",
            "first": "Primeira linha se instrução"
          }
        },
        "method": "BOLETO"
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 155
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:08:27-0200",
          "type": "PAYMENT.CREATED"
        },
        {
          "createdAt": "2015-01-14T14:08:27-0200",
          "type": "PAYMENT.WAITING"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-5D7RIISYWZRI",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-5D7RIISYWZRI"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-TRYJXY9V2KR0"
        }
      },
      "updatedAt": "2015-01-14T14:08:27-0200",
      "createdAt": "2015-01-14T14:08:27-0200"
    }
  ],
  "_links": {
    "multiorder": {
      "href": "https://sandbox.moip.com.br/v2/multiorders/MOR-QXZKIF6GPN5V"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/multipayments/MPY-7X3JO2E2AMFL"
    },
    "checkout": {
      "payBoleto": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/boleto/MPY-7X3JO2E2AMFL"
      }
    }
  }
}

Example of a multipayment with online bank debit

POST https://sandbox.moip.com.br/v2/multiorders/MOR-BZ1UC1FEZUWG/multipayments

Request:

Content-Type: application/json
Authorization: "OAuth qguusgp05mxaa9adyy8kvo4nuq380z7"
{
  "fundingInstrument": {
    "method": "ONLINE_BANK_DEBIT",
    "onlineBankDebit": {
      "bankNumber": "001",
      "expirationDate": "2016-12-30",
      "returnUri": "http://"
    }
  }
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = {
  "fundingInstrument": {
    "method": "ONLINE_BANK_DEBIT",
    "onlineBankDebit": {
      "bankNumber": "001",
      "expirationDate": "2016-12-30",
      "returnUri": "http://"
    }
  }
}
from urllib2 import Request, urlopen

values = """
{
  "fundingInstrument": {
  "fundingInstrument": {
    "method": "ONLINE_BANK_DEBIT",
    "onlineBankDebit": {
      "bankNumber": "001",
      "expirationDate": "2016-12-30",
      "returnUri": "http://"
    }
  }
}"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}
request = Request('https://sandbox.moip.com.br/v2/multiorders/id/multipayments', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String accessToken = "m9mq5lni241ngslgpl910ew45bxnnez";

Moip moip = new Moip(new MoipOAuth(accessToken), endpoint);

Payment multipayment = moip.multiorders().get("MOR-8H8VSF36G5HY").multipayments();

multipayment.setOnlineBankDebit("001", "2016-12-30", "https://return-uri.com")
            .execute();
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$accessToken = 'qguusgp05mxaa9adyy8kvo4nuq380z7';

$moip = new Moip(new MoipOAuth($accessToken), $endpoint);

$multipayments = $moip->multiorders()->get('MOR-8H8VSF36G5HT')->multipayments();

$multipayments->setOnlineBankDebit('001', '2016-12-30', 'https://return-uri.com')
              ->execute();

Response:

201 (Created)
Content-Type: application/json
{
  "id": "MPY-EP4WDATHIPPU",
  "status": "WAITING",
  "amount": {
    "currency": "BRL",
    "total": 8000
  },
  "installmentCount": 1,
  "payments": [
    {
      "id": "PAY-ET37WTEKYWG4",
      "status": "WAITING",
      "amount": {
        "fees": 155,
        "refunds": 0,
        "liquid": 3845,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "method": "ONLINE_BANK_DEBIT",
        "onlineBankDebit": {
          "expirationDate": "2016-12-30",
          "bankNumber": "001",
          "bankName": "BANCO DO BRASIL S.A."
        }
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 155
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:15:23-0200",
          "type": "PAYMENT.CREATED"
        },
        {
          "createdAt": "2015-01-14T14:15:23-0200",
          "type": "PAYMENT.WAITING"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-HWF5X38EW20T",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-HWF5X38EW20T"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-ET37WTEKYWG4"
        }
      },
      "updatedAt": "2015-01-14T14:15:23-0200",
      "createdAt": "2015-01-14T14:15:23-0200"
    },
    {
      "id": "PAY-U70D39R97FNV",
      "status": "WAITING",
      "amount": {
        "fees": 155,
        "refunds": 0,
        "liquid": 3845,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "method": "ONLINE_BANK_DEBIT",
        "onlineBankDebit": {
          "expirationDate": "2016-12-30",
          "bankNumber": "001",
          "bankName": "BANCO DO BRASIL S.A."
        }
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 155
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:15:23-0200",
          "type": "PAYMENT.CREATED"
        },
        {
          "createdAt": "2015-01-14T14:15:23-0200",
          "type": "PAYMENT.WAITING"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-KUKNFDIXWZ5T",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-KUKNFDIXWZ5T"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-U70D39R97FNV"
        }
      },
      "updatedAt": "2015-01-14T14:15:23-0200",
      "createdAt": "2015-01-14T14:15:23-0200"
    }
  ],
  "_links": {
    "multiorder": {
      "href": "https://sandbox.moip.com.br/v2/multiorders/MOR-BZ1UC1FEZUWG"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/multipayments/MPY-EP4WDATHIPPU"
    },
    "checkout": {
      "payOnlineBankDebitItau": {
        "redirectHref": "https://checkout-sandbox.moip.com.br/debit/itau/MPY-EP4WDATHIPPU"
      }
    }
  }
}

Parameters:

NameDescriptionType
_
installmentCountNumber of installments. Minimum 1 and maximum 12.integer(2), optional
delayCaptureUsed if you need to pre-capture a multipayment. Only available for credit cards.boolean, optional
fundingInstrumentFunding instrument attributes.structured
├─methodMethod used. Possible values: CREDIT_CARD, BOLETO, ONLINE_BANK_DEBIT, WALLET .string, required
├─creditCardCredit card attributes.structured
├ ├─idCredit card ID. This ID can be used in the future to create new multipayments. Internal reference.string(16), conditional
├ ├─hashEncrypted credit card data.string, conditional
├ ├─numberCredit Card number. Requires PCI certification.string(19), conditional
├ ├─expirationMonthCredit card expiration month. Requires PCI certification.integer(2), required
├ ├─expirationYearCredit card expiration year. Requires PCI certification.integer(4), required
├ ├─cvcCredit card security code.integer, optional
├ ├─holderHolder attributes.structured, in case of using credit card ID, this attribute is not necessary.
├ ├─├─fullnameHolder name.string(90), required *
├ ├─├─birthdateHolder birth date.date(YYYY-MM-DD), required *
├ ├─├─phonePhone attributes.structured
├ ├─├ ├─countryCodeArea code .integer(2), optional *
├ ├─├ ├─areaCodeCountry code .integer(2), optional *
├ ├─└ └─numberPhone number.integer(9), optional *
├ ├─├─taxDocumentTax document attributes.structured
├ ├─├ ├─typeType of document. Possible value: CPF for social security number, CNPJ for tax identification number.string(3), optional *
├ ├─└ └─numberTax document number.string(11), optional *
├ └─└─billingAddressBilling address.object Address optional *
├─boletoPayment slip attributes.structured
├ ├─expirationDatePayment slip expiration date .date, required
├ ├─instructionLinesPayment slip instruction attributes.structured
├ ├─├─firstPayment slip instructions, line 1.string, optional
├ ├─├─secondPayment slip instructions, line 2.string, optional
├ ├─└─thirdPayment slip instructions, line 3.string, optional
├ └─logoUriLogo that will be inserted on payment slip .link, optional
├─onlineBankDebitOnline bank debit attributes.structured
├ ├─bankNumberBank number. Possible values: 001, 237, 341, 041. List available HERE .string, conditional
├ ├─expirationDateDebit expiration date.date, conditional
└ └─returnUriReturn URI.link, conditional

*These fields are required for the Protected Sales Program

Retrieve a multipayment [GET]

With this API is possible to retrieve details of a multipayment.

Endpoint

GEThttps://sandbox.moip.com.br/v2/multipayments/{multipayment_id}

AUTHENTICATION: OAuth

Example:

GET https://sandbox.moip.com.br/v2/multipayments/MPY-8MMS9Y8TE2IK

Request:

Content-Type: application/json
Authorization: "OAuth qguusgp05mxaa9adyy8kvo4nuq380z7"

require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

headers = {
  :content_type => 'application/json',
  :authorization => 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}

response = RestClient.get 'https://sandbox.moip.com.br/v2/multipayments/id', headers
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'OAuth qguusgp05mxaa9adyy8kvo4nuq380z7'
}
request = Request('https://sandbox.moip.com.br/v2/multipayments/id', headers=headers)

response_body = urlopen(request).read()
print response_body
String endpoint = "sandbox.moip.com.br";
String accessToken = "m9mq5lni241ngslgpl910ew45bxnnez";

Moip moip = new Moip(new MoipOAuth(accessToken), endpoint);

Payment multipayment = moip.multiorders().get("MOR-8H8VSF36G5HY").multipayments().get("MPY-8MMS9Y8TE2IK");
<?php
require 'vendor/autoload.php';

use Moip\Moip;
use Moip\MoipBasicAuth;

$endpoint = 'sandbox.moip.com.br';
$accessToken = 'qguusgp05mxaa9adyy8kvo4nuq380z7';

$moip = new Moip(new MoipOAuth($accessToken), $endpoint);

$multipayments = $moip->multiorders()->get('MOR-8H8VSF36G5HT')->multipayments()->get('MPY-8MMS9Y8TE2IK');

Response:

200 (Ok)
Content-Type: application/json
 {
  "id": "MPY-8MMS9Y8TE2IK",
  "status": "AUTHORIZED",
  "amount": {
    "currency": "BRL",
    "total": 8000
  },
  "installmentCount": 1,
  "payments": [
    {
      "id": "PAY-YVP2NVPMV6YC",
      "status": "AUTHORIZED",
      "amount": {
        "fees": 335,
        "refunds": 0,
        "liquid": 3665,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "creditCard": {
          "id": "CRC-31VUZTMZVION",
          "brand": "MASTERCARD",
          "first6": "555566",
          "last4": "8884",
          "holder": {
            "birthdate": "30/12/1988",
            "taxDocument": {
              "type": "CPF",
              "number": "33333333333"
            },
            "fullname": "Jose Portador da Silva"
          }
        },
        "method": "CREDIT_CARD"
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 335
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:07:42-0200",
          "type": "PAYMENT.AUTHORIZED"
        },
        {
          "createdAt": "2015-01-14T14:07:37-0200",
          "type": "PAYMENT.IN_ANALYSIS"
        },
        {
          "createdAt": "2015-01-14T14:07:34-0200",
          "type": "PAYMENT.WAITING"
        },
        {
          "createdAt": "2015-01-14T14:07:32-0200",
          "type": "PAYMENT.CREATED"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-H31PC0X9WTHR",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-H31PC0X9WTHR"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-YVP2NVPMV6YC"
        }
      },
      "updatedAt": "2015-01-14T14:07:42-0200",
      "createdAt": "2015-01-14T14:07:32-0200"
    },
    {
      "id": "PAY-78WM5WUDITVI",
      "status": "AUTHORIZED",
      "amount": {
        "fees": 335,
        "refunds": 0,
        "liquid": 3665,
        "currency": "BRL",
        "total": 4000
      },
      "installmentCount": 1,
      "fundingInstrument": {
        "creditCard": {
          "id": "CRC-GTVZJDJ47I34",
          "brand": "MASTERCARD",
          "first6": "555566",
          "last4": "8884",
          "holder": {
            "birthdate": "30/12/1988",
            "taxDocument": {
              "type": "CPF",
              "number": "33333333333"
            },
            "fullname": "Jose Portador da Silva"
          }
        },
        "method": "CREDIT_CARD"
      },
      "fees": [
        {
          "type": "TRANSACTION",
          "amount": 335
        }
      ],
      "events": [
        {
          "createdAt": "2015-01-14T14:07:42-0200",
          "type": "PAYMENT.AUTHORIZED"
        },
        {
          "createdAt": "2015-01-14T14:07:37-0200",
          "type": "PAYMENT.IN_ANALYSIS"
        },
        {
          "createdAt": "2015-01-14T14:07:34-0200",
          "type": "PAYMENT.WAITING"
        },
        {
          "createdAt": "2015-01-14T14:07:33-0200",
          "type": "PAYMENT.CREATED"
        }
      ],
      "_links": {
        "order": {
          "title": "ORD-3PJ1LMDGGAZ1",
          "href": "https://sandbox.moip.com.br/v2/orders/ORD-3PJ1LMDGGAZ1"
        },
        "self": {
          "href": "https://sandbox.moip.com.br/v2/payments/PAY-78WM5WUDITVI"
        }
      },
      "updatedAt": "2015-01-14T14:07:42-0200",
      "createdAt": "2015-01-14T14:07:33-0200"
    }
  ],
  "_links": {
    "multiorder": {
      "href": "https://sandbox.moip.com.br/v2/multiorders/MOR-DT554VQVBYCY"
    },
    "self": {
      "href": "https://sandbox.moip.com.br/v2/multipayments/MPY-8MMS9Y8TE2IK"
    }
  }
}
NameDescriptionType
idMultipayment ID.string(16), required

Third party authentication (OAuth)

OAuth permissions allows you to obtain information of other Moip accounts in order to create order and payments where these account are involved as receivers.

To do so, you'll need basically finish 3 steps:

  • Register your APP
  • Ask permissions
  • Generate accessToken

Registering your APP

To act on behalf of other sellers you need to create a Moip APP.
Here you can fill a form that will request to our team the creation of your app, after that you'll receive an email containing:

  • appId
  • appSecret
  • accessToken

With these you can create the link to ask OAuth permissions and generate de accessToken from the sellers account.

Getting permissions [GET]

For getting permissions you have to build a URL with the parameters below and redirect the user to this URL.
After the user gives you permission, you will receive a new code and use it to request its accessToken.

Endpoint

GET https://sandbox.moip.com.br/oauth/authorize

Attributes:

NameDescriptionDetails
responseTypeDefines the type os response. Possible values: CODEstring(4), required
appIdAPP ID.string(16) required
redirectUriRedirect URIstring(255), required
scopeScope of permissions you required. Possible values: CREATE_ORDERS,VIEW_ORDERS,CREATE_PAYMENTS,VIEW_PAYMENTstring(255), required

Example:

https://sandbox.moip.com.br/oauth/authorize?responseType=CODE&appId=APP1A2B3C4D5E6F&redirectUri=https://url.com.br/callback.php&scope=CREATE_ORDERS|VIEW_ORDERS|CREATE_PAYMENTS|VIEW_PAYMENTS

You can send additional parameters to identify your user with `query-params`, but it's necessary that you encode the URL so the parameters sent won't conflict with the required parameters.

Example

https://sandbox.moip.com.br/oauth/authorize?responseType=CODE&appId=APP-QZYFOVCEXC2S&redirectUri=https%3A%2F%2Flabs.moip.com.br%3Fmy_seller_id%sell321&scope=VIEW_PAYMENTS

Redirect_userRedirect_user

Once the user is redirected, Moip will check if he's logged in, if he's, there will be shown the options to accept or refuse the permission for yout app.

User_permissionUser_permission

In case the permission is given the user will be redirected to you redirect url with the code from his confirmation.

Example:

http://meusite.com.br/?code=ohgrvfk2kdq92w27w66mlntasfh24je&scope=create_orders+view_orders+create_payments+view_payments

If he is not logged in, he will be redirected to Moip login page and after login he will be send back to the step described above.

Generate token OAuth (accessToken) [POST]

Com a permissão concedida, você receberá um code que lhe permitira recuperar o accessToken de autenticação e processar requisições envolvendo outro usuário.

With the code you retrieved from the step above you will be able to get the user acessToken and then use it to make requests on his behelf.

Attributes:

| Name Description Details
|:------------ :--------------- :-----
| appId APP Id. string(4), required
| appSecret APP private key. string(32) required
| redirectUri Redirec URI (must be the same URI used when the permission was required). string required
| grantType Grant type. Possible values: AUTHORIZATION_CODE . string(18) required
| code Authentication code. Reference to retrieve the accessToken. string(32) required
| accessToken User's access token. string(32) response
| access_token User's access token. The value of this attribute is the same of the attribute above. string(32) response
| scope Given permissions. string response
| moipAccountId User's Moip account ID. string(16) response

Endpoint

POST https://sandbox.moip.com.br/oauth/accesstoken

AUTHENTICATION: Basic Authentication

Request:

Content-Type: application/json
Authorization: "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="
{
  "appId": "APP-A1B2C3D4E5F6",
  "appSecret": "aa6494500f7711e38ffd0800200c9a66",
  "redirectUri": "https://url.com.br/callback",
  "grantType": "AUTHORIZATION_CODE",
  "code": "550e8400e29b41d4a716446655440000"
}
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'

values = {
  "appId": "APP-A1B2C3D4E5F6",
  "appSecret": "aa6494500f7711e38ffd0800200c9a66",
  "redirectUri": "https://url.com.br/callback",
  "grantType": "AUTHORIZATION_CODE",
  "code": "550e8400e29b41d4a716446655440000"
}

headers = {
  :content_type => 'application/json',
  :authorization => 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}

response = RestClient.post 'https://sandbox.moip.com.br/oauth/accesstoken', values, headers
puts response
from urllib2 import Request, urlopen

values = """
{{
  "appId": "APP-A1B2C3D4E5F6",
  "appSecret": "aa6494500f7711e38ffd0800200c9a66",
  "redirectUri": "https://url.com.br/callback",
  "grantType": "AUTHORIZATION_CODE",
  "code": "550e8400e29b41d4a716446655440000"
}"""

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=='
}
request = Request('https://sandbox.moip.com.br/oauth/accesstoken', data=values, headers=headers)

response_body = urlopen(request).read()
print response_body
// Maven : Add these dependecies to your pom.xml
// <dependency>
//     <groupId>org.glassfish.jersey.core</groupId>
//     <artifactId>jersey-client</artifactId>
//     <version>2.13</version>
// </dependency>
// <dependency>
//     <groupId>org.glassfish.jersey.media</groupId>
//     <artifactId>jersey-media-json-jackson</artifactId>
//     <version>2.13</version>
// </dependency>

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

Client client = ClientBuilder.newClient();
Entity payload = Entity.json("{
  "appId": "APP-A1B2C3D4E5F6",
  "appSecret": "aa6494500f7711e38ffd0800200c9a66",
  "redirectUri": "https://url.com.br/callback",
  "grantType": "AUTHORIZATION_CODE",
  "code": "550e8400e29b41d4a716446655440000"
}");
Response response = client.target("https://sandbox.moip.com.br")
  .path("/oauth/accesstoken")
  .request(MediaType.APPLICATION_JSON_TYPE)
  .header("Content-Type", "application/json")
  .header("Authorization", "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg==")
  .post(payload);

System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println("body:" + response.readEntity(String.class));
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://sandbox.moip.com.br/oauth/accesstoken");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_POST, TRUE);

curl_setopt($ch, CURLOPT_POSTFIELDS, {
  \"appId\": \"APP-A1B2C3D4E5F6\",
  \"appSecret\": \"aa6494500f7711e38ffd0800200c9a66\",
  \"redirectUri\": \"https://url.com.br/callback\",
  \"grantType\": \"AUTHORIZATION_CODE\",
  \"code\": \"550e8400e29b41d4a716446655440000\"
});

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Content-Type: application/json",
  "Authorization: Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="
));

$response = curl_exec($ch);
curl_close($ch);

var_dump($response);

Response:

201 (Created)
Content-Type: application/json
{
  "accessToken": "aa6494500f7711e38ffd0800200c9a77",
  "access_token": "aa6494500f7711e38ffd0800200c9a77",
  "scope": "CREATE_ORDERS|VIEW_ORDERS|CREATE_PAYMENTS|VIEW_PAYMENTS",
  "moipAccountId": "MPA-A1B2C3D4E5F6"
}

Moip accounts

This API allows you to create and retrieve information of a Moip account.

Attributes:

NameDescriptionDetails
idAccount IDstring, response
externalIdAccount ID. DEPRECATED Removed in 2016-01-15.string, response
accessTokenAccesso Token used by Marketplaces and Platforms to manage a Moip account. Only available for transparente accounts.string, response
channelIdAPP ID used to create the account.string, response
emailEmail structure.structured
├─addressEmail address. This will be used as login.string
└─confirmedEmail confirmation.boolean
loginLoginstring, response
personPerson structure.structured
├─nameName.string
├─lastNameLast name.string
├─taxDocumentTax document structure.structured
├─├─typeType of document. Possible value: CPF for social security number.string
├─└─numberDocument number.string
├─identityDocumentPersonal ID structure.structured
├─├─typeIdentity document type. Possible values: RG.string
├─├─numberNumber of document.string
├─├─issuerIssuer of the document.string
├─└─issueDateDate when the document was issued.date
├─birthDateBirth date.date (YYYY-MM-DD)
├─nationalityCountry code according to ISO-3string
├─birthPlaceBirth place.string
├─parentsNameParents name structure.structured
├─├─motherMother's name.string
├─└─fatherFather's name.string
├─phonePhone structurestructured
├─├─countryCodeCountry code. Possible values: 55.string
├─├─areaCodeArea code.string
├─└─numberPhone number.string
├─alternativePhonesAlternative phone numbers.structured list
├─├─countryCodeCountry code. Possible values: 55.string
├─├─areaCodeArea code.string
├─└─numberPhone number.string
├─addressAddress structurestructured
├─├─streetStreet name.string
├─├─streetNumberNumber.string
├─├─complementComplement.string
├─├─districtDistrict.string
├─├─zipcodeZip code. DEPRECATED Removed em 2016-01-15.string
├─├─zipCodeZip code.string
├─├─cityCity.string
├─├─stateState.string
└─└─countryCountry.string
companyCompany structure.structured
├─nameTrading name.string
├─businessNameCompany name.string
├─taxDocumentTax identification document structure.structured
├─├─typeCompany document type. Possible values: CNPJ .string
├─└─numberTax identification number.string
├─mainActivityActivity structure.structured
├─├─cnaeCNAE business code. Example: 82.91-1/00string
├─└─descriptionBusiness description. example: Atividades de cobranças e informações cadastraisstring
├─openingDateCompany opening date.date
├─phoneCompany's phone structure.structured
├─├─countryCodeCountry code.string
├─├─areaCodeArea code.string
├─└─numberPhone number.string
├─addressAddress structure.structured
├─├─streetStreet name.string
├─├─streetNumberNumber.string
├─├─complementComplement.string
├─├─districtDistrict.string
├─├─zipcodeZip code. DEPRECATED Removed em 2016-01-15.string
├─├─zipCodeZip code.string
├─├─cityCity.string
├─├─stateState.string
└─└─countryCountry.string
businessSegmentBusiness category.structured
├─idIndustry ID.string
├─nameBusiness segment name.string, Response
└─mccMerchant Category Code. Used by credit card issuers.string, Response
siteWeb site.string
typeAccount type Possible values: CONSUMER, MERCHANT. Ecommerce platforms and marketplace must use MERCHANT for their users.string
transparentAccountUsed to create transparent account for marketplaces and ecommerce platforms. Theses account are managed by the creator agent and Moip doesn't communicate with them in any way.boolean
tosAcceptanceContract structure.structured
├─acceptedAtDate when the user accepted the contract.datetime
├─ipIP (internet protocol)string
└─userAgentAgent through whom the user accepted the contract.string
createdAtAccount creation date.datetime
_linksLinks structure (HATEOAS) of resource.structured, response
├─selfResource hyperlink.structured
└─└─hrefResource URIlink

Create a Moip account [POST]

This API allows you to create a Moip account.

Endpoint

POST https://sandbox.moip.com.br/v2/accounts

AUTHENTICATION: OAuth

Request:

Content-Type: application/json
Authorization: "OAuth 1tldio91gi74r34zv30d4saz8yuuws5"

{
    "email": {
        "address": "[email protected]"
    },
    "person": {
        "name": "Runscope",
        "lastName": "Random 9123",
        "taxDocument": {
            "type": "CPF",
            "number": "742.520.863-61"
        }, 
          "identityDocument": {
          "type" : "RG",
          "number": "434322344",
          "issuer": "SSP",
          "issueDate": "2000-12-12" 
          }, 
        "birthDate": "1990-01-01",
        "phone": {
            "countryCode": "55",
            "areaCode": "11",
            "number": "965213244"
        },
        "address": {
            "street": "Av. Brigadeiro Faria Lima",
            "streetNumber": "2927",
            "district": "Itaim",
            "zipCode": "01234-000",
            "city": "São Paulo",
            "state": "SP",
            "country": "BRA"
        }
    },
    "type": "MERCHANT"
}

# Not available on Ruby SDK.
# Not available on Python SDK.
# Not available on Java SDK.
# Not available on PHP SDK.

Response:

201 (Created)
Content-Type: application/json
{
    "id": "MPA-8307EF11B83E",
    "channelId": "APP-7KHGFTMYHGLO",
    "type": "MERCHANT",
    "transparentAccount": false,
    "createdAt": "2015-10-29T16:53:25.957Z",
    "person": {
        "name": "Runscope",
        "lastName": "Random 9123",
        "birthDate": "1990-01-01",
        "taxDocument": {
            "number": "742.520.863-61",
            "type": "CPF"
        },
        "phone": {
            "number": "965213244",
            "areaCode": "11",
            "countryCode": "55"
        },
        "address": {
            "street": "Av. Brigadeiro Faria Lima",
            "streetNumber": "2927",
            "district": "Itaim",
            "zipCode": "01234000",
            "city": "São Paulo",
            "state": "SP",
            "country": "BRA"
        }
    },
    "email": {
        "address": "[email protected]",
        "confirmed": false
    },
    "_links": {
        "self": {
            "href": "https://sandbox.moip.com.br/moipaccounts/MPA-8307EF11B83E"
        }
    },
    "login": "[email protected]",
    "externalId": "MPA-8307EF11B83E"
}

Parameters:

NameDescriptionDetails
emailEmail structure.structured
└─addressEmail address. This will be used as login.string, required
personPerson structure.structured
├─nameName.string, required
├─lastNameLast name.string, required
├─taxDocumentTax document structure.structured
├─├─typeType of document. Possible value: CPF for social security number.string, required
├─└─numberDocument number.string, required
├─identityDocumentPersonal ID structure.structured, required
├─├─typeIdentity document type. Possible values: RG.string
├─├─numberNumber of document.string
├─├─issuerIssuer of the document.string
├─└─issueDateDate when the document was issued.date
├─birthDateBirth date.date (YYYY-MM-DD)
├─nationalityCountry code according to ISO-3string
├─birthPlaceBirth place.string
├─parentsNameParents name structure.structured
├─├─motherMother's name.string