Skip to main content

We need to get a unique purchase ID for non-subscription purchases. 

It may take some time for the item purchased to be delivered. At this time, we want to show the loading screen. For this, the user device should be able monitor the purchase status. According to our logic, for this purpose the device should periodically send requests with the transaction ID to find out the status on the backend.

The webhook gives us the transaction_id:

{
"...": "...",
"transaction_id": "2000000263221092",
"original_transaction_id": "2000000263221092",
"...": "...",
"id": "3C725F74-BB80-40F0-A409-67F5352D9FCD",
"app_id": "appf1fcec6c3f"
}

The same transaction_id is available in the RevenueCat SDK logs:

```plain
Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts
sPurchases] - DEBUG: ℹ️ API request started: POST /v1/receipts
ePurchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts (200)
pPurchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished
iPurchases] - DEBUG: ℹ️ Sending updated CustomerInfo to delegate.
IPurchases] - INFO: 💰 Finishing transaction '2000000263221092' for product '...'
2Purchases] - INFO: 😻💰 Purchased product - '...'
Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue
,Purchases] - DEBUG: ℹ️ Vending CustomerInfo from cache.
Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x0000000282713600) removedTransaction: ... 2000000263221092 1
```

On the React Native side, a transactionIdentifier is available in customerInfo. But it does not match the transaction_id:

{
"customerInfo": {
"entitlements": {
"all": {
"..."
},
"active": {
"..."
}
},
"allPurchaseDates": {
"...": "..."
},
"...": "...",
"nonSubscriptionTransactions": .
{
"purchaseDate": "2023-01-30T17:43:59Z",
"revenueCatId": "968cd0aff4",
"productIdentifier": "...",
"purchaseDateMillis": 1675100639000,
"transactionIdentifier": "968cd0aff4",
"productId": "..."
}
],
"...": "..."
},
"productIdentifier": "..."
}

How can we get transaction_id which is available in webhook/RC logs on React Native side? 

How can we get transaction_id which is available in webhook/RC logs on React Native side? 

This is not currently available in the hybrid SDKs - yet, but it is in the native ones. Another option for now would be to use the transactionIdentifier you shared on the customerInfo object. You can retrieve this on your server from the subscribers endpoint. A common way to do this, is to use the webhook as a trigger for your server to call the API and retrieve the updated customer info object from RevenueCat.


How can we get transaction_id which is available in webhook/RC logs on React Native side? 

This is not currently available in the hybrid SDKs - yet, but it is in the native ones. Another option for now would be to use the transactionIdentifier you shared on the customerInfo object. You can retrieve this on your server from the subscribers endpoint. A common way to do this, is to use the webhook as a trigger for your server to call the API and retrieve the updated customer info object from RevenueCat.

Thanks Yousef, it is true that we can use the webhook and subscriber information as you described. But for this we have to change the structure of the database. We currently use the transaction ID from the webhook as the primary transaction ID. In the option you described, we have to use the transaction ID from /subscribers as the main ID.

 

While we waited for your response, we implemented a method to wait for transactions based on the product ID, user ID, and purchase date in milliseconds. Can you see when it won't work?


Reply