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
Highlighted
Contributor
Posts: 10
Registered: ‎03-08-2013
My Device: BB 10
My Carrier: -
Accepted Solution

payment service request freeze/ no respon

i got a problem that payment service request freezed..

this problem similiar with 

http://supportforums.blackberry.com/t5/Native-Development/Is-it-possible-to-use-PaymentService-with-...

 

but that thread says he/she got a problem with screen..

and i already test that my screen initiate well..

 

int
setup_screen()
{
	screen_buffer_t buff;
	int buffer_size[2];
	int usage = SCREEN_USAGE_NATIVE;
	int attribs[1] = {SCREEN_BLIT_END};
	int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
    if (screen_create_context(&screen_ctx, SCREEN_APPLICATION_CONTEXT) != 0) {
        return EXIT_FAILURE;
    }

    if (screen_create_window(&screen_win, screen_ctx) != 0) {
        screen_destroy_context(screen_ctx);
        return EXIT_FAILURE;
    }

    if (screen_create_window_group(screen_win, get_window_group_id()) != 0) goto fail;


    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;

    if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;


    if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&buff) != 0) goto fail;


    if (screen_get_buffer_property_iv(buff, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;


    if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;


    if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;

    return EXIT_SUCCESS;

fail:
    screen_destroy_window(screen_win);
    screen_destroy_context(screen_ctx);
    return EXIT_FAILURE;
}

 

and it's all called when a button ads clicked..

 

this my  function ... at paymentservice_purchase_request it's got freeze/ no respon.. i can't go to the next step..

 

void  MainMenuScene::Ads_Click()
{
	bps_initialize();
	if (setup_screen() != EXIT_SUCCESS) {
	   fprintf(stderr, "Unable to initialize screen.");
	   exit(0);
	}
	int exit_application = 0;
	navigator_request_events(0);
	paymentservice_request_events(0);
	paymentservice_set_connection_mode(true);

	const char* digital_good_id = "25180877";
    const char* digital_good_name = "BuyTK";
    const char* digital_good_sku = "AppTK-1";
    const char* metadata = "something";
    const char* purchase_app_icon = "something";
    const char* purchase_app_name = "TKAppPurchase";

	unsigned request_id = 0;
	if (paymentservice_purchase_request(digital_good_id, digital_good_sku, digital_good_name,metadata, purchase_app_name, purchase_app_icon, get_window_group_id(), &request_id) != BPS_SUCCESS) {
	     fprintf(stderr, "Error: purchase request failed.\n");
    }
	fprintf(stderr,"pass payment service request");
	while (!exit_application) {
	        bps_event_t *event = NULL;
	        bps_get_event(&event, -1);

	        if (event) {
	        	if (bps_event_get_domain(event) == paymentservice_get_domain()) {
	                      if (SUCCESS_RESPONSE == paymentservice_event_get_response_code(event)) {
	                          if (PURCHASE_RESPONSE == bps_event_get_code(event)) {
	                              onPurchaseSuccess(event);
	                              unsigned request_id = 0;
	                              if (paymentservice_get_existing_purchases_request(false, get_window_group_id(), &request_id) != BPS_SUCCESS) {
	                                 fprintf(stderr, "Error: get existing purchases failed.\n");
	                              }
	                          } else
	                              onGetExistingPurchasesSuccess(event);
	                      } else {
	                          failureCommon(event);
	                      }
	                  }
	        	if (bps_event_get_domain(event) == navigator_get_domain()) {
	        	        if (NAVIGATOR_EXIT == bps_event_get_code(event)) {
	        	            exit_application = 1;
	        	        } else if (NAVIGATOR_SWIPE_DOWN == bps_event_get_code(event)) {
	        	            if (paymentservice_purchase_request(digital_good_id, digital_good_sku, digital_good_name,
	        	                    metadata, purchase_app_name, purchase_app_icon, get_window_group_id(), &request_id) != BPS_SUCCESS) {
	        	               fprintf(stderr, "Error: purchase request failed.\n");
	        	            }
	        	        }
	        	   }
	        }
	}

	bps_shutdown();
    screen_destroy_window(screen_win);
    screen_destroy_context(screen_ctx);
}
Contributor
Posts: 10
Registered: ‎03-08-2013
My Device: BB 10
My Carrier: -

Re: payment service request freeze/ no respon

i delete this line paymentservice_set_connection_mode(true)...

 

finally there is response from paymentservice_purchase_request...

but the error become :

 

Error code is 2  : Payment System error. Request ID: 2  Error ID: 2  Text: Payment system is busy, please complete your other transaction and try again.

 

i really appreciate it for who response this..

 

MaMom

Contributor
Posts: 10
Registered: ‎03-08-2013
My Device: BB 10
My Carrier: -

Re: payment service request freeze/ no respon

thank god,
finally i solve this problemm...
it's all about windows_group_id..

i'm using cocos2dx ...
it's documented here
http://www.cocos2d-x.org/issues/1015

i hope it's usefull for the other who get the same problem..
nice to share..

MaMom