IAP Subscriptions

As I understand from Apple documentation receipt should have expired_date - that need for subscriptions.
I found an example here:

{"quantity":"1", 
 "product_id":"com.testapp.test",
 "transaction_id":"1000000135676121", 
 "original_transaction_id":"1000000135134855", 
 "purchase_date":"2014-12-15 06:53:54 Etc/GMT",  
 "purchase_date_ms":"1418626434059", 
 "purchase_date_pst":"2014-12-14 22:53:54 America/Los_Angeles",  
 "original_purchase_date":"2014-12-15 06:51:12 Etc/GMT",  
 "original_purchase_date_ms":"1418626272000",  
 "original_purchase_date_pst":"2014-12-14 22:51:12 America/Los_Angeles",  
 "expires_date":"2014-12-15 06:56:10 Etc/GMT",  
 "expires_date_ms":"1418626570000",  
 "expires_date_pst":"2014-12-14 22:56:10 America/Los_Angeles",  
 "web_order_line_item_id":"1000000028947356",  
 "is_trial_period":"false"
}

How to implement subscribes (in docs you have info that it is supports ) without expired_date ?

UPD: Official Apple doc.

UPD1:
I should validate receipt using server or other methods. It helps to recieve json with expired date and other fields.
Thanks @britzl for help with it

2 Likes

Does somebody know : should I call iap.finish() method for auto-subscription transaction?
I can’t understand it. If I try to call finish(), i do not recive next auto-renew. Looks like i shouldn’t call it, but i can’t find information in Apple docs, or Defold manuals.

I’m not sure myself, perhaps @britzl or @Andreas_Tadic knows?

On Android: https://developer.android.com/google/play/billing/api.html

“Important: Unlike in-app products, subscriptions cannot be consumed.”

On iOS: I can’t see anything in the docs about not calling [SKPaymentQueue finishTransaction] on subscriptions (ie iap.finish()). They should as far as I can tell be treated just as other purchases (ie auto-finished by Defold or manually though iap.finish() depending on game.project settings).

I also read this blog post on auto-renewable subscriptions: https://blog.curtisherbert.com/ios-subscriptions-primer/

There the developer mentions: “You don’t need to poll Apple asking if the user renewed - they’ll tell you when a renewal happens via the queue. One annoyance, here, is that this only seems to happen on app launch. If the user is inside your app when the renewal actually goes through, you won’t get the callback until next time.”

So, when an auto-renewable subscription has been automatically paid for and renewed by Apple it should be available in the payment queue. When Defold starts we pick up anything in the queue and when iap.set_listener() is called anything in queue gets forwarded to the listener.

1 Like

I made all as you say, but I did not receive updated receipt from the queue.
And when I try to bye subscription one more time - i can do this (looks like subscription was canceled)

I try to create new sandbox account
Then I remove finish() method for subscription.
The I try to buy subscription, waiting 3 min (I test on 1 week subs.) and restart an app - auto renew works fine.

I I finish subscription even once - it doesn’t work anymore (I should buy subscription every 3 minutes).
Helps only cretion of new sandbox account.

UPD: My fault, turns out that I can use auto renew only 6 times per sandbox account
And than only single subscription.
Apple has info (in docs) about 6 times, but has no information that it is works only once per account.

Ok, so there’s no issue with subscriptions from Defold’s side?

Only one issue : Defold need documentation and example =)
But in my app all works fine.
Thank you for your help.

1 Like

We/I should add a code snippet or example showcasing how to send the receipt to Apple and parsing the result (like you and I did). But what else is missing?

1 Like

Would be great to have example with comments, how subscription works. Information about launch queue. And about the method iap.finish() is remove transaction from this queue.

Issue with sandbox user: that auto renew for him works only once (I killed whole day for understanding it).

And same docs and example for non-consumable, it was not easy too. Defold manuals told that payments has one workflow for all platforms, but it’s true only for consumable purchase. It’s confuse.

It’s to hard reading and understanding Apple and Google documentation, when you don’t know what exactly Defold Lua methods do.

3 Likes