Solved

How can I get the transaction or order ID in Flutter?

  • 18 October 2021
  • 8 replies
  • 1005 views

Badge +5

How can ı. get order id in flutter for android 

icon

Best answer by cody 18 October 2021, 19:42

View original

8 replies

Userlevel 6
Badge +8

Hey @seyhmus gumus!

We don’t currently send the transaction or order ID in the purchase response from the Flutter SDK.

If you need access to the transaction ID, I’d recommend setting up webhooks as we include transaction identifiers in webhooks for purchases. You can consume webhooks from your server and save the transaction identifier server-side.

Badge +5

Thank you so much for letting me know this

Badge +1

Hey @seyhmus gumus!

We don’t currently send the transaction or order ID in the purchase response from the Flutter SDK.

If you need access to the transaction ID, I’d recommend setting up webhooks as we include transaction identifiers in webhooks for purchases. You can consume webhooks from your server and save the transaction identifier server-side.


Please add the order ID to the response, setting up webhook to save server side and then reading from there complicates what should be a pretty simple transaction. (Make an order -> get your order id in the success response)

Badge +2

HI, there is some way to identify the purchase?

I understand that I can validate the purchase with a webhook, but if i dont have any ID (like order ID o transaction ID) How i can verify if the purchase is the same that the webhook send to my server?

please, can you helpme?

Badge +2

Hey @seyhmus gumus!

We don’t currently send the transaction or order ID in the purchase response from the Flutter SDK.

If you need access to the transaction ID, I’d recommend setting up webhooks as we include transaction identifiers in webhooks for purchases. You can consume webhooks from your server and save the transaction identifier server-side.

I review your code in the library purchases-hybrid-common you can add the order Id, but you filter that in this line

 

https://github.com/RevenueCat/purchases-hybrid-common/blob/1f0c0fdff9803299644891dd6e8b5c913b75e91a/android/src/main/java/com/revenuecat/purchases/hybridcommon/common.kt#L322

Badge +1

So, there’s currently no way of getting the order-id from the Flutter SDK when a purchase is made?
This is a problem for my use case where I need to correlate a consumable purchase to the item that’s purchased in my app

Badge +2

I was looking for a similar solution to this. On the flutter side after calling purchaseProduct() you can get the last transaction from the returned CustomerInfo object and then send this details to your backend.

 

CustomerInfo? customerInfo = await Purchases.purchaseProduct(
                    “myProduct”,type: PurchaseType.inapp).then((value) {
              if (value.nonSubscriptionTransactions.length > 0) {
                int lastItem = value.nonSubscriptionTransactions.length - 1;
                StoreTransaction item = value.nonSubscriptionTransactions[lastItem];
                // send item to your backend

 

In the backend implement the webhook and when you receive the webhook, call the subscriber endpoint:
 

https://api.revenuecat.com/v1/subscribers/{app_user_id}

to get a list of the transactions, then you should be able to match up the 2 on the transaction_id

 

 

 

Badge +1

It is ridiculous not to share this ID, it is very difficult to find it from the user database in case of refunds or problematic payments. Isn't this identity still shared in flutter? If it is not shared, why is it not shared yet?

Reply