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":"order_unique_id",
   "amount":{  
      "currency":"BRL",
      "subtotals":{  
         "shipping":1500
      }
   },
   "items":[  
      {  
         "product":"Product name",
         "category":"APPAREL_AND_ACCESSORIES",
         "subcategory":"CLOTHING",
         "quantity":1,
         "detail":"Product detail",
         "price":9500
      }
   ],
   "customer":{  
      "id":"CUS-87HFA3QCEKO7"
   },
   "checkoutPreferences":{  
      "redirectUrls":{  
         "urlSuccess": "http://www.yourecommerce.com.br/success",
         "urlFailure": "http://www.yourecommerce.com.br/error"
      },
      "installments":[  
         {  
            "quantity":[2,2],
            "addition":1000
         }
      ]
   }
}
#
# This example is based in our SDK developed in Ruby, available
# on: https://github.com/wirecardBrasil/moip-sdk-ruby
#

order = api.order.create({  
  ownId: 'order_unique_id', 
   amount: {  
      currency: 'BRL', 
      subtotals: {  
         shipping: 1500
      }
   },
   items: [  
      {  
        product: 'Product name', 
         category: 'APPAREL_AND_ACCESSORIES', 
         subcategory: 'CLOTHING', 
         quantity: 1,
        detail: 'Product detail', 
         price: 9500
      }
   ],
   customer: {  
      id: 'CUS-87HFA3QCEKO7'
   },
   checkoutPreferences: {  
      redirectUrls: {  
        urlSuccess: 'http://www.yourecommerce.com.br/success', 
         urlFailure: 'http://www.yourecommerce.com.br/error'
      },
      installments: [  
         {  
            quantity: [2,2],
            addition: 1000
         }
      ]
   }
 })
/**
* 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 name"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Product detail"),
    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_unique_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("order_unique_id")
    ->addItem("Product name",1, "Product detail", 9500)
    ->setShippingAmount(1500)->setAddition(0)->setDiscount(0)
    ->addInstallmentCheckoutPreferences([2, 2], 0, 1000)
    ->setUrlSuccess("http://www.yourecommerce.com.br/success")
    ->setUrlFailure("http://www.yourecommerce.com.br/error")
    ->setCustomerId("CUS-87HFA3QCEKO7")
    ->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: 'order_unique_id',
    amount: {
        currency: 'BRL',
        subtotals: {
            shipping: 1000
        }
    },
    items: [{
        product: 'Product name',
        quantity: 1,
        detail: 'Product detail',
        price: 1000
    }],
    customer:{  
            id: 'CUS-87HFA3QCEKO7'
    },
    checkoutPreferences: { 
        redirectUrls: {  
                urlSuccess: 'http://www.yourecommerce.com.br/success',
                urlFailure: 'http://www.yourecommerce.com.br/error'
          },
        installments: [  
                {  
                    quantity: [2,2],
                    addition: 1000
                }
        ]
    }
}).then((response) => {
    console.log(response.body)
}).catch((err) => {
    console.log(err)
})
var body = new OrderRequest
{
    OwnId = "order_unique_id",
    Amount = new Amount
    {
        Currency = "BRL",
        Subtotals = new Subtotals
        {
            Shipping = 1000
        }
    },
    Items = new List<Item>
    {
        new Item
        {
            Product = "Product name",
            Category = "VIDEO_GAME_SOFTWARE",
            Quantity = 1,
            Detail = "Product detail",
            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":"order_unique_id",
   "amount":{  
      "currency":"BRL",
      "subtotals":{  
         "shipping":1500
      }
   },
   "items":[  
      {  
         "product":"Product name",
         "category":"APPAREL_AND_ACCESSORIES",
         "subcategory":"CLOTHING",
         "quantity":1,
         "detail":"Product detail",
         "price":9500
      }
   ],
  "customer": {
    "ownId": "customer_unique_id",
    "fullname": "Customer Full Name",
    "email": "[email protected]",
    "birthDate": "1980-05-15",
    "taxDocument": {
      "type": "CPF",
      "number": "57390209674"
    },
    "phone": {
      "countryCode": "55",
      "areaCode": "11",
      "number": "88763546"
    },
    "shippingAddress": {
      "street": "Avenida 23 de Maio",
      "streetNumber": 654,
      "complement": 12,
      "district": "Centro",
      "city": "Sao Paulo",
      "state": "SP",
      "country": "BRA",
      "zipCode": "01244500"
    }
  }
}
#
# This example is based in our SDK developed in Ruby, available
# on: https://github.com/wirecardBrasil/moip-sdk-ruby
#

order = api.order.create({  
  ownId: 'order_unique_id', 
   amount: {  
      currency: 'BRL', 
      subtotals: {  
         shipping: 1500
      }
   },
   items: [  
      {  
        product: 'Product name', 
         category: 'APPAREL_AND_ACCESSORIES', 
         subcategory: 'CLOTHING', 
         quantity: 1,
        detail: 'Product detail', 
         price: 9500
      }
   ],
  customer: {
    ownId: 'customer_unique_id', 
    fullname: 'Customer Full Name', 
    email: '[email protected]', 
    birthDate: '1980-05-15', 
    taxDocument: {
      type: 'CPF', 
      number: '57390209674'
    },
    phone: {
      countryCode: '55', 
      areaCode: '11', 
      number: '88763546'
    },
    shippingAddress: {
      street: 'Avenida 23 de Maio', 
      streetNumber: 654,
      complement: 12,
      district: 'Centro', 
      city: 'Sao Paulo', 
      state: 'SP', 
      country: 'BRA', 
      zipCode: '01244500'
    }
  }
 })
/**
* 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 name"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Product detail"),
    value("price", 100000000)
);

Map<String, Object> product2 = payloadFactory(
    value("product", "Product name"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Product detail"),
    value("price", 100000000)
);

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_unique_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_unique_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("order_unique_id")
    ->addItem("Product name",1, "Product detail", 9500)
    ->setShippingAmount(1500)->setAddition(0)->setDiscount(0)
    ->setCustomer($moip->customers()->setOwnId("customer_unique_id")
        ->setFullname("Customer Full Name")
        ->setEmail("[email protected]")
        ->setBirthDate("1980-05-15")
        ->setTaxDocument("57390209674")
        ->setPhone(11, 88763546)
        ->addAddress("SHIPPING",
            "Avenida 23 de Maio", 654,
            "Centro", "Sao Paulo", "SP",
            "01244500", 12))
    ->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: 'order_unique_id',
    amount: {
        currency: 'BRL',
        subtotals: {
            shipping: 1000
        }
    },
    items: [{
        product: 'Product name',
        quantity: 1,
        detail: 'Product detail',
        price: 1000
    }],
    customer: {
          ownId: 'customer_unique_id',
        fullname: 'Customer Full Name',
        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'
        }
    }
}).then((response) => {
    console.log(response.body)
}).catch((err) => {
    console.log(err)
})
var body = new OrderRequest
{
    OwnId = "order_unique_id",
    Amount = new Amount
    {
        Currency = "BRL",
        Subtotals = new Subtotals
        {
            Shipping = 1000
        }
    },
    Items = new List<Item>
    {
        new Item
        {
            Product = "Product name",
            Category = "VIDEO_GAME_SOFTWARE",
            Quantity = 1,
            Detail = "Product detail",
            Price = 22000
        }
    },
    Customer = new Customer
    {
        OwnId = "customer_unique_id",
        FullName = "Customer Full Name",
        Email = "[email protected]",
        BirthDate = "1980-5-10",
        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":"order_unique_id",
   "amount":{  
      "currency":"BRL",
      "subtotals":{  
         "shipping":1500
      }
   },
   "items":[  
      {  
         "product":"Product name",
         "category":"APPAREL_AND_ACCESSORIES",
         "subcategory":"CLOTHING",
         "quantity":1,
         "detail":"Product detail",
         "price":9500
      }
   ],
  "customer": {
    "id": "CUS-OQSQ7IWL229E"
  }
}
#
# This example is based in our SDK developed in Ruby, available
# on: https://github.com/wirecardBrasil/moip-sdk-ruby
#

order = api.order.create({  
  ownId: 'order_unique_id', 
   amount: {  
      currency: 'BRL', 
      subtotals: {  
         shipping: 1500
      }
   },
   items: [  
      {  
        product: 'Product name', 
         category: 'APPAREL_AND_ACCESSORIES', 
         subcategory: 'CLOTHING', 
         quantity: 1,
        detail: 'Product detail', 
         price: 9500
      }
   ],
  customer: {
    id: 'CUS-OQSQ7IWL229E'
  }
 })
/**
* 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 name"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Product detail"),
    value("price", 100000000)
);

Map<String, Object> product2 = payloadFactory(
    value("product", "Product name"),
    value("category", "TOYS_AND_GAMES"),
    value("quantity", 2),
    value("detail", "Product detail"),
    value("price", 100000000)
);

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

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_unique_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("order_unique_id")
    ->addItem("Product name",1, "Product detail", 9500)
        ->setShippingAmount(1500)->setAddition(0)->setDiscount(0)
        ->setCustomerId("CUS-87HFA3QCEKO7")
        ->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: 'order_unique_id',
    amount: {
        currency: 'BRL',
        subtotals: {
            shipping: 1000
        }
    },
    items: [{
        product: 'Product name',
        quantity: 1,
        detail: 'Product detail',
        price: 1000
    }],
    customer: {
        id: 'CUS-OQSQ7IWL229E'
    }
}).then((response) => {
    console.log(response.body)
}).catch((err) => {
    console.log(err)
})
var body = new OrderRequest
{
    OwnId = "order_unique_id",
    Amount = new Amount
    {
        Currency = "BRL",
        Subtotals = new Subtotals
        {
            Shipping = 1000
        }
    },
    Items = new List<Item>
    {
        new Item
        {
            Product = "Product name",
            Category = "VIDEO_GAME_SOFTWARE",
            Quantity = 1,
            Detail = "Product detail",
            Price = 22000
        }
    },
    Customer = new Customer
    {
        Id = "CUS-7AKU0VORZ2D4"
    }
};
var result = await WC.Order.Create(body);