Skip to content
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

Support preauth and refunds on PaymentIntents #224

Merged

Conversation

bpcreech
Copy link

@bpcreech bpcreech commented Sep 3, 2024

localstripe already supports Charges with pre-auths and refunds, and it supports PaymentIntents without pre-auths or refunds.

Since PaymentIntents are either preferred or supported for most APIs now, let's support pre-auths on PaymentIntents! Since the PaymentIntent implementation in localstripe just proxies most stuff onto Charge objects, we can proxy pre-auths onto them too. Same for refunds.

We are already using this at Via (ridewithvia.com) to test our Stripe integration.

The tests are a big copy-paste-modify on the Charges tests, which seem pretty comprehensive... and we add tests for refunds on both Charges and PaymentIntents.

@bpcreech bpcreech force-pushed the feat/payment-intent-preauth branch 2 times, most recently from 9aad34f to 3777c29 Compare September 4, 2024 02:22
@bpcreech bpcreech changed the title Support preauth on PaymentIntents Support preauth and refunds on PaymentIntents Sep 4, 2024
@adrienverge
Copy link
Owner

adrienverge commented Sep 11, 2024

Hello @bpcreech,

Thanks for contributing upstream! I have to point out that this is a high-quality pull request with clean code, explanation and tests.
(By the way can you include the text from your PR inside the commit message?)

The refactor of Charge looks clean, and the additions to PaymentIntent and Refund seem to make sense. I haven't tested them thoroughly, but my private test suite passes on it 👌

Do you see any points of attention we should look into before merging this?

Before this commit, localstripe already supported Charges with pre-auths and
refunds, and it supported PaymentIntents without pre-auths or refunds.

Since PaymentIntents are either preferred or supported for most APIs now, let's
support pre-auths on PaymentIntents! Since the PaymentIntent implementation in
localstripe just proxies most stuff onto Charge objects, we can proxy pre-auths
onto them too. Same for refunds.

We are already using this at Via (ridewithvia.com) to test our Stripe
integration.

The tests are a big copy-paste-modify on the Charges tests, which already seemed
pretty comprehensive... and we add tests for refunds on both Charges and
PaymentIntents.
@bpcreech
Copy link
Author

Thanks @adrienverge, and thanks very much for creating and open-sourcing localstripe! It let us retire a far less confidence-building mock we had for our Stripe integration. :)

I updated the git commit message to match the PR.

I don't know of thing to look into. We're using this with a pretty extensive test suite (717 total tests!) which runs the very same tests against the Stripe test API, so I have some confidence that it is an accurate simulation of the surface area we use. (That said, there's lots more to the API and surely areas we aren't simulating right yet.)

The part where we (continue to) proxy to the Charges implementation seems like it might be regrettable some day but I don't understand enough of the nuance to know how an implementation specialized for PaymentIntents would be any different.

@adrienverge
Copy link
Owner

OK 👍

Thanks a lot @bpcreech! Let's release it.

@adrienverge adrienverge merged commit ebe8730 into adrienverge:master Sep 16, 2024
6 checks passed
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.

2 participants