-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add new API v2 endpoint to support Braintree Token generation #272
Open
mdavo6
wants to merge
20
commits into
spree-contrib:master
Choose a base branch
from
mdavo6:vsf-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b8ef6a1
Added braintree.js onload callback to prevent braintree not defined e…
mdavo6 5c309ef
Merge branch 'braintreejs-callback'
mdavo6 1c914f2
Add stores to backend, change checkout confirmation to only run on pa…
mdavo6 c91b50a
Add currency preference to backend:
mdavo6 5dec32e
Added device data to non-3D secure for advanced fraud prevention
mdavo6 f869376
Added recaptcha v2 to prevent fraud
mdavo6 5274177
Added recaptcha_tags for recaptcha gem
mdavo6 0c877b0
Implement braintree-submit button to allow use of gift certificate
mdavo6 8065e69
Move update_source_data to be called inside update action
mdavo6 84c5bf6
Fix issue with provider method
mdavo6 4d3801d
Update backend dropin
mdavo6 ebf622c
Remove redundant JS functions
mdavo6 2222966
Remove logos from payment partial
mdavo6 72179b6
Update formatting of payment partial
mdavo6 347d73c
Sync to master
mdavo6 95363be
Add v2 API endpoint for Vue Spree support
mdavo6 5e27b00
Revert to master
mdavo6 bf1ed15
Revert back to master
mdavo6 931b703
Revert changes to master
mdavo6 b6ee35b
Revert to master
mdavo6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
app/controllers/spree/api/v2/braintree_client_token_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
class BraintreeClientTokenController < ::Spree::Api::V2::BaseController | ||
include Spree::Api::V2::Storefront::OrderConcern | ||
before_action :ensure_order | ||
|
||
def create | ||
gateway = if params[:payment_method_id] | ||
Spree::Gateway::BraintreeVzeroBase.find(params[:payment_method_id]) | ||
else | ||
Spree::Gateway::BraintreeVzeroBase.active.first | ||
end | ||
|
||
render json: { | ||
client_token: gateway.client_token(spree_current_order, @current_api_user), | ||
payment_method_id: gateway.id | ||
} | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
config/initializers/extend_spree_permitted_checkout_attributes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
module Spree | ||
module PermittedAttributes | ||
@@payment_attributes = [:amount, :payment_method_id, :payment_method, :braintree_token, :braintree_nonce] | ||
@@source_attributes = [ | ||
:number, :month, :year, :expiry, :verification_value, | ||
:first_name, :last_name, :cc_type, :gateway_customer_profile_id, | ||
:gateway_payment_profile_id, :last_digits, :name, :encrypted_data, | ||
# Add Braintree params to allow source to be created | ||
:braintree_last_two, :braintree_card_type, :braintree_nonce | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about putting that in
api/v2/storefront/checkout/
namespace?That would put it alongside other payment-related methods: https://api.spreecommerce.org/docs/api-v2/64334a793f6d3-create-new-payment