IOS Subscription paid value - ios

I have configured apple Server-to-Server Notifications and it started to send notification to my webhook but the response body doesn't contain any information about paid value nor currency.
I've searched for endpoint to get that info, with no lock

Apple does not include the price in the S2S notification. It is also not present in the receipts validation response (https://developer.apple.com/documentation/appstorereceipts), but the device does have this information ( not sure how they access it), so we get the price info from the device during validation request it sends to our backend.

Related

Flutter in app purchase with backend side calling completePurchase and verifyReceipt

I have a flutter mobile app with a backend. I need to synchronize subscription with backend to share subscription across platforms.
For that I follow this flow :
I create a new account
I initiate new subscription after account has been created
I listen for purchase update and when I receive a purchase details with purchaseDetails.pendingCompletePurchase I send it to backend and use apple verifyReceipt endpoint to check receipt in purchaseDetails.VerificationData.ServerVerificationData
If receipt is valid I save the OriginalTransactionId from purchaseDetails.PurchaseID to database
My question here is:
After it return validation state from server I wonder if I still need to call completePurchase even if I called verifyReceipt endpoint.
I'm not sure to understand what completePurchase really do...
In the end, later I wait for apple server notification to update subscription status

Apple Server to Server notification not receiving from the sandbox for testing subscription renewal

I am trying to update the user's subscription renewal state. I had set up the endpoint in the app information section "URL for App Store Server Notifications" in the app information. But didn't receive any notification. Also, I had tried to set up revenuecat but got no notification. Does anyone know about this issue?

Unable to receive In-App purchase refund server-to-server notification

I'm trying to implement handling of In-App purchase refund notification (App Store sends responseBody JSON data to server notification url typed by the app developer) in our server backend. But after getting successful refund of In-App purchase, I'm unable to get any notification from the App Store.
Here's the list of things that I did to handle refund notification in our server.
Goto App Store Connect > Type "App Store Notification Url" : "https://ourServerUrl/notifyRefund" (supports TLS 1.2)
Our server accepts 'POST' request and defines #RequestBody parameter as documented in responseBody
Purchase product ('Consumable') from our iOS App (about $0.99) - purchase_date = 2021-03-03
Goto reportaproblem.apple.com and request a refund. -> Next day the refund was processed by App Store and I got $0.99 refunded successfully to my bank account. refund_date = 2021-03-04
After doing above steps I'm still unable to get a notification from App Store.
I read a post about notification delay but I'm not sure if this is because of the delay or my server configuration has a problem.
Apple doc.
Update as of 2021-03-24
In Server <--> App (iOS/Android) communication,
our server's view resolver (ContentNegotiatingViewResolver) determines the default view (TextPlainView, JsonView)
based on the request header (Content-Type, Accept)
Since the apple notification callback response (request to our server)
does not have 'Accept' header, our server sets default view resolver as TextPlainView
following our server configuration in 'servlet-context.xml'
It has caused errors since Apple notification response is in Json format.
After changing our server default view setting as json view
we were able to parse apple notification responseBody.
I hope it helps developers dealing with similar problems.

Apple Sandbox: Only receive 'INITIAL_BUY' server notifications

We have setup Apple’s Server notifications for auto-renewable subscriptions. Last month we still able to get all notification type(INITIAL_BUY, RENEWAL, INTERACTIVE_RENEWAL).
Recently when we tested with sandbox (1 year subscription), we receive only 'INITIAL_BUY' server notifications, we were expect to receive 'RENEWAL' server notifications after 1 hour, but we are not getting those notifications.
Question:
I just want to confirm that is it a new notifications service that only send us 'INITIAL_BUY' notifications? And there are no server-to server notification if the renewal is successful?
Note:**
We did validate receipt with verifyReceipt server to check latest_receipt_info.
Correct. According to this technical note (https://developer.apple.com/library/archive/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-SUBSCRIPTIONS-MY_SERVER_PROCESS_RARELY_RECEIVES_RENEWAL_NOTICES_WHEN_THE_AUTO_RENEWING_SUBSCRIPTION_RENEWS_)
The App Store attempts to charge the user account 24 hours before an auto-renewing subscription expires. If the renewal is successful, there is no server-to server notification because the auto-renewing subscription did not enter into the expired state.
You have to actively call Apple's receipt validation endpoint on or around the expiration date of each receipt (and possible for a few days after that) to fetch the renewal receipts. Apple will not notify your servers.

Server to Server Pollling Auto Renewable Subscription

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 ?
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
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
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

Resources