Tag Archives: ionic play store subscription

State changes during an in-app purchase in Ionic Cordova

Here is a cleaner and summarized version of the data/state changes that are crucial for recording the transaction.

For raw dumps view this article – Ionic Cordova In-App Purchase Plugin Events Data Dumps

---------------------------------
START OF NEW PURCHASE 
---------------------------------
state:requested
canPurchase: false
owned: false

state:initiated
canPurchase: false
owned: false

state:initiated
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

state:finished
canPurchase: false
owned: false

AT THIS POINT - OWNED event listener is fired

"state":"owned"
"canPurchase":false
"owned":true

state:owned
canPurchase: false
owned: true


-----------------------------------------
AFTER CANCELLED AND CANCELLATION COMPLETE
-----------------------------------------
state:valid
owned:false
canPurchase:true

state:valid
owned:false
canPurchase:true


PURCHASE CANCELLED is called when the 
	Popup is cancelled
	When an expired Subscription is removed from Google Play


-----------------------------------------------------------------------------------------
WHEN THE SUBSCRIPTION IS VALID IT IS GIVING the below on screen change or app open
-----------------------------------------------------------------------------------------
state:valid
owned:false
canPurchase:true

state:valid
owned:false
canPurchase:true

state:approved
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

state:approved
canPurchase: false
owned: false

AT THIS POINT - OWNED event listener is fired

state:owned
canPurchase: false
owned: true

state:owned
canPurchase: false
owned: true


The Transaction ID (GPA.3341-6605-8567-18617) changes after new purchases are made
The Purchase Token (cpfjfhlbkagpjhgcoejgmajg.AO-J1Oxa8jFURcHtEBngM5zuU...) changes after new purchases are taken. 

Please note the purchase token will remain same as long the Subscription doesn’t fail or cancelled. The subscription auto-renews and will have the same “Purchase Token“. But if the renewal fails and the grace period is over or the subscription is cancelled and re-subscribed, a new “Purchase Token” will be generated.