Skip to content

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 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,

@hyochan hyochan force-pushed the main branch 3 times, most recently from 608cfb7 to 76fba07 Compare September 9, 2025 04:16
@hyochan hyochan force-pushed the main branch 2 times, most recently from 8426e36 to 381bc18 Compare September 11, 2025 03:37
@hyochan hyochan force-pushed the main branch 4 times, most recently from 74f9efe to 613bc20 Compare September 22, 2025 15:13
@hyochan
Copy link
Owner

hyochan commented Sep 30, 2025

Closes since this is not valid in recent version starting from v14.+. Thanks for the PR though

@hyochan hyochan closed this Sep 30, 2025
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