-
Notifications
You must be signed in to change notification settings - Fork 572
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
Interfaces for polymorphic API resources (external accounts and payment sources) #1320
Interfaces for polymorphic API resources (external accounts and payment sources) #1320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one minor confusion but otherwise this looks great and much cleaner
@@ -6,7 +6,7 @@ namespace Stripe | |||
using Newtonsoft.Json; | |||
using Stripe.Infrastructure; | |||
|
|||
public class Account : StripeEntity, IHasId, IHasObject | |||
public class Account : StripeEntity, IHasId, IHasObject, IPaymentSource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we implement Forgot Account is a source now, damn that is confusing lolIPaymentSource
on Account?
{ | ||
Account Account { get; set; } | ||
|
||
string AccountId { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we have properties in this interface. I thought maybe you wanted to be smart and use this for the nested service but it does not seem to be the case. Can you clarify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the properties declared in the interface lets you access those properties without casting, e.g.:
var payout = payoutService.Get("po_123");
var account = payout.Destination.AccountId;
vs.
var payout = payoutService.Get("po_123");
var destination = payout.Destination;
var account = null;
if (destination is BankAccount)
{
account = ((BankAccount)destination).AccountId;
}
else if (destination is Card) {
account = ((Card)destination).AccountId;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wanted to do something similar with IPaymentSource
and Customer
/ CustomerId
, but Account
is an IPaymentSource
that can never be attached to a customer :(
I could add an additional ICustomerPaymentSource
interface to do this, but not sure if worth the trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you access the Account id on an external account? You already know which account it's on since you retrieved the Payout on that account right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "why" matters. Conceptually, an external account is a payment destination that is attached to a (Stripe) account, so it makes sense that the interface reflects this. It also costs us literally nothing to add this since the two concrete classes that implement this interface already fulfill that contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree though. I think it matters to be consistent though and the fact that it does not happen on IPaymentSource feels confusing to me and not useful. If you were using it explicitly for the service I would say maybe but here I don't see the benefits. Like you could also say the same about Last4
which is on card and bank account and really useful to access without a cast right?
This is my personal opinion and I am fine to merge as is though as I agree it ultimately works and I don't want to block.
Approving! |
fa3b5cf
to
d8e2539
Compare
d8e2539
to
23c58a2
Compare
Done:
IExternalAccount
IPaymentSource
Todo (in followup PRs):
IBalanceTransactionSource
IEventDataObject
? (would replace (WIP) Consider improving StripeEvent polymorphic reference #1129)type
attribute