christianselig/apollo-backend

Return original_transaction_id in server response for receipt validation

christianselig opened this issue · 0 comments

In addition to returning the name of the product (eg: ultra), the unlock status and the subscription type, ALSO return the original transaction ID in that same JSON so it can be determined client-side easily if the purchase was truly a purchase and not just a restore. Should be pretty easy to glean it from the pending_renewal_info we already look at:

"pending_renewal_info": [
    {
        "auto_renew_product_id": "com.christianselig.apollo.sub.monthly",
        "original_transaction_id": "420000571430640",
        "product_id": "com.christianselig.apollo.sub.monthly",
        "auto_renew_status": "1"
    }
]

Issue is I wrote some of the old receipt validation code not the greatest and some of the functions only return whether or not the subscription exists, not the accompanying ID, so will have to fix what bad past Christian did with fancy new André insights.

There's a good enough bandaid solution in place that's worked for well over a decade and likely will forever but this'd be a good one to fix one day, it's a handy one for client-side analytics.

Further reading on issue: https://stackoverflow.com/questions/5623652/differentiating-between-initial-buy-and-free-re-buy-in-storekit-in-app-purchas