1
votes

So I've been trying to find an API to integrate PayPal Payment into my Codename One App, except that I didn't find enough documentation to use the Purchase builtin feature. So I tried to use a WebView of a page hosted on my server and implemented using the paypal "checkout.js" Api.

When I load the page into Chrome, it works perfectly and the transaction is complete. But when I load it using the codename one BrowserComponent it gets stuck (See screenshot). What is the root of this problem ? Is it the fact that the browser does not support popus ? and Is there a way to fix it ?

 Button payButton = new Button("Checkout");
    payButton.addActionListener((ActionEvent evt) -> {
        Form payForm = new Form("Payment", new BorderLayout());
        WebBrowser webBrowser = new WebBrowser("http://localhost/paymentserver/web/app_dev.php/payerParticipation/5");
        payForm.add(BorderLayout.CENTER, webBrowser);
        payForm.show();
    });

Screenshot

3

3 Answers

1
votes

Try embedding firebug into the of your page to see if it reports any errors:

<script>
 if (!document.getElementById('FirebugLite')){E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;E = E ? document'createElement' + 'NS' : document'createElement';E'setAttribute';E'setAttribute';E'setAttribute';(document'getElementsByTagName'[0] || document'getElementsByTagName'[0]).appendChild(E);E = new Image;E'setAttribute';}
</script>

1
votes

Thanks for the help everybody,

I finally found a turnaround and implemented this feature on a PHP server using PayPal PHP SDK. I used the browser Navigation Callback in order to check when the payment was successful/failed.

browser.setNavigationCallback((url)->{
if (url.indexOf("success=true")!=-1){
     System.out.println("Payment complete");
}
else if (url.indexOf("success=false")!=-1){
     System.out.println("Payment failed");
}
return true;
});
0
votes

I don't have an answer for that but I did implement Braintree support for Codename One which is the official PayPal mobile API. I have a cn1lib for it implemented but I didn't get around to publishing it because of the bootcamp. Keep an eye on the blog I'll probably publish it in the next couple of weeks.