Skip to content

Copy id over Solidus' payment response_code on Stripe's payment intent creation#239

Merged
waiting-for-dev merged 1 commit into
masterfrom
waiting-for-dev/response_code_on_pi_creation
Mar 22, 2023
Merged

Copy id over Solidus' payment response_code on Stripe's payment intent creation#239
waiting-for-dev merged 1 commit into
masterfrom
waiting-for-dev/response_code_on_pi_creation

Conversation

@waiting-for-dev

Copy link
Copy Markdown
Contributor

Summary

On #222, we're handling the payment_intent.succeeded webhook by fetching the associated payment via the Spree::Payment#response_code field. However, the response code wasn't filled until after the authorization was completed on Stripe. Once we implement auto-capture (see #178), that could be an issue, as we could receive the webhook before the column update.

We're now filling response_code just after the payment intent creation, which always happens before confirmation on Stripe (see #231).

Closes #238

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/response_code_on_pi_creation branch from ec0d0e1 to e519474 Compare March 21, 2023 14:24

@elia elia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Left two suggestions for your consideration, but happy to see this merged as it is as well 👍

Comment thread app/models/solidus_stripe/gateway.rb Outdated
Comment thread app/models/solidus_stripe/gateway.rb Outdated

@kennyadsl kennyadsl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Left a question before approval.

Comment thread app/models/solidus_stripe/gateway.rb Outdated
).tap { confirm_stripe_payment_intent(_1.id) }
)
.tap { confirm_stripe_payment_intent(_1.id) }
.tap { payment.update_column(:response_code, _1.id) } # rubocop:disable Rails/SkipsModelValidations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider updating the response code before calling confirm_stripe_payment_intent ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, that was the whole point of this PR 😅 Changed, thanks for pointing out.

@rainerdema rainerdema left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

…t creation

On #222, we're handling the `payment_intent.succeeded` webhook by
fetching the associated payment via the `Spree::Payment#response_code`
field. However, the response code wasn't filled until after the
authorization was completed on Stripe. Once we implement auto-capture
(see #178), that could be an issue, as we could receive the webhook
before the column update.

We're now filling `response_code` just after the payment intent
creation, which always happens before confirmation on Stripe (see #231).

Closes #238
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/response_code_on_pi_creation branch from e519474 to 8154a41 Compare March 22, 2023 04:44
@waiting-for-dev

Copy link
Copy Markdown
Contributor Author

Merging, as CI will be fixed with solidusio/solidus_starter_frontend#332

@waiting-for-dev waiting-for-dev merged commit 8e1b68e into master Mar 22, 2023
@waiting-for-dev waiting-for-dev deleted the waiting-for-dev/response_code_on_pi_creation branch March 22, 2023 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fill payment response code on Stripe's payment intent creation

4 participants