-
-
Notifications
You must be signed in to change notification settings - Fork 76
Conversation
Adds the concept of a solidus transaction, representing the users interaction with braintree's javascript
end | ||
|
||
def user | ||
order.user || nil |
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.
|| nil
doesn't make sense
This is useful for payment methods that largely skip the normal checkout flow, like apple pay or paypal one touch. Will be expanded to handle addresses and extra param.
Doesn't exactly map to our addresses, so we'll pick that up in email.
7d9cc66
to
e86dc28
Compare
Still need to allow customization of the import
Its pretty reasonable for solidus' use case to expect both and email and a phone.
This isn't all the javascript required to go through and end-to-end apple pay, but it provides the heavy-lifting between the frontend and the backend API's.
Not required to be used if you want to write your own, but this should get most people what they need in order to enable their payment methods.
Probably covers most peoples use cases, but feel free to override.
These didn't include phone or email, both of which are required.
cd82825
to
80246fc
Compare
I'm not sure restricting to display_on :front_end is valid, as that will put the payment method in the "usual checkout flow", even though often we wouldn't want it to be. |
I was unsure of that as well - I'll remove that restriction. Scoping it to the gateway will likely be good enough. |
80246fc
to
2e8ce21
Compare
last_name: ta.last_name, | ||
city: ta.city, | ||
country: country, | ||
state: country.states.find_by_abbr(ta.state_code), |
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.
Solidus will do this for us if we simply pass in the state_code
to state_name
.
👍 Just one minor comment. Fine with either approach. |
|
||
def address | ||
transaction.address.try do |ta| | ||
country = Spree::Country.find_by_iso(ta.country_code) |
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.
find_by(iso: ta.country_code)
Upcase country
This will make use of the [state_validate][1] validation in Solidus, saving us a bit of work. [1]: https://github.com/solidusio/solidus/blob/master/core/app/models/spree/address.rb#L174
Due to the order and payment having new identifiers on each run, we would never match the body of the request. Since we had VCR configured to record new episodes by default, it would just keep appending to the end of the file. This ensures the body will match by always using the same identifiers and also removes the global config option to record new episodes.
Save payment type to source
Provides javascript and endpoints to execute a `SolidusPaypalBraintree::Transaction".
This
Transaction
object is intended to model an "external transaction" that takes place between a user in javascript and Braintree, for which we need to import the details of after it is completed.