FB.ui pay method comes up with "An error occurred, please try again later"

1.1k views Asked by At

guys, We're developing a game that will receive payments via FB Credits transactions, and the problem we face is "An error occurred" message once the FB.ui with 'pay' method gets displayed. I tried to debug the whole thing but it's already taking ages to find out what may be causing this. I am really desperate on fixing this already! Please help!

I created a test FB app that has absolutely everything removed but the most necessary stuff left in order to initiate a payment. You can access it here:

http://apps.facebook.com/paymentproblemapp

Here is also some of my FB JS API initialization code, which you can also find in the app in script called fbapps-testapp-facebook-1.0.js:

the init function

init : function() {

  window.fbAsyncInit = function() {
    FB.init({
      appId : window.APP_ID,
      status : true,
      cookie : true,
      oauth : true,
      channelUrl : window.MASTER_URL + "channel",
      frictionlessRequests : true
    });
  };

  (function(d){
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
  }(document));

},

and the payment function:

// order_info to be constructed in swf
placeOrder : function(order_info, swfOrderCallback) {
  var onOrderPlaced = function(data) {
    if (swfOrderCallback) {
      // further actions within the swf due to payment

      if (data['order_id']) {
        // TODO successful payment
        return true;
      } else {
        // handle errors here
        return false;
      }
    }
  };

  // calling the payment dialog
  try {
    FB.ui({
      method : 'pay',
      order_info : order_info,
      purchase_type : 'item',
      dev_purchase_params : {
        'oscif' : false
      }
    }, onOrderPlaced);
  } catch (err) {
    // TODO handle payment error
  }
}

Any help will be greatly appreciated! Thank you!

1

There are 1 answers

0
Pascal On

Make sure you call placeOrder() after FB.init().