J
J
JayJet2016-10-11 14:31:09
Classmates
JayJet, 2016-10-11 14:31:09

Where should the API_callback be located?

I work with javascript and FAPI classmates. I call FAPI.init - everything is successful. I call FAPI.UI.showPayment() - a successful purchase occurs. Question: where should the callback from the payment come from? To some function called API_callback? Where should she be? If at the same level as FAPI.init, then it is not called. In the browser console, when making a purchase, it says "Uncaught TypeError: c.__FAPI__CallBack is not a function". I put the function in different places, called it different options. Maybe it needs to be registered somewhere? I think a good hour on this.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
X
x32net, 2016-10-11
@x32net

I did this: I called a js function in the browser from AS3. The function name was chosen ala myAwesomeFunc.

R
Romas34, 2016-10-26
@Romas34

To be honest, I do not quite understand what the problem is. Yes, there should be a callback function in the script code (in the same place as the FAPI initialization function):

/*
* Эта функция вызывается после завершения выполнения следующих методов:
* showPermissions, showInvite, showNotification, showPayment, showConfirmation, setWindowSize
*/
function API_callback(method, result, data) {
    console.log("Method " + method + " finished with result " + result + ", " + data);
    if (method == "showConfirmation" && result == "ok") {
    	FAPI.Client.call(feedPostingObject, function(status, data, error) {
            console.log("status = " + status + "   data = " + data + " error == "
    	                + (error != null ? error["error_msg"] : "null"));
            getFlash().publishCallback({"status":status, "data":data, "error":error});
        }, data);
    }
    //invoke client API callback
    getFlash().onApiCallBack({"method":method, "result":result, "data":data});
}

(example taken from here: https://github.com/apiok/html_app_example/blob/mas...
it calls onApiCallBack() - a callback in as-code. Which, of course, must be registered:
That. we get into the onApiCallBack() function:
private function onApiCallBack(event: Object): void {
        trace("[OKManager] onApiCallBack: method =", event.method,
              " result =", event.result, " data =", event.data);
        if (event.method == 'showPayment') {
            .......
        } else if (event.method == "showConfirmation") {
            .......
        }
        .............
    }

J
JayJet, 2016-10-26
@JayJet

The issue has already been partially resolved. For me personally, this only works in Mozilla (always) and in Opera (once). Since I myself use Google Chrome, but it doesn’t work in it, that’s why I sounded the alarm. However, I would like it to work in Google.

N
nick_bar, 2019-05-04
@nick_bar

Question to the author. I also work with API classmates. But even my Init is wrong. Could you help?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question