Code
31
SDK error · code 31
What it means
beginRefundRequestError (code 31) means the iOS in-app refund request could not start: the SDK found no verified transaction for the product, the entitlement is missing or ambiguous, customer info failed to load, or StoreKit refused the request. Pass the right entitlement ID, make sure the customer owns a verified purchase, and read the message for the exact reason.
Code
31
iOS (Swift)
ErrorCode.begin
Android (Kotlin)
No matching code in the Android SDK; see the causes below.
Causes
RefundRequestError, such as a duplicate request or a failure.Fix
Call beginRefundRequest(forEntitlement:) with the ID of the entitlement you mean. beginRefundRequestForActiveEntitlement() needs exactly one active entitlement.
The customer must be signed in to the account that bought, with a verified transaction. See Transaction.beginRefundRequest-63bvd).
Make sure getCustomerInfo succeeds, because the SDK reads the product from it.
A second request for the same transaction can fail as a duplicate. Disable the button after the first tap.
In your app
// Swift
do {
let result = try await Purchases.shared.purchase(package: package)
} catch let error as ErrorCode where error == .beginRefundRequestError {
// handle begin refund request error
} On RevenueDot: The SDK reads the entitlement and its product from the customer info RevenueDot serves, so a customer info that lacks the entitlement produces this error. The refund sheet itself is Apple's. See Why is my entitlement not active?.
FAQ
The iOS refund request could not start. The message says why: no matching entitlement, several active entitlements, no verified transaction, or a StoreKit refusal.
No. The request goes to Apple. Access changes only when the refund is granted, and the store then reports it to your server.
In React Native, compare error.code with PURCHASES_ERROR_CODE.BEGIN_REFUND_REQUEST_ERROR. In Flutter, convert the PlatformException with PurchasesErrorHelper.getErrorCode(e) and compare the result with PurchasesErrorCode.beginRefundRequestError.
Get started
RevenueDot answers the same SDK calls with the same error codes. Start free on RevenueDot Cloud, free up to $10,000 a month in tracked revenue.
Already have an account? Sign in · Prefer your own servers? Self-host free