In App Purchases Notifications

Jose Miguel
2 min readSep 7, 2020

--

On this post we are going to follow to configuration and setup for server notification from Apple Store and Google Play Store when any of your app’s users purchases some subscriptions or their subscriptions status is updated.

Types of products

On this page from apple we can see the different types of products that the stores provide. In the case of the subscriptions, the store is the one that charges periodically to users, not your app or server.

Server Notifications

Each store provides a service to notify your server, so every time a subscription status is updated, our server will notify so we can handle the status of the users in our system.

IOS

On ios, the service is called Server-to-server Notification, you can check here more details about the configuration, and here how to enable it.

To configure:

  1. Visit https://appstoreconnect.apple.com/apps, then access to your app.
  2. Click on ‘App Information’ under General.
  3. On ‘URL for App Store Server Notifications’, add the url on your server where you want to receive the notifications.

After this, your server will get notified after any update on the subscription. You can check here the different types of notifications that you will receive and handle the subscription on your system according to the status.

Android

On Android, the service is called Real-time developer notifications, on this page you can check more detailed explanation about the configuration. And here you can check how to configure it.

The notification system on Android is different from ios. In order to get the notification we have to configure Google Cloud Pub/Sub for updates.

To configure:

  1. Go to Google Cloud Console and create/select a project.
  2. On the header, click to open the menu and select ‘Pub/Sub’, or click https://console.cloud.google.com/cloudpubsub/topic/list
  3. Create/select a topic.
  4. Add the service account google-play-developer-notifications@system.gserviceaccount.com, and grant it the role of Pub/Sub Publisher.
  5. Create a subscription. There are 2 types of subscription:
    - Pull: we need to configure our server to pull for new messages.
    - Push: Similar to ios, the notification is send to the endpoint we configure.
    You can check here how to integrate PubSub with your server.
  6. Go to Google Play Console and select your app.
  7. Click on ‘Development tools’, then ‘Service & APIs’.
  8. On Real-time developer notifications type the topic name.
  9. You can send a test notification to test that all is connected.

Receiving notifications

Once you have configured all, next step is handle the notifications. Both stores do not send any information related to the user, so it is up to you to send the data from your app to your server so you can save and use that data later when the notification is send to the server.

Also the data send to the server has to be validated with the store to get all the data.

  • IOS send the ‘receipt’
  • Android send ‘purchaseToken’

References

--

--

Jose Miguel

Software Engineer, traveler. Currently working at Criptan (Spain) from South Korea. You can check about me here https://jmn8718.github.io/