Skip to content

Adds retrieve payment methods customer endpoint#1

Merged
macaugh merged 5 commits intomasterfrom
add-retrieve-payment-methods
Feb 26, 2025
Merged

Adds retrieve payment methods customer endpoint#1
macaugh merged 5 commits intomasterfrom
add-retrieve-payment-methods

Conversation

@macaugh
Copy link

@macaugh macaugh commented Feb 24, 2025

This PR introduces a new request handler to simulate retrieving a payment method for a customer in the Stripe mock environment. The new handler is registered via the Customers.included callback using the route:

get /v1/customers/([^/]+)/payment_methods/([^/]+)

The corresponding method, retrieve_payment_method, extracts the customer ID and payment method ID from the URL, validates the existence of the customer, and then searches for the payment method within the customer's stored sources. If the payment method is not found, it raises an appropriate error.

I found based on the docs that to test you need to run the following:

$ bundle install
$ bundle exec rspec

However this led to a lot of errors.
To test the specific functions added you can use the following

bundle exec rspec spec/instance_spec.rb

@macaugh macaugh self-assigned this Feb 24, 2025
@macaugh macaugh requested a review from hhoopes February 24, 2025 20:54
@macaugh macaugh marked this pull request as ready for review February 25, 2025 20:46
Copy link
Author

@macaugh macaugh left a comment

Choose a reason for hiding this comment

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

Still trying to decide our best option here. I'm thinking that this would work for us for now but I don't think it would be appropriate to upstream.

@hhoopes
Copy link

hhoopes commented Feb 25, 2025

It seems like a solid first pass for improving our ability to use this gem! Will be interesting to get to upgrade the gem and start removing manual mocks from our tests.

@macaugh macaugh merged commit 0d49bff into master Feb 26, 2025
3 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