@@ -193,13 +193,24 @@ - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
193193}
194194
195195RCT_EXPORT_METHOD (receiptData:(RCTResponseSenderBlock)callback)
196+ {
197+ NSString *receipt = [self grandUnifiedReceipt ];
198+ if (receipt == nil ) {
199+ callback (@[@" not_available" ]);
200+ } else {
201+ callback (@[[NSNull null ], receipt]);
202+ }
203+ }
204+
205+ // Fetch Grand Unified Receipt
206+ - (NSString *)grandUnifiedReceipt
196207{
197208 NSURL *receiptUrl = [[NSBundle mainBundle ] appStoreReceiptURL ];
198209 NSData *receiptData = [NSData dataWithContentsOfURL: receiptUrl];
199210 if (!receiptData) {
200- callback (@[ @" not_available " ]) ;
211+ return nil ;
201212 } else {
202- callback (@[[ NSNull null ], [receiptData base64EncodedStringWithOptions: 0 ]]) ;
213+ return [receiptData base64EncodedStringWithOptions: 0 ];
203214 }
204215}
205216
@@ -220,7 +231,7 @@ - (void)productsRequest:(SKProductsRequest *)request
220231 @" currencyCode" : [item.priceLocale objectForKey: NSLocaleCurrencyCode ],
221232 @" priceString" : item.priceString ,
222233 @" countryCode" : [item.priceLocale objectForKey: NSLocaleCountryCode ],
223- @" downloadable" : item.downloadable ? @" true" : @" false" ,
234+ @" downloadable" : item.isDownloadable ? @" true" : @" false" ,
224235 @" description" : item.localizedDescription ? item.localizedDescription : @" " ,
225236 @" title" : item.localizedTitle ? item.localizedTitle : @" " ,
226237 };
@@ -248,7 +259,7 @@ - (NSDictionary *)getPurchaseData:(SKPaymentTransaction *)transaction {
248259 @" transactionDate" : @(transaction.transactionDate .timeIntervalSince1970 * 1000 ),
249260 @" transactionIdentifier" : transaction.transactionIdentifier ,
250261 @" productIdentifier" : transaction.payment .productIdentifier ,
251- @" transactionReceipt" : [[transaction transactionReceipt ] base64EncodedStringWithOptions: 0 ]
262+ @" transactionReceipt" : [self grandUnifiedReceipt ]
252263 }];
253264 // originalTransaction is available for restore purchase and purchase of cancelled/expired subscriptions
254265 SKPaymentTransaction *originalTransaction = transaction.originalTransaction ;
0 commit comments