# Refunds
source: https://developer.mastercard.com/ob-accept-payments/documentation/use-cases/refunds/index.md

Our Refund APIs enable the Merchant through the Integrator to initiate a refund request and retrieve the PSU's source account details, which can be used to initiate a refund outside of Mastercard Open Finance Pay. In cases where you have signed up for a Mastercard Settlement Account, then Mastercard can execute the Refund within Mastercard Open Finance Pay.

### Provide the source account details required to initiate a refund {#provide-the-source-account-details-required-to-initiate-a-refund}

Fetch the PSU's source account details which can then be used to initiate a refund towards the PSU.
Note: We depend on the ASPSPs to provide us with the details of the Source Account the PSU selected during the payment flow. This does not happen reliably in all markets. Where possible, we provide alternative ways for capturing the PSU account through an AIS (Account Information Service) flow. Please find more details on this in the steps below.

#### Flow to Fetch the PSU's account details when the ASPSP returned them to Mastercard Open Finance Pay during payment initiation: {#flow-to-fetch-the-psus-account-details-when-the-aspsp-returned-them-to-mastercard-open-finance-pay-during-payment-initiation}

Diagram fetch-psu-ac-details

1. The Consumer / Payment Service User (PSU) initiates a refund request from the Merchant's application.
2. The merchant passes the refund request to the Integrator.
3. The Integrator uses the /payments/{payment_id}/refunds endpoint to submit a Create Payment Refund request.
4. Mastercard Open Finance Pay responds to the Integrator with the Refund ID.
5. The Integrator uses the /refunds/{refund_id} to check the status of the refund. If the status returned is SOURCE_ACCOUNT_AVAILABLE, then the PSUs source account details were captured during the initial payment initiation.
6. Mastercard Open Finance Pay responds to the Integrator with the latest refund status.
7. The Integrator uses the /refunds/{refund_id}/payment-rails endpoint to submit a to fetch the PSU's source account details.
8. Mastercard Open Finance Pay responds to the Integrator with the source account details that were captured during the payment initiation.
9. The Integrator or the Merchant refund the PSU using the source account details that were captured during the payment initiation.

#### Flow to fetch the PSU's account details when the ASPSP has not returned them to Mastercard Open Finance Pay during payment initiation: {#flow-to-fetch-the-psus-account-details-when-the-aspsp-has-not-returned-them-to-mastercard-open-finance-pay-during-payment-initiation}

Diagram fetch_psu_details_not_returned

1. The Consumer / Payment Service User (PSU) initiates a refund request from the Merchant's application.
2. The Merchant passes the refund request to the Integrator.
3. The Integrator uses the /payments/{payment_id}/refunds endpoint to submit a Create Payment Refund request.
4. Mastercard Open Finance Pay responds to the Integrator with the Refund ID.
5. The Integrator uses the /refunds/{refund_id} to check the status of the refund. If the status returned is 6. SOURCE_ACCOUNT_UNAVAILABLE, then the PSU's source account details were not captured during the initial payment initiation.
6. Mastercard Open Finance Pay responds to the Integrator with the latest refund status.
7. The Integrator uses the /refunds/{refund_id}/payment-rails endpoint to submit a Collect refund source account request to initiate an AIS flow to collect the PSU's source account details.
8. Mastercard Open Finance Pay responds to the Integrator with flowURL that will be used to initiate the AIS flow.
9. The Integrator or Merchant redirects the PSU to the flowURL where the PSU will complete an AIS journey and Mastercard Open Finance Pay will capture the PSUs source account details.
10. The Integrator uses the /refunds/{refund_id} to check the status of the refund. If the status returned is SOURCE_ACCOUNT_AVAILABLE, then the PSU's source account details were captured during the AIS journey.
11. Mastercard Open Finance Pay responds to the Integrator with the latest refund status.
12. The Integrator uses the /refunds/{refund_id}/payment-rails endpoint to fetch the PSU's source account details.
13. Mastercard Open Finance Pay responds to the Integrator with the source account details that were captured during the AIS journey.
14. The Integrator or the Merchant refund the PSU using the source account details that were captured during the AIS journey.

### Flow to refund the PSU using a Mastercard Settlement Account: {#flow-to-refund-the-psu-using-a-mastercard-settlement-account}

Diagram refund_psu

1. The Consumer / Payment Service User (PSU) initiates a refund request from the Merchant's application.
2. The Merchant passes the refund request to the Integrator.
3. The Integrator uses the /payments/{payment_id}/refunds endpoint to submit a Create Payment Refund request.
4. Mastercard Open Finance Pay responds to the Integrator with the Refund ID.
5. The Integrator uses the /refunds/{refund_id} to check the status of the refund. If the status returned is PENDING or PREPARING, then it is a Mastercard Settlement Account refund and Mastercard Open Finance Pay will execute the refund.
6. Mastercard Open Finance Pay responds to the Integrator with the latest refund status.
7. Mastercard Open Finance Pay execute a refund from the Mastercard Settlement Account to the PSU's bank account.
8. The Integrator uses the /refunds/{refund_id} to check the status of the refund.
9. Mastercard Open Finance Pay responds to the Integrator with the latest refund status. If the status returned is PAYMENT_EXECUTED_DEBITED, then the refund has been executed.
10. The integrator informs the Merchant that the refund is complete.
11. The Merchant informs the PSU that the refund is complete.

### Endpoints used {#endpoints-used}

A Create payment refund request is initiated (Link to refund API Reference). You will need to use the payment_id in the path.

API Reference: `POST /payments/{payment_id}/refunds`

The updated status of the refund is retrieved using the Get refund endpoint (Link to refund API Reference). The refund_id (you received in the create payment refund response) is required to fetch the refund status.

API Reference: `GET /refunds/{refund_id}`

The PSU source account details are retrieved using the Get refund payment rails endpoint (Link to refund API Reference). The refund_id (you received in the create payment refund response) is required to fetch the refund status.

API Reference: `GET /refunds/{refund_id}/payment-rails`

The AIS journey to collect a PSU's source account details is initiated using the Collect refund source account endpoint (Link to refund API Reference). The refund_id (you received in the create payment refund response) is required in the path.

API Reference: `POST /refunds/{refund_id}/payment-rails`

### Error handling {#error-handling}

Refer to the [Codes and Formats](https://developer.mastercard.com/ob-accept-payments/documentation/developer-support/code-and-formats/index.md) for information related to handling errors.
