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

Add support for the PaymentIntent resource #657

Merged
merged 1 commit into from
Jun 28, 2018

Conversation

remi-stripe
Copy link
Contributor

This feature is gated so the tests are stubbed for now

r? @ob-stripe
cc @stripe/api-libraries
cc @michelle-stripe @jenan-stripe

@remi-stripe remi-stripe force-pushed the remi-add-payment-intent branch 5 times, most recently from 79dea47 to c625218 Compare June 27, 2018 21:29
@@ -38,7 +38,7 @@ Metrics/MethodLength:
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 307
Max: 350
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was hardcoded to the current size which does not make sense I think so I bumped it a lot so that others don't get lost like I was

Copy link
Contributor

Choose a reason for hiding this comment

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

You can regenerate the configuration with rubocop --auto-gen-config. Those metrics cops can be a bit annoying though, we should consider disabling some of them or setting real limits we want to enforce.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it okay to do what I did to avoid this for every future pr adding a new resource?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's fine for now. I'm guessing the largest module is Stripe::Util. We can look into fixing these metrics later.

@@ -38,7 +38,7 @@ Metrics/MethodLength:
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 307
Max: 350
Copy link
Contributor

Choose a reason for hiding this comment

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

You can regenerate the configuration with rubocop --auto-gen-config. Those metrics cops can be a bit annoying though, we should consider disabling some of them or setting real limits we want to enforce.

payment_intent = payment_intent.cancel
assert payment_intent.is_a?(Stripe::PaymentIntent)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason you didn't write tests for #capture and #confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly that rubocop was driving me nuts and I thought I'd fix it after and then forgot :)


should "be saveable" do
stub_request(:get, "#{Stripe.api_base}/v1/payment_intents/pi_123")
.to_return(body: JSON.generate(id: "pi_123", object: "payment_intent", metadata: {}))
Copy link
Contributor

Choose a reason for hiding this comment

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

When testing an instance method, instead of stubbing the retrieve request then initializing the resource with .retrieve, I'd recommend just creating the resource directly with .new. This way only one request is sent which can clarify errors if assert_requested fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mostly mimicked what is in other tests though but will fix

@remi-stripe
Copy link
Contributor Author

@ob-stripe Fixed I think, PTAL

@remi-stripe remi-stripe assigned ob-stripe and unassigned remi-stripe Jun 27, 2018

payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent")
payment_intent = payment_intent.cancel
assert payment_intent.is_a?(Stripe::PaymentIntent)
Copy link
Contributor

Choose a reason for hiding this comment

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

You're missing the assert_requested in the 3 tests for the non-standard methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes sorry. Fixed.

This feature is gated so the tests are stubbed for now
@stripe-ci stripe-ci assigned remi-stripe and unassigned ob-stripe Jun 28, 2018
@ob-stripe ob-stripe merged commit d4bd5aa into master Jun 28, 2018
@ob-stripe ob-stripe deleted the remi-add-payment-intent branch June 28, 2018 12:07
@ob-stripe
Copy link
Contributor

Released in 3.16.0.

@Kasvit
Copy link

Kasvit commented Sep 27, 2020

@ob-stripe Hello. Can you help me? I have "stripe (3.2.0)" at Gemfile.lock but if I call Stripe::PaymentIntent in rails console I get "NameError: uninitialized constant Stripe::PaymentIntent"
ruby v - 2.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants