Examples

Here you can see some API requests examples.

Create Order for Wirecard Checkout

If you want to use our checkout to perform your payments, you will be able to do this through this requisition:

{  
   "ownId":"meu_id_order",
   "amount":{  
      "currency":"BRL",
      "subtotals":{  
         "shipping":1500
      }
   },
   "items":[  
      {  
         "product":"Nome do produto",
         "category":"APPAREL_AND_ACCESSORIES",
         "subcategory":"CLOTHING",
         "quantity":1,
         "detail":"Camiseta estampada branca",
         "price":9500
      }
   ],
   "customer":{  
      "id":"CUS-SB5W39JUOLUV"
   },
   
   "checkoutPreferences":{  
      "redirectUrls":{  
         "urlSuccess": "http://www.lojaexemplo.com.br/compraFeita",
         "urlFailure": "http://www.lojaexemplo.com.br/error"
      },
      "installments":[  
         {  
            "quantity":[2,2],
            "addition":1000
         }
      ]
   },
   "receivers": [
    {
      "type": "SECONDARY",
      "feePayor": true,
      "moipAccount": {
        "id": "MPA-E3C8493A06AE"
      },
      "amount": {
        "percentual": 15
      }
    }
  ]
}
#
# This example is based in our SDK developed in Ruby, available
# on: https://github.com/wirecardBrasil/moip-sdk-ruby
#

order = api.order.create(
  ownId: 'meu_id_order',
  amount: {
    currency: 'BRL',
    subtotals: {
      shipping: 1500
    }
  },
  items: [
    {
      product: 'Nome do produto',
      category: 'APPAREL_AND_ACCESSORIES',
      subcategory: 'CLOTHING',
      quantity: 1,
      detail: 'Camiseta estampada branca',
      price: 9500
    }
  ],
  customer: {
    id: 'CUS-SB5W39JUOLUV'
  },

  checkoutPreferences: {
    redirectUrls: {
      urlSuccess: 'http://www.lojaexemplo.com.br/compraFeita',
      urlFailure: 'http://www.lojaexemplo.com.br/error'
    },
    installments: [
      {
        quantity: [2, 2],
        addition: 1000
      }
    ]
  },
  receivers: [
    {
      type: 'SECONDARY',
      feePayor: true,
      moipAccount: {
        id: 'MPA-E3C8493A06AE'
      },
      amount: {
        percentual: 15
      }
    }
  ]
)
/**
* This example is based in our SDK developed in Java, available
* on: https://github.com/wirecardBrasil/moip-sdk-java
*/

Map<String, Object> subtotals = payloadFactory(
    value("shipping", 15000)
);

Map<String, Object> amount = payloadFactory(
    value("currency", "BRL"),
    value("subtotals", subtotals)
);

Map<String, Object> product = payloadFactory(
    value("product", "Product 1 Description"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Anakin's Light Saber"),
    value("price", 100000000)
);

List items = new ArrayList();
items.add(product);

Map<String, Object> redirectUrls = payloadFactory(
    value("urlSuccess", "https://urlSuccess.com"),
    value("urlFailure", "https://urlFailure.com")
);

List installments = new ArrayList();
installments.add(1); // min allowed installment
installments.add(5); // max allowed installment

Map<String, Object> installments = payloadFactory(
    value("quantity", installments)
);

Map<String, Object> checkoutPreferences = payloadFactory(
    value("redirectUrls", redirectUrls),
    value("installments", installments)
);
  
Map<String, Object> customer = payloadFactory(
    value("id", "CUS-XXOBPZ80QLYP")
);

Map<String, Object> order = payloadFactory(
    value("ownId", "order_own_id"),
    value("amount", amount),
    value("items", items),
    value("checkoutPreferences", checkoutPreferences),
    value("customer", customer)
);

Map<String, Object> responseCreation = Moip.API.orders().create(order, setup);
<?php

/**
* This example is based in our SDK developed in PHP, available
* on: https://github.com/wirecardBrasil/moip-sdk-php
*/

$order = $moip->orders()->setOwnId("meu_id_order")
    ->addItem("Nome do produto", 1, "Camiseta estampada branca", 9500)
    ->setShippingAmount(1500)->setAddition(0)->setDiscount(0)
    ->addInstallmentCheckoutPreferences([2, 2], 0, 1000)
    ->setUrlSuccess("http://www.lojaexemplo.com.br/compraFeita")
    ->setUrlFailure("http://www.lojaexemplo.com.br/error")
    ->setCustomerId("CUS-SB5W39JUOLUV")
    ->addReceiver("MPA-E3C8493A06AE", "SECONDARY", 0, 30, true)
    ->create();

print_r($order);
/**
* This example is based in our SDK developed in Node js, available
* on: https://github.com/wirecardBrasil/moip-sdk-node
*/

const moip = require('moip-sdk-node').default({
  accessToken: 'your-access-token',
  production: false
})

moip.order.create({
  ownId: '1521656695',
    amount: {
        currency: 'BRL',
        subtotals: {
            shipping: 1500
        }
    },
    items: [{
        product: 'Descrição do pedido',
        quantity: 1,
        detail: 'Mais info...',
        price: 9500
    }],
    customer: {
        ownId: 'id_cliente',
        fullname: 'Eduardo Garcia',
        email: '[email protected]',
        birthDate: '1988-12-30',
        taxDocument: {
            type: 'CPF',
            number: '59929091092'
          checkoutPreferences:{  
      redirectUrls:{  
         urlSuccess: 'http://www.lojaexemplo.com.br/compraFeita',
         urlFailure: 'http://www.lojaexemplo.com.br/error'
        },
        phone: {
            countryCode: '55',
            areaCode: '11',
            number: '22355576'
        },
        shippingAddress: {
            street: 'Avenida Faria Lima',
            streetNumber: 500,
            complement: 10,
            district: 'Itaim Bibi',
            city: 'Sao Paulo',
            state: 'SP',
            country: 'BRA',
            zipCode: '01234500'
        },
  receivers: [
    {
      type: 'SECONDARY',
      feePayor: true,
      moipAccount: {
        id: 'MPA-E3C8493A06AE'
      },
      amount: {
        percentual: 30
      }
    }
  ]
}
}).then((response) => {
    console.log(response.body)
}).catch((err) => {
    console.log(err)
})
var body = new OrderRequest
{
    OwnId = "id_pedido",
    Amount = new Amount
    {
        Currency = "BRL",
        Subtotals = new Subtotals
        {
            Shipping = 1000
        }
    },
    Items = new List<Item>
    {
        new Item
        {
            Product = "Descrição do pedido",
            Category = "VIDEO_GAME_SOFTWARE",
            Quantity = 1,
            Detail = "Mais info...",
            Price = 22000
        }
    },
    Customer = new Customer
    {
        Id = "CUS-7AKU0VORZ2D4"
    }
};
var result = await WC.Order.Create(body);

Create Order with a New Customer

Creating order and registering a new customer in the same request:

{
  "ownId": "id_pedido",
  "amount": {
    "currency": "BRL",
    "subtotals": {
      "shipping": 1000
    }
  },
  "items": [
    {
      "product": "Descrição do pedido",
      "category": "CLOTHING",
      "quantity": 1,
      "detail": "Mais info...",
      "price": 12000
    }
  ],
  "customer": {
    "ownId": "id_cliente",
    "fullname": "Eduardo Garcia",
    "email": "[email protected]",
    "birthDate": "1988-12-30",
    "taxDocument": {
      "type": "CPF",
      "number": "59929091092"
    },
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "22355576"
    },
    "shippingAddress": {
      "street": "Avenida 23 de Maio",
      "streetNumber": 654,
      "complement": 12,
      "district": "Centro",
      "city": "Sao Paulo",
      "state": "SP",
      "country": "BRA",
      "zipCode": "01244500"
    }
  },
  "receivers": [
    {
      "type": "SECONDARY",
      "feePayor": true,
      "moipAccount": {
        "id": "MPA-E3C8493A06AE"
      },
      "amount": {
        "percentual": 30
      }
    }
  ]
}
#
# This example is based in our SDK developed in Ruby, available
# on: https://github.com/wirecardBrasil/moip-sdk-ruby
#

order = api.order.create(
  ownId: "id_pedido",
  amount: {
    currency: "BRL",
    subtotals: {
      shipping: 1000,
    },
  },
  items: [
    {
      product: "Descrição do pedido",
      category: "CLOTHING",
      quantity: 1,
      detail: "Mais info...",
      price: 12000,
    },
  ],
  customer: {
    ownId: "id_cliente",
    fullname: "Eduardo Garcia",
    email: "[email protected]",
    birthDate: "1988-12-30",
    taxDocument: {
      type: "CPF",
      number: "59929091092",
    },
    phone: {
      countryCode: "55",
      areaCode: "11",
      number: "22355576",
    },
    shippingAddress: {
      street: "Avenida 23 de Maio",
      streetNumber: "654",
      complement: "12",
      district: "Centro",
      city: "Sao Paulo",
      state: "SP",
      country: "BRA",
      zipCode: "01244500",
    },
  },
  receivers: [
    {
      type: "SECONDARY",
      feePayor: true,
      moipAccount: {
        id: "MPA-E3C8493A06AE",
      },
      amount: {
        percentual: 30
      }
    }
  ]
)
/**
* This example is based in our SDK developed in Java, available
* on: https://github.com/wirecardBrasil/moip-sdk-java
*/

Map<String, Object> subtotals = payloadFactory(
    value("shipping", 15000)
);

Map<String, Object> amount = payloadFactory(
    value("currency", "BRL"),
    value("subtotals", subtotals)
);

Map<String, Object> product1 = payloadFactory(
    value("product", "Product 1 Description"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Anakin's Light Saber"),
    value("price", 100000000)
);

Map<String, Object> product2 = payloadFactory(
    value("product", "Product 2 Description"),
    value("category", "SCIENCE_AND_LABORATORY"),
    value("quantity", 5),
    value("detail", "Pym particles"),
    value("price", 2450000000)
);

List items = new ArrayList();
items.add(product1);
items.add(product2);

Map<String, Object> taxDocument = payloadFactory(
    value("type", "CPF"),
    value("number", "10013390023")
);

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

Map<String, Object> shippingAddress = payloadFactory(
    value("city", "Sao Paulo"),
    value("district", "Itaim BiBi"),
    value("street", "Av. Brigadeiro Faria Lima"),
    value("streetNumber", "3064"),
    value("state", "SP"),
    value("country", "BRA"),
    value("zipCode", "01451001")
);

Map<String, Object> customer = payloadFactory(
    value("ownId", "customer_own_id"),
    value("fullname", "Customer Full Name"),
    value("email", "[email protected]"),
    value("birthDate", "1980-5-10"),
    value("taxDocument", taxDocument),
    value("phone", phone),
    value("shippingAddress", shippingAddress)
);

Map<String, Object> order = payloadFactory(
    value("ownId", "order_own_id"),
    value("amount", amount),
    value("items", items),
    value("customer", customer)
);

Map<String, Object> responseCreation = Moip.API.orders().create(order, setup);
<?php

/**
* This example is based in our SDK developed in PHP, available
* on: https://github.com/wirecardBrasil/moip-sdk-php
*/

$order = $moip->orders()->setOwnId("id_pedido")
    ->addItem("Descrição do pedido", 1, "Mais info...", 12000)
    ->setShippingAmount(1000)->setAddition(0)->setDiscount(0)
    ->setCustomer($moip->customers()->setOwnId("id_cliente")
        ->setFullname("Eduardo Garcia")
        ->setEmail("[email protected]")
        ->setBirthDate("1988-12-30")
        ->setTaxDocument("59929091092")
        ->setPhone(11, 22355576)
        ->addAddress("SHIPPING",
            "Avenida 23 de Maio", 654,
            "Centro", "Sao Paulo", "SP",
            "01244500", 12))
    ->addReceiver("MPA-E3C8493A06AE", "SECONDARY", 0, 30, true)
    ->create();

print_r($order);
/**
* This example is based in our SDK developed in Node js, available
* on: https://github.com/wirecardBrasil/moip-sdk-node
*/

const moip = require('moip-sdk-node').default({
  accessToken: 'your-access-token',
  production: false
})

moip.order.create({
    ownId: '1521656695',
    amount: {
        currency: 'BRL',
        subtotals: {
            shipping: 1000
        }
    },
    items: [{
        product: 'Descrição do pedido',
        quantity: 1,
        detail: 'Mais info...',
        price: 12000
    }],
    customer: {
        ownId: 'id_cliente',
        fullname: 'Eduardo Garcia',
        email: '[email protected]',
        birthDate: '1988-12-30',
        taxDocument: {
            type: 'CPF',
            number: '59929091092'
        },
        phone: {
            countryCode: '55',
            areaCode: '11',
            number: '22355576'
        },
        shippingAddress: {
            street: 'Avenida 23 de Maio',
            streetNumber: 654,
            complement: 12,
            district: 'Centro',
            city: 'Sao Paulo',
            state: 'SP',
            country: 'BRA',
            zipCode: '01244500'
        },
      receivers: [
    {
      type: 'SECONDARY',
      feePayor: true,
      moipAccount: {
        id: 'MPA-E3C8493A06AE'
      },
      amount: {
        percentual: 30
      }
    }
  ]
}).then((response) => {
    console.log(response.body)
}).catch((err) => {
    console.log(err)
})
var body = new OrderRequest
{
    OwnId = "id_pedido",
    Amount = new Amount
    {
        Currency = "BRL",
        Subtotals = new Subtotals
        {
            Shipping = 1000
        }
    },
    Items = new List<Item>
    {
        new Item
        {
            Product = "Descrição do pedido",
            Category = "VIDEO_GAME_SOFTWARE",
            Quantity = 1,
            Detail = "Mais info...",
            Price = 22000
        }
    },
    Customer = new Customer
    {
     OwnId = "meu_id_customer",
     FullName = "João Silva",
     Email = "[email protected]",
     BirthDate = "1990-10-22",
     TaxDocument = new Taxdocument
     {
         Type = "CPF",
         Number = "22288866644"
     },
     Phone = new Phone
     {
         CountryCode = "55",
         AreaCode = "11",
         Number = "55552266"
     },
     ShippingAddress = new Shippingaddress
     {
         City = "São Paulo",
         Complement = "10",
         District = "Itaim Bibi",
         Street = "Avenida Faria Lima",
         StreetNumber = "500",
         ZipCode = "01234000",
         State = "SP",
         Country = "BRA"
     }
   }
};
var result = await WC.Order.Create(body);

Create Order with an Existing Customer

Creating an order by passing the ID of an existing customer:

{
  "ownId": "identificador_pedido",
  "amount": {
    "currency": "BRL",
    "subtotals": {
      "shipping": 1500
    }
  },
  "items": [
    {
      "product": "Câmera fotográfica",
      "category": "CAMERAS",
      "quantity": 1,
      "detail": "Câmera fotográfica, modelo CM54296, cor preta",
      "price": 100000
    }
  ],
  "customer": {
    "id": "CUS-OQSQ7IWL229E"
  },
    "receivers": [
    {
      "type": "SECONDARY",
      "feePayor": true,
      "moipAccount": {
        "id": "MPA-E3C8493A06AE"
      },
      "amount": {
        "percentual": 15
      }
    }
  ]
}
#
# This example is based in our SDK developed in Ruby, available
# on: https://github.com/wirecardBrasil/moip-sdk-ruby
#

order = api.order.create({ 
  ownId: 'identificador_pedido', 
  amount: {
    currency: 'BRL', 
    subtotals: {
      shipping: 1500
    }
  },
  items: [
    {
      product: 'Câmera fotográfica', 
      category: 'CAMERAS', 
      quantity: 1,
      detail: 'Câmera fotográfica, modelo CM54296, cor preta', 
      price: 100000
    }
  ],
  customer: {
    id: 'CUS-OQSQ7IWL229E'
  },
   receivers: [
    {
      type: "SECONDARY",
      feePayor: true,
      moipAccount: {
        id: "MPA-E3C8493A06AE",
      },
      amount: {
        percentual: 30
      }
    }
  ]
 })
/**
* This example is based in our SDK developed in Java, available
* on: https://github.com/wirecardBrasil/moip-sdk-java
*/

Map<String, Object> subtotals = payloadFactory(
    value("shipping", 15000)
);

Map<String, Object> amount = payloadFactory(
    value("currency", "BRL"),
    value("subtotals", subtotals)
);

Map<String, Object> product1 = payloadFactory(
    value("product", "Product 1 Description"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Anakin's Light Saber"),
    value("price", 100000000)
);

Map<String, Object> product2 = payloadFactory(
    value("product", "Product 2 Description"),
    value("category", "SCIENCE_AND_LABORATORY"),
    value("quantity", 5),
    value("detail", "Pym particles"),
    value("price", 2450000000)
);

List items = new ArrayList();
items.add(product1);
items.add(product2);

Map<String, Object> customer = payloadFactory(
    value("id", "CUS-XXOBPZ80QLYP")
);

Map<String, Object> order = payloadFactory(
    value("ownId", "order_own_id"),
    value("amount", amount),
    value("items", items),
    value("customer", customer)
);

Map<String, Object> responseCreation = Moip.API.orders().create(order, setup);
<?php

/**
* This example is based in our SDK developed in PHP, available
* on: https://github.com/wirecardBrasil/moip-sdk-php
*/

$order = $moip->orders()->setOwnId("meu_id_order")
        ->addItem("Descrição do pedido",1, "Camiseta estampada branca", 9500)
        ->setShippingAmount(1500)->setAddition(0)->setDiscount(0)
        ->setCustomerId("CUS-87HFA3QCEKO7")
        ->addReceiver("MPA-E3C8493A06AE", "SECONDARY", 0, 30, true)
        ->create();

print_r($order);
/**
* This example is based in our SDK developed in Node js, available
* on: https://github.com/wirecardBrasil/moip-sdk-node
*/

const moip = require('moip-sdk-node').default({
  accessToken: 'your-access-token',
  production: false
})

moip.order.create({
    own_id: 'identificador_pedido',
    amount: {
        currency: 'BRL',
        subtotals: {
            shipping: 1000
        }
    },
    items: [{
        product: 'Descrição do pedido',
        quantity: 1,
        detail: 'Mais info...',
        price: 1000
    }],
    customer: {
        id: 'CUS-OQSQ7IWL229E'
    },
   receivers: [
    {
      type: 'SECONDARY',
      feePayor: true,
      moipAccount: {
        id: 'MPA-E3C8493A06AE'
      },
      amount: {
        percentual: 30
      }
    }
  ]
}).then((response) => {
    console.log(response.body)
}).catch((err) => {
    console.log(err)
})
var body = new OrderRequest
{
    OwnId = "id_pedido",
    Amount = new Amount
    {
        Currency = "BRL",
        Subtotals = new Subtotals
        {
            Shipping = 1000
        }
    },
    Items = new List<Item>
    {
        new Item
        {
            Product = "Descrição do pedido",
            Category = "VIDEO_GAME_SOFTWARE",
            Quantity = 1,
            Detail = "Mais info...",
            Price = 22000
        }
    },
    Customer = new Customer
    {
        Id = "CUS-7AKU0VORZ2D4"
    }
};
var result = await WC.Order.Create(body);