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

Added support for options on the Pay Invoice API #1257

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

remi-stripe
Copy link
Contributor

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

@@ -131,6 +136,15 @@ public virtual async Task<StripeInvoice> PayAsync(string invoiceId, StripeReques
cancellationToken).ConfigureAwait(false));
}

public virtual async Task<StripeInvoice> PayAsync(string invoiceId, StripeInvoicePayOptions payOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change the first PayAsync method to call this one?

@@ -151,6 +158,14 @@ public void Pay()
Assert.Equal("invoice", invoice.Object);
}

[Fact]
public void PayOptions()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need separate tests for both methods, esp. if one simply calls the other. Can you just update the Pay test to add options?

return this.Pay(invoiceId, null, requestOptions);
}

public virtual StripeInvoice Pay(string invoiceId, StripeInvoicePayOptions payOptions, StripeRequestOptions requestOptions = null)
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 did this to avoid a breaking change but maybe it'd be cleaner to force the option?

@@ -131,6 +136,15 @@ public virtual async Task<StripeInvoice> PayAsync(string invoiceId, StripeReques
cancellationToken).ConfigureAwait(false));
}

public virtual async Task<StripeInvoice> PayAsync(string invoiceId, StripeInvoicePayOptions payOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems you an not call PayAsync with the option from the one without, it returns a compilation error


Services/Invoices/StripeInvoiceService.cs(132,20): error CS4016: Since this is an async method, the return expression must be of type 'StripeInvoice' rather than 'Task<StripeInvoice>' [/Users/remi/Workspace/bindings/stripe-dotnet/src/Stripe.net/Stripe.net.csproj]

Copy link
Contributor

@ob-stripe ob-stripe Aug 23, 2018

Choose a reason for hiding this comment

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

You want return await PayAsync(...);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

damn I tried a few variations but did not think it just wanted the await. Thanks!

@remi-stripe
Copy link
Contributor Author

Fixed PTAL @ob-stripe

@@ -123,10 +128,15 @@ public virtual async Task<StripeInvoice> UpdateAsync(string invoiceId, StripeInv
}

public virtual async Task<StripeInvoice> PayAsync(string invoiceId, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
{
return await this.PayAsync(invoiceId, null, requestOptions, cancellationToken);
Copy link
Contributor

@ob-stripe ob-stripe Aug 23, 2018

Choose a reason for hiding this comment

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

Actually, I did some research and the right approach here is to not declare this method as async and not use await. Can you update accordingly? Sorry for the extra work :/

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, are you sure that method will still appear as Async though and work as expected?

Copy link
Contributor

Choose a reason for hiding this comment

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

On third thought, it would work, but it would be a breaking change :/

Let's just get rid of the overloads and release this as a major version?

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!

@remi-stripe
Copy link
Contributor Author

@ob-stripe fixed, PTAL

@ob-stripe ob-stripe merged commit 1dd71d2 into master Aug 23, 2018
@ob-stripe ob-stripe deleted the remi-pay-invoice-options branch August 23, 2018 16:46
@ob-stripe
Copy link
Contributor

Released as 18.0.0.

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

Successfully merging this pull request may close these issues.

2 participants