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

Multiorders

somentelucas edited this page Sep 3, 2018 · 7 revisions

Introduction

TO DO

Dependencies

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

Features

Index

Create multiorder

Authorization able
Basic Auth
OAuth
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> moipAccount1 = payloadFactory(
    value("id", "MPA-VB5OGTVPCI52")
);

Map<String, Object> receiver1 = payloadFactory(
    value("moipAccount", moipAccount1),
    value("type", "PRIMARY")
);

List receivers = new ArrayList();
receivers.add(receiver1);

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

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

List orders = new ArrayList();
orders.add(order1);

Map<String, Object> multiorder = payloadFactory(
    value("ownId", "multiorder_own_id")
    value("orders", orders)
);

Map<String, Object> responseCreation = Moip.API.multiorders().create(multiorder, setup);

Get multiorder

Authorization able
Basic Auth
OAuth
Map<String, Object> responseGet = Moip.API.multiorders().get("multiorder_id", setup);
Clone this wiki locally