amosproj / amos2021ss07-bike-nest

MIT License
1 stars 0 forks source link

Braintree ClientToken Generation works #149

Closed rmandlx closed 3 years ago

rmandlx commented 3 years ago

Now one can generate a clientToken for use in the frontend by accessing localhost:9000/payment/getclienttoken

Interesting notes: in the beginning, it didn't work, because its not enough to just call the generate function. You have to create a customer for braintree first. This customer can contain information about the user like first name, last name, address and so on, but it is not required. The important thing is, that we register our users as customers and remember the id, that braintree assignes to them. Or as in our case: we tell braintree that they should use our userId also as their customerId. That way, whenever we need to provide a customerId, we just use the userId.

The alternative solution would have been, to store the customerId and userId in a table, so that we can map our userIds to braintree customerIds.