# Installment Refunds

This object represents refunds. Various situations require full or partial refunds of a loan. Depending on the refund
amount and whether the borrower has made payments, a refund may also trigger a reimbursement to the borrower.


## Get refunds

 - [GET /people/{personId}/loans/{loanId}/refunds](https://docs.peachfinance.com/api-docs/api-public/installment-refunds/peach.people.loans.handlers.loan_refunds_get.md): Returns a list of all prior refunds for the loan, as well as the remaining eligible refund amount.

## Create refund

 - [POST /people/{personId}/loans/{loanId}/refunds](https://docs.peachfinance.com/api-docs/api-public/installment-refunds/peach.people.loans.handlers.loan_refunds_post.md): The refund endpoint will execute a full or partial refund according to the refundAmount specified.
A full refund is equal to the amountFinancedAtOrigination. An atFaultParty must also be specified,
in order to trigger the corresponding accounting entries related to billing for the refund.

## Create refund v2

 - [POST /people/{personId}/loans/{loanId}/refunds-v2](https://docs.peachfinance.com/api-docs/api-public/installment-refunds/peach.people.loans.handlers.loan_refunds_v2_post.md): The refund endpoint will execute a full or partial refund according to the refundAmount specified.
The total of all refunds cannot exceed the amountFinanced (or principalAmount)  passed at origination.

A refund is applied in the following way:
- The system first depletes any non-due principal.
  This amount will be stored as refundDetails.refundNonDuePrincipalAmount.
- If any refund amount is left to apply, the system will create a transaction of type service credit and serviceCreditType=refund.
  This transaction will be applied on the loan using the "payment waterfall".
  This amount will be stored as refundDetails.refundTransactionAmount.
- After the system applies the serviceCreditType=refund, if there is any remaining unapplied
  refund amount, it will be recorded as credit to the borrower (also called reimbursementAmount or amount owed to borrower.)
- The system will replay the loan from the refundDate.

Please consider the following before creating refunds:

- If you want to fully refund the loan including interest and fees, pass the following:
  - refundDate equals the activation date.
  - refundAmount equals the amount financed.
  - isRefundOriginationFees, isRefundLateFees and isRefundOtherFees set to true.
  - isRefundMDR and isRefundDownPayment - set these attributes depending on your policy.
- If you want to partially refund the loan with prorated interest and/or fees, set the following. Prorated interest means
  the system will lower the principal from the activation date and re-accrue interest.
  - refundDate equals the activation date.
  - refundAmount equals a partial refund amount.
  - isRefundOriginationFees, isRefundLateFees and isRefundOtherFees - set these values depending on your policy.
  - isRefundMDR - set this attribute depending on your policy.
  - isRefundDownPayment - set to false. To remind: this attribute can be true only for a full refund.
- If you want to partially refund the loan without prorating interest and/or fees prior the refund date, set the following:
  - refundDate equals an effective date of the refund (or keep empty to indicate "today").
  - refundAmount equals a partial refund amount.
  - isRefundOriginationFees, isRefundLateFees and isRefundOtherFees set to false.
  - isRefundMDR - set to false. To remind: this attribute can be true only if refundDate equals the activation date.
  - isRefundDownPayment - set to false. To remind: this attribute can be true only for a full refund.

## Cancel refund

 - [POST /people/{personId}/loans/{loanId}/refunds/{loanRefundId}/cancel](https://docs.peachfinance.com/api-docs/api-public/installment-refunds/peach.people.loans.handlers.loan_refunds_cancel.md): Cancel a refund.

