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: 23
Registered: ‎11-19-2012
My Device: Playbook
My Carrier: Three

[Playbook] Correct in-app payment flow?

[ Edited ]

Hi guys, would like to ask for direction implementing the in-app payment flow

 

i took the source directly from the sample code,

but i turn on the 

paymentservice_set_connection_mode(true);

 to allow local testing on my playbook device, i tried everything and it seems to work perfectly, except for one case:

  1. i initiate a purchase sequence
  2. the dialog appear, i select "Success" from the first drop down
  3. i hit the ok button
  4. A dummy "Confirm Purchase" dialog appear, even if i click on cancel, it reported as a successfull purchase

the following is the code, which report the success

if (SUCCESS_RESPONSE == paymentservice_event_get_response_code(event))
				{
					userEvent.UserEvent.UserData2 = 1; //1:means success, 0 means not success..

					if (PURCHASE_RESPONSE == bps_event_get_code(event))
					{
						// Handle a successful purchase here
						userEvent.UserEvent.StringsData[0] = paymentservice_event_get_digital_good_sku(event, 0);

						//send a single purchase event..
						this->postEventFromUser(userEvent);
					}
					else
					{
						// Handle a successful query for past purchases here
						int numPurchases = paymentservice_event_get_number_purchases(event);

						for(int x=0;x<numPurchases;x++)
						{
							userEvent.UserEvent.StringsData[0] = paymentservice_event_get_digital_good_sku(event, x);

							this->postEventFromUser(userEvent);
						}
					}
				}
				else
				{

 if i click "Cancel" or "Buy Now" on step 4, it will always get pass this logic

if (SUCCESS_RESPONSE == paymentservice_event_get_response_code(event)) { // Handle a successful purchase here

ergo my program will "Handle a successful purchase here.." block

 

i guess it should go with 

SUCCESS_RESPONSE != paymentservice_event_get_response_code(event)

if i click on cancel.. unfortunately it goes with

SUCCESS_RESPONSE == paymentservice_event_get_response_code(event)

did i miss something? did i mis-intrepret what the document says? if so, how do i catch a "Cancel" from a payment confirmation event?

 

I hope you understands what i'm trying to say here Smiley Happy

 

Thanks for your time Smiley Wink

Highlighted
Developer
Posts: 110
Registered: ‎10-22-2011
My Device: PlayBook, Bold 9650, Dev Alpha A
My Carrier: Sprint

Re: [Playbook] Correct in-app payment flow?

I believe I saw this before while looking into the Payment Service on Tablet OS. I seem to recall that leaving test mode allowed capturing the Cancellation (of course, I didn't test an actual purchase that way, especially since I never put the app up for download).

This is probably a bug from our eyes, and a feature from RIM's. Smiley Sad


Is there a helpful or useful post in this thread? Click the thumbs up on it so that other people can find it more easily!
Like this post too! Smiley Very Happy