Server to Server Pollling Auto Renewable Subscription
Asked Answered
D

3

1

We are implementing server side receipt validation for auto renewable subscription. Now when a user turn off the subscription or when it auto renew there is no notification send from apple server to our server. We want to poll apple server when the subscription is about to expire. So how can we do this?

Is there a way to schedule such polling at specific date ?

Dormeuse answered 20/6, 2018 at 12:11 Comment(0)
L
0

First when any in app purchase made you need to store receipt data after validating it. Also you need to store expire date of that particular purchase which you will get by receipt validation.

Now create a crone job in your server to validate auto renew purchase, crone job time interval is up to you as per your project need but let say for example take 1 hours. In the crone job you need to select only those record which expire time with in next 6 hours(You can change this time as per your need). Then again validate this receipt and if purchase get auto renew then you will get list of receipt. You will get always new receipt in the list whenever purchase auto renew. In this you will get new expire time. Suppose you are not getting any new receipt then it means user has cancel subscription

Librium answered 20/6, 2018 at 12:28 Comment(1)
Hm.. Ok this can be one solution but say as the data grows will this be in-efficient ? Say we have to query the whole database for expired receipt say every day, then I have to query this receipts which can be in any number with apple servers.Dormeuse
H
0

You would need Receipt validation.

If your app offers auto-renewable subscriptions, you can receive server notifications from the App Store about key events by setting up an optional URL that links to your server.

Before sending a notification to your server, the App Store will try to establish a secure network connection with your server by using App Transport Security (ATS) protocols. If a secure connection cannot be established, notifications will not be sent to your server. See Requirements for Connecting Using ATS to learn more about security requirements.

After a secure HTTPS connection has been established, the App Store will deliver JSON objects through an HTTP post to your server for key subscription events. See the In-App Purchase Programming Guide to learn more about the contents of this HTTP post.

Use server notifications together with Receipt Validation to validate a customer's current subscription status and provide them access to content or services from within your app.

For more info : Link

Hyetology answered 20/6, 2018 at 12:33 Comment(1)
Yes, this I know. But apple does not provide notification when user cancels the subscription or when the subsection auto renews so when it is about to expire we have to poll apple server along with the receipt data to query the current status. so, on server I have to detect which subscription are about to expire and then have to query apple server for their current status. So, how can I achieve this. Ex : Schedule a task that would run 12hours before expiration or as crazy developer suggested run a cron job that would query DB for expiring subscription and poll apple servers..Dormeuse
F
0

Not get notifications such as cancel as these notifications are only sent when a subscription is canceled by Apple directly.

The renewal notification, "Automatic renewal was successful for an expired subscription. Check Subscription Expiration Date to determine the next renewal date and time." In general, iTunes will attempt to charge the user account a day before an auto-renewing subscription is scheduled to expire. If the renewal is successful, there is no server-to-server notification because the auto-renewing subscription did not enter into an expired state. There is no support at present to simulate this event in the sandbox environment.“

Read more: https://forums.developer.apple.com/message/283579#283579

Forwards answered 30/1, 2019 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.