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: 24
Registered: ‎02-06-2012
My Device: developer
My Carrier: -
Accepted Solution

Is it possible to use PaymentService with cocos2d-x?

[ Edited ]

Application (used cocos2d-x) freezed in paymentservice_purchase_request, looks like modal dialog exists, but not visible.

 

But sample from NDK-Samples works fine.

Contributor
Posts: 24
Registered: ‎02-06-2012
My Device: developer
My Carrier: -

Re: Is it possible to use PaymentService with cocos2d-x?

Tryed add PaymentService to CubeRotate - same effect. No purchase dialog visible at top of window with opengl graphics. At least in simulator.

Retired
Posts: 25
Registered: ‎01-30-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Is it possible to use PaymentService with cocos2d-x?

Can you please elaborate a bit more, so I can try (and investigate) it here? A snippet of code would be helpful.

Contributor
Posts: 24
Registered: ‎02-06-2012
My Device: developer
My Carrier: -

Re: Is it possible to use PaymentService with cocos2d-x?

In CubeRotation sample

In file main.cpp before line

 

while (!exit_application) {

 

i've inserted:

paymentservice_request_events(0);
paymentservice_set_connection_mode(true);
const char* digital_good_id = "Digital-Good-1-ID";
const char* digital_good_name = "Sample Digital Good 1";
const char* digital_good_sku = "SAMPLE_DIGITAL_GOOD_SKU_1";
const char* metadata = "Sample purchase metadata";
const char* purchase_app_icon = "http://www.rim.com/products/appworld_3col.jpg";
const char* purchase_app_name = "Payment Service Sample App";
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");
}

 

 

Retired
Posts: 25
Registered: ‎01-30-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Is it possible to use PaymentService with cocos2d-x?

[ Edited ]

The event loop (where you inserted your code) is the responsible for dispatching all the events that happen to your application so they can be routed property.

 

If you make anything modal there, you will basically choke your application from receiving gestures (for example, clicking a button).

 

while (!exit_application) 
{
  //Request and process BPS next available event
  bps_event_t *event = NULL;
  rc = bps_get_event(&event, 0);
  assert(rc == BPS_SUCCESS);

  if (event) 
  {
    int domain = bps_event_get_domain(event);

    if (domain == screen_get_domain()) 
    {
 
      /* 
       * [fsimoes] If you comment out this line, your 
       * application won't be able to handle touch gestures. 
      */ 
      handleScreenEvent(event);
    } 
    else if ((domain == navigator_get_domain())
	&& (NAVIGATOR_EXIT == bps_event_get_code(event))) 
    {
      exit_application = 1;
    }
  }

  render();
}

 

 

The best solution would be moving the code you inserted in the event loop to a worker thread, created when you press a button (or click the cube), for example.

 

Contributor
Posts: 24
Registered: ‎02-06-2012
My Device: developer
My Carrier: -

Re: Is it possible to use PaymentService with cocos2d-x?

I'm inserted purchase request BEFORE event handling loop, and event handling code doesn't reached, because i must do something in purchase debug window, but can't, since doesn't see it.

Contributor
Posts: 24
Registered: ‎02-06-2012
My Device: developer
My Carrier: -

Re: Is it possible to use PaymentService with cocos2d-x?

[ Edited ]

I'm found problem with Rotating Cube and purchases. In window creation code no call of screen_create_window_group :smileyhappy: