# Transactions

This object represents payments and credits. Payments represent real money that were paid back by borrowers. Credits
are adjustments made on a loan. Credits lower balances similar to payments. Credits can be issued by customer service
representatives or supervisors.


## Get transactions

 - [GET /people/{personId}/loans/{loanId}/transactions](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.loan_transactions_get_all.md)

## Create transaction

 - [POST /people/{personId}/loans/{loanId}/transactions](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transactions_create.md): Create a transaction. Permissions required depend on the object type passed:

| type             | permission                            |
|------------------|---------------------------------------|
| One Time Payment | transaction:create.onetimepayment   |
| Service Credit   | transaction:create.servicecredit    |
| Down Payment     | transaction:create.downpayment      |

Once a loan has been onboarded to Peach's platform, valid loan statuses for each transaction type are as follows:

| type             | valid loan statuses                       |
|------------------|-------------------------------------------|
| One Time Payment | active, accelerated, or chargedOff* |
| Service Credit   | active, accelerated, or chargedOff* |
| Down Payment     | active                                  |

*=chargedOff is only valid when the loan type configuration paymentAllowedWhenChargedOff is true.

During migration while a loan is in prepMigration, valid loan statuses for each transaction type are as follows:

| type             | valid loan statuses                      |
|------------------|------------------------------------------|
| One Time Payment | originated                             |
| Service Credit   | originated                             |
| Down Payment     | active                                 |

## Fail multiple transactions

 - [POST /people/{personId}/loans/{loanId}/transactions/fail](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transactions_fail_multiple.md): This endpoint allows you to fail multiple transactions in one call. The system will mark applicable transactions as 
failed and replay the loan once (starting from the earliest effective date of the provided transactions).

## Get transaction by ID

 - [GET /people/{personId}/loans/{loanId}/transactions/{transactionId}](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transactions_get_by_id.md)

## Update transaction

 - [PUT /people/{personId}/loans/{loanId}/transactions/{transactionId}](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transactions_update.md)

## Backdate transaction

 - [POST /people/{personId}/loans/{loanId}/transactions/{transactionId}/backdate](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transaction_backdate.md): Backdate a transaction. Can only be applied to transactions with status=succeeded or status=pending. Can be applied to payments or service credits.

## Cancel transaction

 - [POST /people/{personId}/loans/{loanId}/transactions/{transactionId}/cancel](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transaction_cancel.md)

## Get transaction chargebacks

 - [GET /people/{personId}/loans/{loanId}/transactions/{transactionId}/chargebacks](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.chargebacks.handlers.get_chargebacks.md)

## Create transaction chargeback

 - [POST /people/{personId}/loans/{loanId}/transactions/{transactionId}/chargebacks](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.chargebacks.handlers.transaction_chargeback.md): In some cases a borrower might chargeback/dispute a payment that they made in the past. Only transactions in succeeded status can be charged back.

If the payment/transaction isExternal=true, the caller can post chargeback in two ways:
 1. Update status of the transaction to inDispute or chargeback directly. The chargeback amount defaults to the full amount of the transaction.
    The system will create a chargeback object automatically. This option is the easiest way to tell the system about a chargeback.
 1. Create chargeback(s) via Create transaction chargeback endpoint. This option allows the caller to provide more details about the chargeback.
    This option should be used for multiple partial chargebacks. Keep in mind that a transaction can have multiple chargebacks and reversals.

It's important to not mix the options above because it can create edge cases and confusion.

If the payment/transaction is isExternal=false, the caller cannot change the transaction status to inDispute or chargeback nor create chargeback(s)
via Create transaction chargeback endpoint. Chargebacks will be received directly from the payment processor.

## Get chargeback by ID

 - [GET /people/{personId}/loans/{loanId}/transactions/{transactionId}/chargebacks/{chargebackId}](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.chargebacks.handlers.get_chargeback_by_id.md)

## Update chargeback

 - [PUT /people/{personId}/loans/{loanId}/transactions/{transactionId}/chargebacks/{chargebackId}](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.chargebacks.handlers.update_chargeback.md)

## Reverse transaction

 - [POST /people/{personId}/loans/{loanId}/transactions/{transactionId}/reverse](https://docs.peachfinance.com/api-docs/api-public/transactions/peach.transactions.handlers.transaction_reverse.md)

