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

Multipayments

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

Introduction

TO DO

Dependencies

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

Features

Index

Create multipayment

Authorization able
Basic Auth
OAuth

Pay with credit card

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

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

Map<String, Object> holder = payloadFactory(
    value("fullname", "Portador Teste Moip"),
    value("birthdate", "1988-12-30"),
    value("taxDocument", taxDocument),
    value("phone", phone)
);

Map<String, Object> creditCard = payloadFactory(
    value("number", 5555666677778884),
    value("cvc", 123),
    value("expirationMonth", 12),
    value("expirationYear", 24),
    value("holder", holder)
);

Map<String, Object> fundingInstrument = payloadFactory(
    value("method", "CREDIT_CARD"),
    value("creditCard", creditCard)
);

Map<String, Object> multipayment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newMultipay = Moip.API.multiorders().pay(multipayment, "multiorder_id", setup);

Pay with credit card hash

The Credit Card Hash is an encrypted version of the credit card. This encryption must occur on the front-end using our Javascript Encryption SDK.

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

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

Map<String, Object> holder = payloadFactory(
    value("fullname", "Portador Teste Moip"),
    value("birthdate", "1988-12-30"),
    value("taxDocument", taxDocument),
    value("phone", phone)
);

Map<String, Object> creditCard = payloadFactory(
    value("hash", "CREDIT_CARD_HASH"),
    value("holder", holder)
);

Map<String, Object> fundingInstrument = payloadFactory(
    value("method", "CREDIT_CARD"),
    value("creditCard", creditCard)
);

Map<String, Object> multipayment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newMultipay = Moip.API.multiorders().pay(multipayment, "multiorder_id", setup);

Pay with boleto

Map<String, Object> instructionLines = payloadFactory(
    value("first", "First instruction line!"),
    value("second", "Second instruction line!"),
    value("third", "Third instruction line!")
)

Map<String, Object> boleto = payloadFactory(
    value("expirationDate", "2020-06-20"),
    value("instructionLines", instructionLines),
    value("logoUri", "http://www.lojaexemplo.com.br/logo.jpg")
);

Map<String, Object> fundingInstrument = payloadFactory(
    value("method", "BOLETO");
    value("boleto", boleto);
);

Map<String, Object> multipayment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newMultipay = Moip.API.multiorders().pay(multipayment, "multiorder_id", setup);

Pay with online bank debit

Map<String, Object> onlineBankDebit = payloadFactory(
    value("bankNumber", 341),
    value("expirationDate", "2017-11-22")
);

Map<String, Object> fundingInstrument = payloadFactory(
    value("method", "ONLINE_BANK_DEBIT"),
    value("onlineBankDebit", onlineBankDebit)
);

Map<String, Object> multipayment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newMultpay = Moip.API.multiorders().pay(multipayment, "multiorder_id", setup);

Create pre-authorized multipayment

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

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

Map<String, Object> holder = payloadFactory(
    value("fullname", "Portador Teste Moip"),
    value("birthdate", "1988-12-30"),
    value("taxDocument", taxDocument),
    value("phone", phone)
);

Map<String, Object> creditCard = payloadFactory(
    value("hash", "CREDIT_CARD_HASH"),
    value("holder", holder)
);

Map<String, Object> fundingInstrument = payloadFactory(
    value("method", "CREDIT_CARD"),
    value("creditCard", creditCard)
);

Map<String, Object> multipayment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("delayCapture", true),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newMultipay = Moip.API.multiorders().pay(multipayment, "multiorder_id", setup);

Capture pre-authorized multipayment

Authorization able
Basic Auth
OAuth
Map<String, Object> newCapture = Moip.API.multipayments().capturePreAuthorized("pre_authorized_multipayment_id", setup);

Cancel pre-authorized multipayment

Authorization able
Basic Auth
OAuth
Map<String, Object> newCancel = Moip.API.multipayments().cancelPreAuthorized("pre_authorized_multipayment_id", setup);

Get multipayment

Authorization able
Basic Auth
OAuth
Map<String, Object> getResponse = Moip.API.multipayments().get("multipayment_id", setup);