Skip to content

fix(ios): serialize UInt64 transaction IDs as strings to prevent E_DEVELOPER_ERROR during finishTransaction #2931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Aflexon
Copy link

@Aflexon Aflexon commented Mar 10, 2025

This pull request resolves a serialization issue affecting transaction identifiers (id and originalID) for iOS. We've observed transaction IDs—particularly from family-shared subscriptions—with UInt64 values exceeding JavaScript’s MAX_SAFE_INTEGER (2^53 - 1), such as 504319184420155588.

When these large integer IDs are transmitted from native Swift code to JavaScript via the React Native bridge, they lose numeric precision. This loss causes transaction IDs to become corrupted, resulting in errors like E_DEVELOPER_ERROR with the message Invalid transaction Id when calling finishTransaction with IDs obtained from the purchaseUpdatedListener. Consequently, transactions may fail to complete properly.

Proposed Changes

  1. Serialize transaction identifiers (id, originalID) explicitly as strings to maintain numerical precision.
  2. Retain numeric serialization for timestamp fields (millisecondsSince1970), as they currently do not risk exceeding JavaScript's precision limit.

@hyochan hyochan requested a review from Copilot March 27, 2025 04:50
@hyochan hyochan added 📱 iOS Related to iOS 🛠 bugfix All kinds of bug fixes labels Mar 27, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR resolves an issue with large UInt64 transaction IDs being truncated on the React Native bridge by serializing them as strings.

  • Changed the transaction identifier type in the TransactionSk2 interface from number to string.
  • Updated the purchase mapping to use the new string-typed transaction identifier.
Files not reviewed (1)
  • ios/IapSerializationUtils.swift: Language not supported
Comments suppressed due to low confidence (2)

src/types/appleSk2.ts:114

  • Changing the 'id' type from number to string addresses the precision issue, but please verify that all consumers of this field are updated to expect a string.
id: string;

src/types/appleSk2.ts:192

  • Removing the explicit conversion to string is logical since 'id' is now a string; please ensure that all related interfaces and usage correctly reflect this change.
transactionId: id,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠 bugfix All kinds of bug fixes 📱 iOS Related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants