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

Payments

somentelucas edited this page Aug 29, 2018 · 16 revisions

Introduction

The payment is a financial transaction that occurs between the customer and the receiver (it means, probably you).

Dependencies

TO DO

Features

Index

Create payment

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> payment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newPay = Moip.API.payments().pay(payment, "order_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> payment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newPay = Moip.API.payments().pay(payment, "order_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> payment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newPay = Moip.API.payments().pay(payment, "order_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> payment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newPay = Moip.API.payments().pay(payment, "order_id", setup);

Create pre-authorized payment

Authorization able
Basic Auth
OAuth
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> payment = payloadFactory(
    value("installmentCount", 1),
    value("statementDescriptor", "minhaLoja.com"),
    value("delayCapture", true),
    value("fundingInstrument", fundingInstrument)
);

Map<String, Object> newPreAuthorizedPayment = Moip.API.payments().pay(payment, "order_id", setup);

Capture pre-authorized payment

Authorization able
Basic Auth
OAuth
Map<String, Object> newConvertion = Moip.API.payments().capturePreAuthorized("pre_authorized_payment_id", setup);

Cancel pre-authorized payment

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

Get payment

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

Authorize payment in Sandbox

Authorization able
Basic Auth
OAuth
Map<String, Object> newAuthorize = Moip.API.payments().authorize("payment_id", 9500, setup);
Clone this wiki locally