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
New Developer
jbeach42
Posts: 63
Registered: ‎10-27-2010
My Device: 9900 and PlayBook

Detecting Previous In-App Purchases - Design Question

Just curious how others are accomplishing this.

 

I have in-app purchases.  If the user deletes the app, or gets a new phone or something, I'll need to check for previous purchases.

 

Should I be checking for previous purchases automatically on app startup, or should there be a button somewhere that a user can initate the check?  I think in other platforms, the preferred approach may be the latter.  At least from what I've heard.  I don't see any guidelines for this for BlackBerry.

 

Although I haven't implemented it yet, I'm planning on doing the check at every app startup if I don't already have any an indication that the user has already purchased.  This is a simple but if done in the main thread could impact starup performance if Purchase Manager isn't checking cache.  I'm not sure how the Purchase Manager caching mechanism works.

 

Any comments on this would be very appreciated!  :smileyhappy:

 

-----------------------------------------------------------------------------
Apps:Beats Brainwave Entrainment - Awesome Timer - StarSlide - Save Santa
@jamiebeach
Please use plain text.
Developer
d3v3l0p3r
Posts: 168
Registered: ‎07-19-2012
My Device: Q5, Q10, Z10, Z30, PlayBook

Re: Detecting Previous In-App Purchases - Design Question

I have the same question. Can someone with some experience with in-app purchases help with this? thank you

---
If you find my post helpful please "like" it and "accept as a solution"
Please use plain text.
Developer
mzex
Posts: 368
Registered: ‎06-30-2012
My Device: Playbook, Z10LE, DevAlpha C

Re: Detecting Previous In-App Purchases - Design Question

[ Edited ]

Exactly what i wanted to ask.

When you request existing purchases from payment manager via requestExistingPurchases(bool) method, if you set that bool to false, it will not ask user for credentials , it will just check cache on device, and if you set it to true, it will ask user for credentials and request data from server. I'm not sure what is going on during upgrade or reinstall of application, especially what will happen to database if app has one.

Please use plain text.
Developer
d3v3l0p3r
Posts: 168
Registered: ‎07-19-2012
My Device: Q5, Q10, Z10, Z30, PlayBook

Re: Detecting Previous In-App Purchases - Design Question

Great, now all we need is someone to provide some suggestions.

---
If you find my post helpful please "like" it and "accept as a solution"
Please use plain text.
New Developer
jbeach42
Posts: 63
Registered: ‎10-27-2010
My Device: 9900 and PlayBook

Re: Detecting Previous In-App Purchases - Design Question

So I finished my app. Without guidance, I decided to do the following:

- once purchased or check for existing purchase returns true, a file is written so that the checks don't happen again.
- if the file isn't there, I do a check for existing purchase on startup without forcing server refresh.
- the purchase button also checks for the "already purchased" error and writes the file in that case, also letting the user know that it was already purchased. So at the very least, users can get their in-app purchase if the check for existing purchase doesn't work.

In hindsight, there should also be a button to check for existing purchases, forcing server refresh. If you look at the top grossing iOS apps, they all have this.
-----------------------------------------------------------------------------
Apps:Beats Brainwave Entrainment - Awesome Timer - StarSlide - Save Santa
@jamiebeach
Please use plain text.
Developer
mzex
Posts: 368
Registered: ‎06-30-2012
My Device: Playbook, Z10LE, DevAlpha C

Re: Detecting Previous In-App Purchases - Design Question

Yeah, i do nearly the same stuff, but my app use db, and i write that info in db. Problem is, that we cant test all that stuff right now, because procedure for testing IN app payments described here: http://supportforums.blackberry.com/t5/BlackBerry-App-World-Development/Testing-app-in-DRAFT-mode-on...  with sandbox account when you app is in draft state in App world is not working currently.

Please use plain text.
New Developer
jbeach42
Posts: 63
Registered: ‎10-27-2010
My Device: 9900 and PlayBook

Re: Detecting Previous In-App Purchases - Design Question

Actually - I've changed things a bit. After struggling with in-app purchases over the last 24 hours, I've decided to force refresh on checkExistingPurchases. Otherwise I was getting an error about the cache not existing.

Also, the test mode and prod mode error codes seem to be wildly different. Would be nice if there was some info on what the error codes are.
I've determined that 1 is user canceled and 5 is already purchased. Seemed like they were all 4 in test mode.

One other thing - yes, the sandbox is actually working. Put your app into draft, go to app world and swipe down for settings. If your phone is in dev mode, then there is a development setting in app world where you can enter your app id or sku.
One thing to note - refresh of app world seems to take a while and therefore draft apps don't necessarily appear for a while.
-----------------------------------------------------------------------------
Apps:Beats Brainwave Entrainment - Awesome Timer - StarSlide - Save Santa
@jamiebeach
Please use plain text.
Developer
mzex
Posts: 368
Registered: ‎06-30-2012
My Device: Playbook, Z10LE, DevAlpha C

Re: Detecting Previous In-App Purchases - Design Question

I tried that already, and is not working for me. I have my app in draft mode, and i go to settings, development mode, and enter id of my drafted app. I get page of my app, and when i press download, i get error saying "cant download, network error", but i have not any network error, i can download normal apps from AppWorld, without problems.

Please use plain text.
Developer
georg22
Posts: 247
Registered: ‎11-22-2011
My Device: Blackberry Playbook

Re: Detecting Previous In-App Purchases - Design Question

I am looking for an example how to detect a previous purchase.

 

When I watch the examples at github I find something like this:

 

PaymentServiceControl {
                        id: paymentControl
                        property string id
                        property string sku
                        property string name
                        property string metadata
                        ...
                        onExistingPurchasesResponseSuccess: {
                            purchases.text = receiptsString
                        }
            
               ...
                    }
 
So when I trigger in onCreationComplete()
 
paymentControl.getExisting (bool);
 
What exactly happens here? Whats is in "receiptsString"? How can i check, if a specific SKU or ID was already purchased? When do I set the bool parameter to true? Initial, or all tever? I just dont get the whole picture.
 
Please use plain text.