-
-
Notifications
You must be signed in to change notification settings - Fork 76
Allows the paypal_braintree source to be added to the wallet on checkout #123
Conversation
Looking for some feedback here. This is intended to address #122. Wanted to ensure a source is always reusable and that making it a subclass of Spree::PaymentSource wasn't going to ruin anyone's day before proceeding. |
Although it would make sense, I don't think that subclassing I believe the other two changes are what is needed to get this source added to the wallet. |
Unfortunately it’s needed to subclass from PaymentSource because Solidus introduced a validation on the payment source class in https://github.com/solidusio/solidus/blob/292e7acea02803560f69a4720417f5b6d62a5808/core/app/models/spree/wallet_payment_source.rb#L13. We either should remove this validation (as this is useless IMO) or need to change this code so it only subclasses on Solidus 2.2 and above. |
Seems like solidusio/solidus#2201 should allow us to not subclass the PaymentSource. Will make appropriate changes. |
Notably thinking about this it needs to be a subclass of PaymentSource on Solidus 2.3 or this wont |
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.
I think this is the right direction to go and I think we should roll back solidusio/solidus#2201.
Please see my comments for a way to change this PR such that it should be compatible with all versions of Solidus.
@@ -1,12 +1,13 @@ | |||
module SolidusPaypalBraintree | |||
class Source < ApplicationRecord | |||
class Source < Spree::PaymentSource |
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.
Can you change this to SolidusSupport.payment_source_parent_class
please?
See solidusio/solidus_support#1
You'll also want to ensure you require at least version 0.1.2
of solidus_support in the gemspec for this gem.
PAYPAL = "PayPalAccount" | ||
APPLE_PAY = "ApplePayCard" | ||
CREDIT_CARD = "CreditCard" | ||
|
||
belongs_to :user, class_name: Spree::UserClassHandle.new | ||
belongs_to :payment_method, class_name: 'Spree::PaymentMethod' | ||
has_many :payments, as: :source, class_name: "Spree::Payment" | ||
has_many :wallet_payment_sources, class_name: 'Spree::WalletPaymentSource', as: :payment_source, inverse_of: :payment_source |
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.
You shouldn't need this if you inherit from SolidusSupport.payment_source_parent_class
@joeljackson can you please also update the gemspec to require at least version |
@jordan-brough Done. Thanks 👍 |
Thanks @joeljackson. Lgtm. Seeing if we can figure out what's wrong w/ the spec failures. |
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.
👍 the spec errors are due to the unstable test suite we had. I fixed a lot of this in master. Merging as this change is good
No description provided.