2

My app offers in-app subscriptions. When a subscription is bought or renewed, the app is notified with a SKPaymentTransaction, that contains in-app product identifier. I can query that in-app id to retrieve the purchased SKProduct. That product may contain a regular price, an introductory price (or trial), and one or more discount prices (since iOS 12.2). In case of a renewed subscription, the current regular price may differ from the price the user had been subscribed in the past.

My question is how to tell which is the price the user has paid:

  • current regular price;
  • introductory price/trial;
  • discount price;
  • something else, available in the past for that user.
Vladimir Grigorov
  • 10,903
  • 8
  • 60
  • 70

1 Answers1

3

You can't get the actual price of the transaction directly, but you can look at the product price and some other receipt fields to approximate what the user paid.

You'll need to save the price and introductoryPrice from the SKProduct then you can look at the is_in_intro_offer_period flag on the SKPaymentTransaction to determine if the price field or introductoryPrice is what the user will be charged.

Note that the SKProduct prices will be in the user's currency so you should be saving the locale too if you want to convert everything to the same currency.

The fact that price is not in a receipt still blows my mind :)

enc_life
  • 4,973
  • 1
  • 15
  • 27
  • `is_in_intro_offer_period` is a [receipt field](https://developer.apple.com/documentation/appstorereceipts/is_in_intro_offer_period) and while it can be used to determine whether a user is eligible for an introductory offer it doesn't provide the information needed to answer the question imo. – sethdeckard Jul 20 '20 at 13:55
  • @sethdeckard I made some edits to clarify. Does that help? It's impossible to get the actual transaction price, but you can infer it based off the price of the product and whether the user is in an introductory period or not. – enc_life Jul 20 '20 at 19:19
  • That seems like a reasonable approach for introductory offers and a similar approach should work for promotional pricing (`discounts` on `SDKProduct`). Accessing receipt fields requires validation of the receipt on your backend but if you're working with subscriptions you should already be doing this in addition to persisting all of this state too. :) – sethdeckard Aug 10 '20 at 18:14