Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update how braintree client tokens are generated (Implementation 2) #79

Conversation

skukx
Copy link
Contributor

@skukx skukx commented Feb 20, 2019

To promote a one to one relationship between braintree customers and
spree users, add the braintree customer id to the spree_users table.
Anytime a new client token is generated for a new payment method, pass
that customer id in as one of the options so that all new payment
methods are added to the same braintree customer associated to the spree
user.

To promote a one to one relationship between braintree customers and
spree users, add the braintree customer id to the spree_users table.
Anytime a new client token is generated for a new payment method, pass
that customer id in as one of the options so that all new payment
methods are added to the same braintree customer associated to the spree
user.
Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, looks like it resolves the issue found in the other implementation with admins getting user's tokens. Just one comment about a possible issue with a nil user object.

options[:customer_id] = user.braintree_customer_id if user.present?

braintree_gateway.generate_client_token(options)
rescue => error
Copy link
Contributor Author

@skukx skukx Feb 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious on thoughts about rescuing here. I rescue so that we don't return a 500 resulting in the user not getting a rendered page (Maybe braintree is down).

This is important as a customer may not even be using the Braintree payment method and we don't want to block them completely

@skukx skukx closed this Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants