Skip to content

Commit c23f71a

Browse files
hyochanclaude
andcommitted
fix(apple): validate appAccountToken UUID format before purchase
Add validation that throws a clear error when appAccountToken is not a valid UUID format. Apple silently returns null for non-UUID values, which makes debugging difficult. This change fails fast with a descriptive error message to help developers identify the issue. Closes hyochan/expo-iap#128 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 15d6ef2 commit c23f71a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/apple/Sources/Helpers/StoreKitTypesBridge.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,19 @@ enum StoreKitTypesBridge {
364364
if let quantity = props.quantity, quantity > 1 {
365365
options.insert(.quantity(quantity))
366366
}
367-
if let token = props.appAccountToken, let uuid = UUID(uuidString: token) {
367+
if let token = props.appAccountToken {
368+
guard let uuid = UUID(uuidString: token) else {
369+
// Apple requires appAccountToken to be a valid UUID format.
370+
// If a non-UUID value is provided, Apple silently returns null for this field.
371+
// Fail fast with a clear error message so developers can identify the issue.
372+
// Reference: https://openiap.dev/docs/types/request
373+
OpenIapLog.error("❌ Invalid appAccountToken format: '\(token)'. Must be a valid UUID (e.g., '550e8400-e29b-41d4-a716-446655440000')")
374+
throw PurchaseError.make(
375+
code: .developerError,
376+
productId: props.sku,
377+
message: "appAccountToken must be a valid UUID format (e.g., '550e8400-e29b-41d4-a716-446655440000'). Received: '\(token)'. Apple silently returns null for non-UUID values."
378+
)
379+
}
368380
options.insert(.appAccountToken(uuid))
369381
}
370382
if let offerInput = props.withOffer {

0 commit comments

Comments
 (0)