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 #1222

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

remi-stripe
Copy link
Contributor

@remi-stripe remi-stripe commented Jul 4, 2018

This PR adds support for the Payment Intent resource.

cc @stripe/api-libraries @michelle-stripe @jenan-stripe
cc @stevene-stripe

fixture.PaymentIntent.Amount.Should().Be(fixture.PaymentIntentCreateOptions.Amount);
fixture.PaymentIntent.CaptureMethod.Should().Be(fixture.PaymentIntentCreateOptions.CaptureMethod);
fixture.PaymentIntent.Currency.Should().Be(fixture.PaymentIntentCreateOptions.Currency);
fixture.PaymentIntent.AllowedSourceTypes.Count.Should().Be(fixture.PaymentIntentCreateOptions.AllowedSourceTypes.Count);
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 could not, for the life of me, figure out how to compare the 2 lists. I tried a lot of options but none worked/compiled for some reasons so I settled for the count for now.


namespace Stripe.Infrastructure.Middleware
{
internal class PaymentIntentAllowedSourceTypesPlugin : IParserPlugin
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 one is dirty/sad but it's just temporary because I needed to make it work. We should ship only after @ob-stripe other PR #1218 instead.

namespace Stripe
{
public class StripePaymentIntentConfirmOptions : StripeBaseOptions
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are a bit frustrating, they each support a subset of the other endpoints params. Not sure this was the best approach

{
public class StripePaymentIntentTransferDataOptions : INestedOptions
{
[JsonProperty("transfer_data[amount]")]
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'll never understand why we need to repeat the parent property's parameter name. Haven't tested either as the test suite would require a custom account and all that.


[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

missing support for next_source_action

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, though the code feels really ugly 😢

@@ -0,0 +1,145 @@
using System;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you confirm that the folder structure is the right approach?

@ob-stripe
Copy link
Contributor

@remi-stripe Looks like this one also needs to be rebased and fixed.

@remi-stripe
Copy link
Contributor Author

Yes, we should hold off a bit on that one since the API could be changing in the next few days. I'll rebase once we know the exact/final shape

@remi-stripe remi-stripe force-pushed the remi-add-payment-intents branch from 5d03899 to a07c807 Compare September 22, 2018 21:55
@remi-stripe
Copy link
Contributor Author

r? @ob-stripe assigning to you for review as I've redone the PR to match the new test suite and future naming. Some users need this asap so it could not wait the next major revision after all.

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

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

Minor comments, but lgtm overall.

{
AuthorizeWithUrl,
None,
Unknown,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have Unknown as the first value in the enum, so that when you initialize a new PaymentIntentSourceActionType, the Type field defaults to Unknown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm sure but that breaks the "alphabetical order" rule :)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine. I don't think it makes sense for enums anyway -- if we add a new value to an existing enum, we should append it after all existing values, otherwise it's technically a breaking change.

using Newtonsoft.Json;

public class PaymentIntentConfirmOptions : StripeBaseOptions
{
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the OpenAPI spec, this request also has an additional client_secret string parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a client-side property used with the publishable key, I'm not sure this is a useful parameter in the server-side library. Do you still think I should add it? It's not in our docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack, let's ignore it for now -- we can always append it later if needed.

@remi-stripe remi-stripe force-pushed the remi-add-payment-intents branch from a07c807 to 25492a3 Compare September 24, 2018 11:51
@remi-stripe
Copy link
Contributor Author

@ob-stripe PTAL

@remi-stripe remi-stripe changed the title [WIP] Add support for the PaymentIntent resource Add support for the PaymentIntent resource Sep 24, 2018
@remi-stripe remi-stripe merged commit 9dd9875 into master Sep 24, 2018
@remi-stripe remi-stripe deleted the remi-add-payment-intents branch September 24, 2018 13:17
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.

2 participants