Handling #IAP #Subscription #Cancellations
IAP Subscriptions are great, they allow you take recurring payments from your customers, so that you can make an on-going income from a customer that continues to use your service.
However, accepting a subscription, it’s also important to know when the subscription is cancelled, so that you can stop providing your service to the customer.
First thing is to define a callback with the “Subscription Status Url”, which you can find under your app in iTunes Connect, under App Information > General Information.
This URL will be sent some JSON data using HTTP POST, and the format of the requests are as follows;
First, the Intial buy, as follows;
{
“latest_receipt”: “….”,
“latest_receipt_info”: {
“original_purchase_date_pst”: “2017-10-14 18:51:38 America\/Los_Angeles”,
“quantity”: “1”,
“unique_vendor_identifier”: “025C068A-ABA3-4967-BC20-82C397CA6E1A”,
“original_purchase_date_ms”: “1508032298000”,
“expires_date_formatted”: “2017-11-15 02:51:34 Etc\/GMT”,
“purchase_date_ms”: “1508032294000”,
“expires_date_formatted_pst”: “2017-11-14 18:51:34 America\/Los_Angeles”,
“is_trial_period”: “false”,
“item_id”: “1215609502”,
“unique_identifier”: “aae666d4899834762d29b57272c10400256ba0dc”,
“original_transaction_id”: “240000386052948”,
“expires_date”: “1510714294000”,
“app_item_id”: “1214710746”,
“transaction_id”: “240000386052948”,
“bvrs”: “1.3.3”,
“web_order_line_item_id”: “240000089571027”,
“version_external_identifier”: “822490968”,
“bid”: “ie.infiniteloop.cloudansweringmachine”,
“product_id”: “CloudAnsweringMachineSubscription”,
“purchase_date”: “2017-10-15 01:51:34 Etc\/GMT”,
“purchase_date_pst”: “2017-10-14 18:51:34 America\/Los_Angeles”,
“original_purchase_date”: “2017-10-15 01:51:38 Etc\/GMT”
},
“environment”: “PROD”,
“auto_renew_status”: “true”,
“password”: “f1d192a81bc746da837639012d3917b3”,
“auto_renew_product_id”: “CloudAnsweringMachineSubscription”,
“notification_type”: “INITIAL_BUY”
}
Then if the customer cancels the subscription, then the request would be as follows;
{
“environment”: “PROD”,
“auto_renew_status”: “false”,
“web_order_line_item_id”: “240000089571027”,
“latest_expired_receipt_info”: {
“original_purchase_date_pst”: “2017-10-14 18:51:38 America\/Los_Angeles”,
“cancellation_date_ms”: “1508089204000”,
“quantity”: “1”,
“cancellation_reason”: “0”,
“unique_vendor_identifier”: “025C068A-ABA3-4967-BC20-82C397CA6E1A”,
“original_purchase_date_ms”: “1508032298000”,
“expires_date_formatted”: “2017-11-15 02:51:34 Etc\/GMT”,
“purchase_date_ms”: “1508032294000”,
“expires_date_formatted_pst”: “2017-11-14 18:51:34 America\/Los_Angeles”,
“is_trial_period”: “false”,
“item_id”: “1215609502”,
“unique_identifier”: “aae666d4899834762d29b57272c10400256ba0dc”,
“original_transaction_id”: “240000386052948”,
“expires_date”: “1510714294000”,
“app_item_id”: “1214710746”,
“transaction_id”: “240000386052948”,
“bvrs”: “1.3.3”,
“web_order_line_item_id”: “240000089571027”,
“version_external_identifier”: “822490968”,
“bid”: “ie.infiniteloop.cloudansweringmachine”,
“cancellation_date”: “2017-10-15 17:40:04 Etc\/GMT”,
“product_id”: “CloudAnsweringMachineSubscription”,
“purchase_date”: “2017-10-15 01:51:34 Etc\/GMT”,
“cancellation_date_pst”: “2017-10-15 10:40:04 America\/Los_Angeles”,
“purchase_date_pst”: “2017-10-14 18:51:34 America\/Los_Angeles”,
“original_purchase_date”: “2017-10-15 01:51:38 Etc\/GMT”
},
“cancellation_date_ms”: “1508089204000”,
“latest_expired_receipt”: “………………….”,
“cancellation_date”: “2017-10-15 17:40:04 Etc\/GMT”,
“password”: “f1d192a81bc746da837639012d3917b3”,
“cancellation_date_pst”: “2017-10-15 10:40:04 America\/Los_Angeles”,
“auto_renew_product_id”: “CloudAnsweringMachineSubscription”,
“notification_type”: “CANCEL”
}
This example is taken from the app, CloudAnsweringMachine.com