Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 42
Registered: ‎02-17-2012
My Device: Newb Playbook Developer
My Carrier: -
Accepted Solution

get existing purchases - local mode

Hi, I've been trying to implement IAP in my game, and I seem to be having some problem with getting existing purchases. When the app starts (local mode)  the paymentservice_get_existing_purchases_request(true... returns error 260 (communication time out) which makes sense, and then paymentservice_get_existing_purchases_request(false.. runs successfully but it would never remember any purchase that was made when the game was run earlier. It would however, remember correctly all the purchases that were made in that session. But if I close the app and run it again, it wouldn't remember any purchase.

 

Is that how it is supposed to work in local mode? Is that how it is supposed to run when running online.

 

 

As stated in the documentation:

"allow_refresh

If true the device should be allowed to refresh the list of purchases from the Payment Service server, if false the current list of cached purchases should be returned immediately."

 

I guess what I'm asking is that is the allow_refresh parameter is turned off, then what does the function return exactly? Does that cache contain everything from the time that the app was installed or only from the current session?

 

Any help is appreciated.

Thanks!

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: get existing purchases - local mode

Hi there,

 

Yes, this appears to be working as expected. Keep in mind that any purchases made that were not done with real money (in local or sandbox testing) will not constitute a transaction and therefore should not be expected to be returned with the paymentservice_get_existing_purchases_request() call. 

 

As for the App World cache, the first time you run the app I would strongly recommend refreshing (pulling from the App World server) as the cache will be empty for this app. The cache will store some purchases but is never guaranteed to have the data available, so periodic refreshes are also recommended.

 

I hope that helps, if you have any further questions just let me know.

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 42
Registered: ‎02-17-2012
My Device: Newb Playbook Developer
My Carrier: -

Re: get existing purchases - local mode

Hi, thank you for your reply.

 

I'm a little confused about the "The cache will store some purchases but is never guaranteed to have the data available" part. I understand that during the first run a refresh will be needed, but if the app has not been deleted, then can i assume that all the purchases that were available in the cache in the i-th run, will still be available in the cache in the (i+1) th run?

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: get existing purchases - local mode

The App World cache is like your browser cache, it's nice to use when available but should not be relied upon. The cache can be cleared at any time, for example if the device ever gets low on memory.

 

Your application should keep track of purchases, there shouldn't be a need to check for purchases every time it is run but you can use the cache for quick checks, if info is available then your app could use it (ex after a re-install of the app) otherwise it would likely be best to refresh and also cache all purchases in your app as well.

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 42
Registered: ‎02-17-2012
My Device: Newb Playbook Developer
My Carrier: -

Re: get existing purchases - local mode

Alright, that clears things up..

 

Thank you for you help Smiley Happy

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: get existing purchases - local mode

Happy to help!

Garett
@garettBeuk
--
Goodbye everybody!