If I can take a look at your custom onclick logic please, provide us with your app id, page name, and component path.
Could you provide a link to the documentation from the screenshot?
Note - the functionality isn’t live in the app yet and you’ll notice that the custom code has a placeholder destination for purchases using a Google device.
I’m not sure I understood you correctly, please correct me if I’m wrong.
If you want to update a user record, I think after calling the block with custom code, you can add a Save Object in Backendless block and update the user with their objectId.
Or is the problem something else?
2- the custom code executes and displays a Google Pay UI for the user to subscribe to my service using an in-app payment
3 - if the user completes this process then the app will call a JavaScript function on the page gonative_iap_purchases
4 - when i know the user has completed the in-app payment process, I update the database so they are shown the content for a subscribed user
After executing the custom code in step 2 I don’t know if the user has completed the payment process or not, so I can’t update their record at that point, otherwise any user that does not complete payment will still access subscriber content.
As I understand it, the gonative.iap.purchase function will be executed in the second step.
I couldn’t find information about what this function returns in the documentation, but it’s possible it returns information about whether the operation was successful. Based on that information, you could decide to update the record in the database.
I meant that you can assign the result of the function execution to a variable within the custom code block and inspect its content.
I have a guess as to how this works, but you’ll need to create a test page with minimal logic required for testing and test data for logging in (if needed).
I think, it would be better if you create a testing page because, upon further examination of your question, I doubt that the proposed option will work. I am more inclined to believe that gonative.iap.purchase, after succeeding, will simply call gonative_iap_purchases and not return anything.
That is what I think will happen as well, I don’t think it is returned as part of the call I make, but when the payment is made by the user it is then called separately.
I am not at a point where I can test this yet, but wanted to understand if there is a usual way to access a Javascript function that is called on the page when triggered by an outside event.
Yes, but you have to figure out how it gets there. For example, If it’s added to the global scope, for example, in the window object, we can wrap it in another function that modifies the user record:
I hope you can help with a related query, that will then allow me to test the solution you have provided above.
I’m using the GoNative shell for my app. They have added the in-app payments native plugin, which uses a Javascript bridge to allow the webApp to access functionality and data from the app. https://gonative.readme.io/docs/gonative-javascript-bridge
With in-app payments, their documentation asks me to define a function using JavaScript on page load but not to call it.
If the function is called by the app when the page loads, does the console.log mean that it will return the data in a way that can be accessed through UI Builder? Or do I need to do something else to access it?
Yes, but you have to figure out how it gets there. For example, If it’s added to the global scope, for example, in the window object, we can wrap it in another function that modifies the user record:
That’s correct, you need to add this code to the Custom Code block. You will have to try different stages of page loading. As we cannot be sure when the library will add the functions.