Skip to content

Commit

Permalink
fixes transaction date types to be ints on iOS (#2133)
Browse files Browse the repository at this point in the history
Co-authored-by: Andres Aguilar <andres.aguilar@nfl.com>
  • Loading branch information
andresesfm and Andres Aguilar authored Nov 28, 2022
1 parent 72fb4ce commit 240f716
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ios/IapTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension Date {
}

var millisecondsSince1970String: String {
return String((self.timeIntervalSince1970 * 1000.0).rounded())
return String(self.millisecondsSince1970)
}

init(milliseconds: Int64) {
Expand Down
4 changes: 2 additions & 2 deletions ios/RNIapIos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -796,15 +796,15 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
block(nil)
} else {
var purchase = [
"transactionDate": transaction.transactionDate?.millisecondsSince1970String,
"transactionDate": transaction.transactionDate?.millisecondsSince1970,
"transactionId": transaction.transactionIdentifier,
"productId": transaction.payment.productIdentifier,
"transactionReceipt": receiptData?.base64EncodedString(options: [.endLineWithCarriageReturn])
]

// originalTransaction is available for restore purchase and purchase of cancelled/expired subscriptions
if let originalTransaction = transaction.original {
purchase["originalTransactionDateIOS"] = originalTransaction.transactionDate?.millisecondsSince1970String
purchase["originalTransactionDateIOS"] = originalTransaction.transactionDate?.millisecondsSince1970
purchase["originalTransactionIdentifierIOS"] = originalTransaction.transactionIdentifier
}

Expand Down
2 changes: 1 addition & 1 deletion src/types/appleSk2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const transactionSk2Map = ({
transactionReceipt: '', // Not available
purchaseToken: '', //Not avaiable
quantityIOS: purchasedQuantity,
originalTransactionDateIOS: String(originalPurchaseDate),
originalTransactionDateIOS: originalPurchaseDate,
originalTransactionIdentifierIOS: originalID,
};
return purchase;
Expand Down
4 changes: 2 additions & 2 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface ProductPurchase {
purchaseToken?: string;
//iOS
quantityIOS?: number;
originalTransactionDateIOS?: string;
originalTransactionDateIOS?: number;
originalTransactionIdentifierIOS?: string;
//Android
productIds?: string[];
Expand Down Expand Up @@ -96,7 +96,7 @@ export interface PurchaseResult {

export interface SubscriptionPurchase extends ProductPurchase {
autoRenewingAndroid?: boolean;
originalTransactionDateIOS?: string;
originalTransactionDateIOS?: number;
originalTransactionIdentifierIOS?: string;
}

Expand Down

0 comments on commit 240f716

Please sign in to comment.