Testing refund requests
Test your app’s implementation of refund requests, and your app’s and server’s handling of approved and declined refunds.
Overview
The sandbox environment and StoreKit Testing in Xcode both support testing refund requests, which enable your customers to request a refund from within your app. Your app displays the refund request sheet by calling any of these methods: beginRefundRequest(for:in:) , beginRefundRequest(in:), beginRefundRequest(for:in:), beginRefundRequest(in:), or refundRequestSheet(for:isPresented:onDismiss:). While you’re testing your app, you fill out the sheet to submit the request.
Depending on your testing setup, the App Store automatically approves or declines the refund request in the testing environment. Note that the App Store doesn’t send emails for refund requests in testing environments.
Test approved refunds
To set up a test for approved refunds, select any refund reason on the refund request sheet, and submit the sheet. The App Store automatically approves the refund request in the testing environment.
Your app receives a Transaction with refund information in the revocationDate and revocationReason properties. If you’re testing in the sandbox environment and your server receives App Store Server Notifications V2 for the sandbox, it gets a notification with a REFUND notificationType.
Test declined refunds
To set up a test for declined refunds, follow these steps on the refund request sheet with your app running in the sandbox environment:
Under Issue, select Other.
In the text box, type DECLINE.
Tap Request Refund.
The App Store automatically rejects the refund request in the testing environment.
If your server receives App Store Server Notifications V2 for the sandbox environment, it gets a notification with a REFUND_DECLINED notificationType.
Test prorated refunds
To set up a test for prorated refunds, follow these steps on the refund request sheet with your app running in the sandbox environment:
Under Issue, select Other.
In the text box, type GRANT_PRORATED.
Tap Request Refund.
The testing environment determines the prorated percentages as follows:
For auto-renewable subscriptions, it calculates the proration based on the time that remains on the subscription
For consumables, non-consumables, and non-renewing subscriptions, it uses a default proration of 50%
In the testing environment, the App Store automatically approves the prorated refund.
Your app receives a Transaction with refund information in the revocationDate and revocationReason properties. If you’re testing in the sandbox environment and your server receives App Store Server Notifications V2 for the sandbox, it gets a notification with a REFUND notificationType. For prorated refunds, the transaction data includes the revocationType field with a value of REFUND_PRORATED and the revocationPercentage field.
Test prorated refunds with information from your server
Another way to test prorated refunds is to provide the refund information by calling the Send Consumption Information, following these steps:
In your app, select any refund reason on the refund request sheet, and submit the sheet.
The App Store server sends a
CONSUMPTION_REQUESTnotification to your App Store Server Notifications V2 for the sandbox environment.Respond by calling Send Consumption Information. Note that in the sandbox environment you need to respond to the notification within five minutes for the system to apply your consumption information to the refund request.
The values you provide in the ConsumptionRequest determine the outcome of the refund in the testing environment:
Specify the
GRANT_PRORATEDvalue as the refund preference to get a prorated refundSpecify a valid
consumptionPercentage. The testing environment approves the prorated refund using your consumption percentage.
For more information on receiving server notifications for the sandbox environment, see Enabling App Store Server Notifications. For more information on testing, see Testing at all stages of development with Xcode and the sandbox and Setting up StoreKit Testing in Xcode.