0

I need the purchaseToken for our server. This field exsits in the Android API,

/**
  * Token that uniquely identifies a purchase.
  */
 val purchaseToken: String,

And it is received upon purchase. But iOS API of the purchase function below doesn't send it back

func purchase(package: Package) async throws -> PurchaseResultData

When I debug, I see a similar data inside this:

purchaseResultData.customerInfo.allPurchases.first?.value["id"]

But allPurchases is private so I can't get it this way.

Any ideas?

Luda
  • 7,282
  • 12
  • 79
  • 139
  • `purchaseToken` is an Android object, it doesn't exist on iOS... What is it that you're trying to save? https://developer.android.com/reference/com/android/billingclient/api/Purchase#getPurchaseToken() – enc_life Apr 12 '22 at 14:50

1 Answers1

1

I notice that PurchaseResultData is a typealias for

typealias PurchaseResultData = (transaction: StoreTransaction?,
                                customerInfo: CustomerInfo,
                                userCancelled: Bool)

Instead of checking the customerInfo for the purchaseToken, maybe the transaction object has this information as I can see that the type StoreTransaction has a property called productIdentifier

So maybe try

purchaseResultData.transaction.productIdentifier

Update with some other ideas

  • Maybe try looking at the transaction identifier
  • Maybe exploring the store kit objects, namely SK1Transaction and SK2Transaction which are properties of StoreTransaction
  • I have not used this specific API, but it seems like allPurchasedProductIdentifiers is a public property within CustomerInfo so I wonder if this is different from the allPurchases you tried
Shawn Frank
  • 4,381
  • 2
  • 19
  • 29
  • I did. Unfortunately, it is not it. Is it a longer numberOnly var. The one I am looking for is shorter and has chars as well. – Luda Apr 04 '22 at 09:21
  • @Luda - I see. I just updated with some new ideas. Have a look if maybe they help ? – Shawn Frank Apr 04 '22 at 09:33
  • 1
    I will check your suggestions soon. I am giving you an upvote anyway for your kindness and politness. – Luda Apr 05 '22 at 12:36
  • I was hoping it would be customerInfo.allPurchasedProductIdentifiers, unfortunately it is the ids of products configured in AppStore – Luda Apr 12 '22 at 07:57
  • @Luda Hmm ... Other ideas I can think of. 1. I found some support email on an article by them, you can check if they have some answer: `support@revenuecat.com`. 2. Can you share the Android code that worked, maybe it has some hints for us ? 3. I will leave some links related to product identifier I found on revenue cat forums, maybe they will help – Shawn Frank Apr 12 '22 at 08:33
  • https://community.revenuecat.com/general-questions-7/error-with-product-identifiers-ios-724 – Shawn Frank Apr 12 '22 at 08:33
  • https://community.revenuecat.com/sdks-51/invalid-product-identifiers-still-after-trying-all-points-in-reference-post-1308 – Shawn Frank Apr 12 '22 at 08:33
  • https://community.revenuecat.com/general-questions-7/invalid-product-identifiers-992 – Shawn Frank Apr 12 '22 at 08:34
  • https://community.revenuecat.com/search?q=product%20identifier%20ios – Shawn Frank Apr 12 '22 at 08:34
  • This is mine. Waiting for an answer https://community.revenuecat.com/sdks-51/how-to-get-the-purchasetoken-in-ios-1451 – Luda Apr 13 '22 at 12:46