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.