Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Braintree with Cordova for purchases in app for feature upgrades

I use Cordova for our app development. We are on Android. We have been looking into several different ways to make purchases of our products and services. We would like to make it possible to purchase directly from the app that would allow our equipment to be feature modifiable in the field.

Note: I know that there is a released plugin for PayPal found here: PayPal-Cordova-Plugin. What I need to know is if the Javascript SDK and drop in UI from the Braintree project has been used with Cordova. Are there examples of it's use?

Rather, if have you implemented the Braintree client server using Cordova and Android, where did you start and did it work out?

I have tried to include the client-side functionality:

<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script>
  braintree.setup("CLIENT-TOKEN-FROM-SERVER", "<integration>", options);
</script>

I currently don't have a server-side to setup in order to test the functionality. I would like to know if I start down this path if it will be worth my time and if anyone else has tried to implement the code using Cordova.

like image 224
CaptainBli Avatar asked Mar 26 '15 20:03

CaptainBli


1 Answers

To start I know this response might be really late, although I will still give it, since I looked for this for a long time myself.

To start off the Cordova library from Braintree is not worth investigating. I spent more than 40 hours fiddling with it and didn't find any really useful answers anywhere on the web.

The easy solution is to implement an in-app browser in Cordova, and link it to an online website. https://github.com/apache/cordova-plugin-inappbrowser

which can be added by the command: cordova plugin add cordova-plugin-inappbrowser

There you can use the very handy and easy to configure drop-in UI from Braintree.

The first problems that arose to me were the iframe Braintree uses for the Cordova implementation, I tested this on android and it did work fine and open everything well.

document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
    var ref = window.open('XXX/payment.php', 'location=yes');
}

and on the server you can just use js/php to make everything work.

like image 137
mitchken Avatar answered Sep 18 '22 11:09

mitchken