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 /v1/topups endpoints #1110

Merged
merged 5 commits into from
May 21, 2018
Merged

Conversation

jkakar-stripe
Copy link
Contributor

This add standard retrieve, create and update client support for the new /v1/topups endpoint.

@brandur-stripe
Copy link
Contributor

@jkakar-stripe Hey Jamu! We just noticed that this PR never quite made it even though its sisters in six other languages did. Do you remember if there was any particular reason why this one didn't finish up? Thanks!

@brandur-stripe
Copy link
Contributor

(And also, we're definitely interested in trying to get this done while we still have some context in our heads, so we'd like to help out in getting it through however possible.)

@jaymedavis
Copy link
Contributor

You may have to mark the option class with the IHaveMetadata interface. Thanks for taking the time to learn everything, this looks really great, fwiw. 👍

@jkakar-stripe
Copy link
Contributor Author

@brandur-stripe The main issue is that the account used to test the changes isn't opted into the feature. I think an obvious next step is to do that and then iterate on whatever problems come up.

@remi-stripe remi-stripe self-assigned this May 4, 2018

// Sleep for 5 seconds to ensure the Source is chargeable
// 1 or 2 seconds are unfortunately not enough.
System.Threading.Thread.Sleep(5000);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is awful, but I can't see another way for now 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

Fuuu :/ Yeah, I don't know of one either.


[JsonProperty("expected_availability_date")]
[JsonConverter(typeof(StripeDateTimeConverter))]
public DateTime? ExpectedAvailabilityDate { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Weirdly this value is null in Test so I had to make it optional with the ?. I feel like we should consider making all properties always optional to be resilient to changes on Stripe's end.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what you have here is correct given that it's also marked optional in the backend too.

I'm not too sure that we should go around applying this too liberally because the ? does require a little extra code to use for the user (making it a little less sound ergonomically).

On that note though. I was cross-referencing this with the API resource and noticed these fields are also optional:

  • BalanceTransactionId
  • Description
  • FailureCode
  • FailureMessage
  • StatementDescriptor

Should we add ? for them as well? These are all strings so I think the answer is "no" when comparing to other optional properties throughout the library, but it seems a little strange that nullable is only used for certain types.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think for strings it's fine. But it'd be great to figure out a better way than throwing the ? when a test breaks because it means we never fully test the edge-cases

public Dictionary<string, string> Metadata { get; set; }

[JsonProperty("source")]
public string SourceId { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I named this SourceId because it has to be a real Source id src_XXX and can't be just a token. I'm ambivalent on whether Source is a better name but worry that one day we'll turn that into a "string or hash" version again. What do you think?

If so, we likely want to match that on the StripeTopup resource.

Copy link
Contributor

Choose a reason for hiding this comment

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

SourceId works for me — there's probably some inconsistency throughout, but it matches well with the expandable conventions that we have in here (e.g., BalanceTransationId).

@remi-stripe
Copy link
Contributor

r? @brandur-stripe
cc @jkakar-stripe

@brandur-stripe
Copy link
Contributor

Left one comment above, but looks good. Thanks for taking this over Remi.

@remi-stripe
Copy link
Contributor

Answered the comment so I think for now we're good. The test failure is also unrelated (and that test works locally for me, I ran it a few times).

Should we remove the tests for that resource while it's gated or are we okay with other devs not being able to run the full test suite?

@brandur-stripe
Copy link
Contributor

Answered the comment so I think for now we're good. The test failure is also unrelated (and that test works locally for me, I ran it a few times).

Don't worry about it if you don't know the answer right away, but do you know if those test failures are just intermittent? The only thing is that we're going to need a successful build to get a released shipped.

Should we remove the tests for that resource while it's gated or are we okay with other devs not being able to run the full test suite?

It's far from perfect, but IMO it's probably okay — when I run the suite I often just copy the test key from the project anyway. What do you think?

@remi-stripe
Copy link
Contributor

Don't worry about it if you don't know the answer right away, but do you know if those test failures are just intermittent? The only thing is that we're going to need a successful build to get a released shipped.

Not sure, I had never seen those before and the Plan resource has not changed in a while so I don't get what's happening. I could not find a "rebuild" button unfortunately to force it to trigger again.

It's far from perfect, but IMO it's probably okay — when I run the suite I often just copy the test key from the project anyway. What do you think?

Works for me.

@brandur-stripe
Copy link
Contributor

Not sure, I had never seen those before and the Plan resource has not changed in a while so I don't get what's happening. I could not find a "rebuild" button unfortunately to force it to trigger again.

Kk thanks. Your other branch worked, so I think it's probably intermittent. (And FWIW, also can't find a rebuild button, but some documentation suggests that there should be one. I suspect there might be a permissions issue in here somewhere.)

@brandur-stripe brandur-stripe changed the title [wip] Add support for /v1/topups endpoints Add support for /v1/topups endpoints May 21, 2018
@brandur-stripe brandur-stripe merged commit e2806ed into master May 21, 2018
@brandur-stripe brandur-stripe deleted the jkakar/topup-client branch May 21, 2018 13:52
@brandur-stripe
Copy link
Contributor

Released as 16.2.0.

@brandur-stripe
Copy link
Contributor

brandur-stripe commented May 23, 2018

Gah. Remi, this is somewhat annoying, but I'm noticing quite a few build failures after pulling this one in. I'd say roughly one in two or so are failing.

The reason for the failures is the non-determinism around whether a source becomes chargeable in time — apparently waiting five seconds isn't always enough. Any ideas around the best way to fix this? Should we just do a longer sleep, or is there some other improvement that we should be pushing for somewhere? Thanks.

@remi-stripe
Copy link
Contributor

@brandur-stripe IMO we should simply disable the tests for that resource until we move to stripe-mock. I will open a separate PR for this.

@remi-stripe
Copy link
Contributor

Pushed #1192 Let me know what you think!

@brandur-stripe
Copy link
Contributor

Yep, thanks Remi. That makes sense to me.

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.

4 participants