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

Refunds

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

Refund payment

Authorization able
Basic Auth
OAuth

Refund to credit card

Map<String, Object> newRefund = Moip.API.refunds().refundPayment("payment_id", setup);

Refund to bank account

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

Map<String, Object> holder = payloadFactory(
    value("fullname", "Jose Silva"),
    value("taxDocument", taxDocument)
);

Map<String, Object> bankAccount = payloadFactory(
    value("type", "CHECKING"),
    value("bankNumber", "001"),
    value("agencyNumber", 4444444),
    value("agencyCheckNumber", 2),
    value("accountNumber", 1234),
    value("accountCheckNumber", 1),
    value("holder", holder)
);

Map<String, Object> refundingInstrument = payloadFactory(
    value("method", "BANK_ACCOUNT"),
    value("bankAccount", bankAccount)
);

Map<String, Object> refundBankAccount = payloadFactory(
    value("refundingInstrument", refundingInstrument)
);

Map<String, Object> newRefund = Moip.API.refunds().refundPayment(refundBankAccount, "payment_id", setup);

Refund to Moip account

Map<String, Object> moipAccount = payloadFactory(
    value("id", "moip_account_id")
);

Map<String, Object> refundingInstrument = payloadFactory(
    value("method", "MOIP_ACCOUNT"),
    value("moipAccount", moipAccount)
);

Map<String, Object> refundMoipAccount = payloadFactory(
    value("amount", "500"),
    value("refundingInstrument", refundingInstrument)
);

Map<String, Object> newRefund = Moip.API.refunds().refundPayment(refundMoipAccount, "payment_id", setup);

Refund order

Authorization able
Basic Auth
OAuth

Refund to credit card

Map<String, Object> newRefund = Moip.API.refunds().refundOrder("order_id", setup);

Refund to bank account

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

Map<String, Object> holder = payloadFactory(
    value("fullname", "Jose Silva"),
    value("taxDocument", taxDocument)
);

Map<String, Object> bankAccount = payloadFactory(
    value("type", "CHECKING"),
    value("bankNumber", "001"),
    value("agencyNumber", 4444444),
    value("agencyCheckNumber", 2),
    value("accountNumber", 1234),
    value("accountCheckNumber", 1),
    value("holder", holder)
);

Map<String, Object> refundingInstrument = payloadFactory(
    value("method", "BANK_ACCOUNT"),
    value("bankAccount", bankAccount)
);

Map<String, Object> refundBankAccount = payloadFactory(
    value("refundingInstrument", refundingInstrument)
);

Map<String, Object> newRefund = Moip.API.refunds().refundOrder(refundBankAccount, "order_id", setup);

Refund to Moip account

Map<String, Object> moipAccount = payloadFactory(
    value("id", "moip_account_id")
);

Map<String, Object> refundingInstrument = payloadFactory(
    value("method", "MOIP_ACCOUNT"),
    value("moipAccount", moipAccount)
);

Map<String, Object> refundMoipAccount = payloadFactory(
    value("amount", "500"),
    value("refundingInstrument", refundingInstrument)
);

Map<String, Object> newRefund = Moip.API.refunds().refundOrder(refundMoipAccount, "order_id", setup);

Get refund

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

List refunds of a payment

Authorization able
Basic Auth
OAuth
Map<String, Object> listPaymentRefundResponse = Moip.API.refunds().listPaymentRefunds("payment_id", setup);

List refund of a order

Authorization able
Basic Auth
OAuth
Map<String, Object> listOrderRefundsResponse = Moip.API.refunds().listOrderRefunds("order_id", setup);