Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Strip whitespace on payment methods form fields. #66

Closed
jacquesporveau opened this issue Mar 8, 2017 · 1 comment
Closed

Strip whitespace on payment methods form fields. #66

jacquesporveau opened this issue Mar 8, 2017 · 1 comment

Comments

@jacquesporveau
Copy link

When visiting /admin/payment_methods/:id/edit and saving a BraintreeGateway payment method if the user makes an error in copying and pasting by including leading or trailing whitespace on any of the API key fields it isn't stripped.

This causes errors when trying to generate gateway tokens etc and could give the user a wtf moment. I propose either stripping the whitespace on save or adding a validation to check that the keys don't include leading or trailing whitespace.

Yes this happened to me.

@tvdeyen
Copy link
Member

tvdeyen commented Apr 29, 2017

This is not related to this Gem. It rather is something that should be handled in core. Could you please open an issue there? Thanks.

Just a note about storing credentials: You should not store API credentials in the database at all. Use static configuration with ENV vars instead.

Here is an example

# config/initializers/spree.rb
Spree::Config.static_model_preferences.add(
  SolidusPaypalBraintree::Gateway, 'braintree_credentials', {
    environment: Rails.env.production? ? 'production' : 'sandbox',
    merchant_id: ENV['BRAINTREE_MERCHANT_ID'],
    public_key: ENV['BRAINTREE_PUBLIC_KEY'],
    private_key: ENV['BRAINTREE_PRIVATE_KEY']
  }
)

@tvdeyen tvdeyen closed this as completed May 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants