-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fixed Updating customer billing address now correctly reflected to stripe #3696
base: master
Are you sure you want to change the base?
Fixed Updating customer billing address now correctly reflected to stripe #3696
Conversation
a8ee671
to
5024303
Compare
...per_portal/app/controllers/developer_portal/admin/account/payment_details_base_controller.rb
Outdated
Show resolved
Hide resolved
...per_portal/app/controllers/developer_portal/admin/account/payment_details_base_controller.rb
Outdated
Show resolved
Hide resolved
55fcccc
to
2ef2719
Compare
match 'hosted_success', via: [:get, :post], on: :member | ||
end | ||
|
||
resource :stripe, only: %i[show edit update] do |
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.
Adding update
method for Stripe
@@ -8,7 +8,17 @@ def html_class_name | |||
end | |||
|
|||
def path | |||
admin_account_payment_details_path | |||
if payment_gateway_type == :stripe | |||
admin_account_stripe_path |
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.
This is in order for update
method to be executed on StripeController
, and not the generic PaymentDetailsBaseController
, so that billing address is updated on the payment method.
…e Stripe fixed code climate issues and failed test fixed climate code fixed failing cucumber fixed first time adding billing address fixed cuccumber faliures fixed code climate issues refactored code added missing arguments fixed failed uni test fixed code climate keep method in its own file code refactored refactored code updated stripe error fixed id faliure error
2ef2719
to
0c78c4f
Compare
2cc7132
to
17605be
Compare
|
||
customer | ||
rescue Stripe::InvalidRequestError | ||
create_customer |
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.
this changes logic. First of all I don't understand why do we rescue with create_customer
with create_customer
. Maybe retry? But then in the past, we only retried one of the options... just it is a little weird to read.
As I see it, first create customer in case we don't find an ID. We retrieve customer by ID and create it in case it's status is deleted. And we rescue when in case the retrieve
call or the deleted?
call raised. It will retry if create_customer
failed though.
I mean, I'm not sure we need to change original unless we understand why it was written like that.
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.
Just for reference: the original piece was added here: https://github.com/3scale/porta/pull/3351/files#diff-4c16dc8fb0816a60d4675d1987c5588b66341daf5edd80d0cb2fb1ececb5a9b6R47
This was to fix an issue where a reference was stored in our DB, but we couldn't find the Stripe::Customer
by that ID anymore. So, previously the situation when the customer has been deleted was checked (and the fallback was to create a new customer). But the issue still occurred, when (if I remember correctly) switching the Stripe credentials - to point to a different Stripe instance. Obviously, in this case all old references become invalid.
I think in practical this changed code works almost the same way. The only caveat I see is that if customer_id.blank?
and create_customer
throws a Stripe::InvalidRequestError
for some reason, then create_customer
would be retried again (which was not happening originally, and it would just throw directly).
I can certainly revert this change to avoid confusion.
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 was wondering why this change was made in the first place, but it turns out to be the result of a refactor, and undoing of that refactor 😬 )
@@ -47,6 +68,7 @@ def find_or_create_customer | |||
begin | |||
customer = Stripe::Customer.retrieve(customer_id, api_key) | |||
return create_customer if customer.deleted? | |||
|
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.
This is just to make RuboCop happy:
RuboCop: Add empty line after guard clause. [Layout/EmptyLineAfterGuardClause]
What this PR does / why we need it:
Changing customer billing address, in the developer portal, is updated to Stripe only when credit card details are changed. Just editing and saving billing address details creates problems, when customer details are not consistent between 3scale and Stripe. This can be forcefully fixed, when the customer updates their credit card information as well.
Expected behavior:
Editing just billing address details should update customer details on Stripe.
Which issue(s) this PR fixes
https://issues.redhat.com/browse/THREESCALE-9532
Verification steps
Mentioned in jira with snapshots