Testing Refunds

Testing Refund Notifications

1. Choose a test payment for which you want to create a test refund.

A payment needs to be in status delivered before you can create a refund for it (see Payment Statuses for details about payment statuses).

Where do I find a test payment that is in status delivered?

  • If you already have test payments and need a list of all payments available to you, see Getting a List of all Payments.

  • If you are using self-managed recurring payments and want to create a test payment specifically for this test, you can create a card or direct debit payment and move it into delivered.

  • If you are using 529 Payments, you can also move a test payment into delivered.

2. Create a refund for the payment using magic values.

Use the following parameters:

amount integer

Any amount lower or exactly like the original payment amount.

external_reference string

Depends on which status you want to move the refund to:

Move Refund to Status...external_reference

Received

#SANDBOX_TO_RECEIVED_STATUS

Finished

#SANDBOX_TO_FINISHED_STATUS

notifications_url string (url)

A URL where you can receive callbacks to test the notifications.

Since you are testing status notifications, make sure to provide a notifications URL where you can receive the notifications via callbacks.
https://api-platform-sandbox.flywire.com/payments/v1/FWU125675432/refunds
  -X POST
  -H "Content-Type: application/json"
  -H "X-Authentication-Key: {api_key}"
  -d '{
		“amount”: 10000,
		“external_reference”: “My test refund#SANDBOX_TO_RECEIVED_STATUS”,
		“notifications_url”: “https://webhooks/notifications/refunds”
}

3. Check the notifications.

You created a refund which automatically also created a refund bundle. You'll receive the following notifications:

Refund initiated

Refund bundle pending

4. Make the bundle reach the cut-off time.

The refunds won't move forward in the process yet, since the refund bundle must reach its cut-off time first.

You could just wait until the cut-off time is reached, but you probably want to use a magic value to fast forward time and make the bundle reach the cut-off time immediately. To do this, create a new refund with the cut-off time magic value for the same recipient of the first refund. This ensures that the new refund will be added to the bundle that contains the first refund.

You can find out who the recipient of the first refund is by checking the payment details of the payment you created the refund for, see Getting Details about a Payment.

Use the following parameters:

amount integer

Any amount lower or exactly like the original payment amount.

external_reference string

Must be #SANDBOX_CUT_OFF_REACHED

notifications_url string (url)

A URL where you can receive callbacks to test the notifications.

Since you are testing status notifications, make sure to provide a notifications URL where you can receive the notifications via callbacks.
https://api-platform-sandbox.flywire.com/payments/v1/FWU125675432/refunds
	-X POST
	-H "Content-Type: application/json"
	-H "X-Authentication-Key: {api_key}"
	-d '{
		“amount”: 10000,
		“external_reference”: “My test refund to reach the cut-off time#SANDBOX_CUT_OFF_REACHED”,
		“notifications_url”: “https://webhooks/notifications/refunds”
		}

5. Check the notifications.

Now that the bundle has reached the cut-off time you'll receive the following notifications:

Refund bundle pending - marked for approval (Only for manual approvals. For automatic approvals, no notification is sent.)

6. Approve the bundle if needed.

Depending on the settings for the recipient of the refund, the approval either happens automatically or you have to manually approve it.

If you are not sure if you need to approve the bundle manually, check the approval settings for the recipient, see Recipients - Refunds: Cut-off time and Approval.

7. Check the notifications.

Now that the bundle is approved you'll receive the following notifications:

Refund bundle approved

Within 5 minutes, the refund will move into the status you chose and you'll get more notifications:

Refund received

Refund bundle received

This is the end of this scenario.

If there are more refunds in the bundle, all refunds in the bundle will change their status from initiated to received.

Refund received

Refund bundle received

Refund finished

Payment reversed

This is the end of this scenario.

Only the refund you created will change its status from received to finished.
If there are other refunds in the bundle, they will change their status to received.