Skip to main content

VALIDATION

Purchase validation - iOS

Each purchase should be validated before awarding it to the end-user. This assists in preventing unauthorized purchases and ensures the integrity of your in-app economy. Validating purchases is a critical security measure to prevent fraud, protect your revenue, and ensure fair user experiences.

Essentially, that are two distinct validation approaches readily available.

Server-side Validation​

The most secure and reliable way to validate purchases is by using server-to-server (S2S) communication, with the client completely removed from the validation process. This minimizes security risks and ensures that entitlements are only granted based on verified data received directly from Xsolla.

With Xsolla, server-side validation is implemented through a webhook-based model:

  • Once a user completes a purchase through your app, Xsolla services automatically trigger a webhook event to your backend.
  • This webhook contains all the necessary purchase data, including the Xsolla order ID, enabling your server to validate and process the purchase asynchronously.
  • Your backend can then use this data to update the user's entitlements, balance, inventory, etc., without requiring any additional input from the client.

This flow ensures that the client has no role in deciding the outcome of a purchase — all validation logic lives on the server, using trusted data that originates from Xsolla itself.

tip

For more information about how webhooks work, see our Webhooks guide.

Transaction callbacks are UI-only in this flow

Even with server-side validation, the SDK still delivers its usual client callbacks — paymentQueue(_:updatedTransactions:), and the validateTransaction(_:) result if you call it. In a server-side (webhook) flow these are for UI/UX only: show a spinner, a confirmation screen, or refresh the storefront. They do not grant the reward and must not be used to do so — the entitlement is already awarded by your backend from the trusted webhook, independently of the device. Treat the client callback as a display signal, not the source of truth.

Client-side Validation​

Provides means of validating a purchase on the user's device without a need for a backend (server). It's better than nothing, but has its own drawbacks, i.e. anything that runs on the client can potentially be exploited.

Before finishing transaction, it can be validated on client side. Unfinished transactions restored after app was closed can't be validated.

SKPaymentTransaction* transaction = ...;
[[SKPaymentQueue defaultQueue] validateTransaction:transaction completion:^(BOOL isValid, NSError * _Nullable error) {
// isValid will be YES for valid transactions
}];

Comparison with Native StoreKit Validation​

While Xsolla provides streamlined validation approaches, it's helpful to understand how they compare to Apple's native StoreKit validation methods ↗ (https://developer.apple.com/documentation/storekit/choosing-a-receipt-validation-technique).

Server-side Validation Differences​

AspectXsolla Webhook-basedApple's verifyReceipt API
ImplementationWebhook automatically triggered by XsollaManual server-to-server calls to Apple's endpoint
SecurityHigh - No client involvementHigh - Direct validation with Apple
Setup ComplexityLow - Configure webhook endpointMedium - Implement receipt parsing and API calls
Data FormatJSON webhook payloadBase64-encoded receipt → JSON response
TimingAsynchronous, real-time notificationsSynchronous, on-demand validation
Transaction HistoryIndividual purchase eventsComplete receipt with all transactions
Network RequirementsWebhook endpoint accessible to XsollaSecure HTTPS to Apple's servers

With Xsolla's webhook-based approach, purchase validation happens automatically when Xsolla pushes verified purchase data to your backend endpoint, eliminating the need to handle receipt extraction, parsing, or validation requests.

With Apple's native approach, your app must extract receipt data from the app bundle and your server must make validation requests to Apple's endpoints (https://buy.itunes.apple.com/verifyReceipt for production or https://sandbox.itunes.apple.com/verifyReceipt for sandbox), then parse the JSON response.

Client-side Validation Differences​

AspectXsolla Mobile SDKApple's Native Local Validation
ImplementationSimple SDK method callComplex PKCS #7 container decoding
Code ComplexityLow - Single function callHigh - ASN.1 parsing, cryptographic validation
Validation StepsHandled internally by SDKManual verification of certificate chain, bundle ID, version, device hash
DependenciesXsolla Mobile SDKSecurity frameworks
MaintenanceManaged by XsollaDeveloper maintains cryptographic code
Security LevelMedium - Client-side limitations applyMedium - Client-side limitations apply

Xsolla's client-side validation provides a simplified interface:

SKPaymentQueue.default().validateTransaction(transaction) { isValid, error in
// Simple validation result
}

Apple's native local validation requires extensive implementation including decoding receipts as PKCS #7 containers using ASN.1 notation, verifying certificate chains and signature validity, computing SHA-1 hashes for device identification, and validating multiple receipt fields (bundle ID, version, device hash).