braintree with angular2 and firebase

286 views
Skip to first unread message

Stefan Aerts

unread,
Nov 19, 2016, 2:05:57 PM11/19/16
to Firebase Google Group
Hi,
is the following approach possible?

1) deploy angular2 client application on firebase -> is ok already
2) create database on firebase -> ok
3) user security rules on firebase -> ok

Now the payment part is where i am trying to find out what way to go.

my idea is :

1)create a backend expressJS braintree gateway connection server that wil run on a server in a seperate application:
The code must do something like this
/**
 * Route that returns a token to be used on the client side(my angular2 client) to tokenize payment details
 */
app.post('/api/v1/token', function (request, response) {
  gateway.clientToken.generate({}, function (err, res) {
    if (err) throw err;
    response.json({
      "client_token": res.clientToken
    });
  });
});
/**
 * Route to process a sale transaction
 */
app.post('/api/v1/process', jsonParser, function (request, response) {
  var transaction = request.body;
  gateway.transaction.sale({
    amount: '100',
    paymentMethodNonce: transaction.payment_method_nonce
  }, function (err, result) {
    if (err) throw err;
    console.log(util.inspect(result));
    response.json(result);
  });
});
app.listen(3000, function () {
  console.log('Listening on port 3000');
});

2) create a client in my angular2 app that will use the v3 hosted fields solution:
and that client will connect to the server above that i have to deploy somewhere on a cloud server, i read about heroku?

I have a little angular1 app that uses the older(v2) braintree.js script and i run an express server on my localhost.
This test works.
Now what are the next step to achieve the goal ( angular2 app + braintree v3  + my express server + firebase)?

Thanks.
Kind rg,
Stefan.




Kato Richardson

unread,
Nov 21, 2016, 12:57:35 PM11/21/16
to Firebase Google Group
Hi Stefan,

You can probably slim the server stack by using a queue to talk between the client and the server, so that their interactions equate to nothing more than writing a record to the database and waiting for the server to write something back.

I hope that helps!

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8f3452c6-0d98-407a-8663-015a73568193%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages