braintree / braintree-web

A suite of tools for integrating Braintree in the browser
https://developer.paypal.com/braintree/docs/start/hello-client/javascript/v3
MIT License
444 stars 134 forks source link

payment_methods endpoint returns hasSubscription true for canceled subscriptions #571

Open charidimostzed opened 3 years ago

charidimostzed commented 3 years ago

General information

Issue description

Hello there,

Regarding the /payment_methods endpoint, we noticed thathasSubscription:true is returned for cards that their subscriptions have been canceled. Are there any recent changes to the endpoint?

Is this maybe connected to https://github.com/braintree/braintree-web/issues/566?

Thank you in advance

crookedneighbor commented 3 years ago

I don't think it's related to #566

I think the logic we are using to populate the value just checks if there is a subscription object attached to the payment method at all, regardless of the status of the subscription.

We'll have to think about the best way to handle this situation. It's pretty clear cut that the subscription is tied to the payment method when the status is active and no longer tied to the payment method when canceled, but I'm not 100% sure on the situations for the other statuses.

My assumption here is that expired and past due subscription would also have hasSubscription: false while pending would have hasSubscription: true, but I want to check in with my team and the owners of the API before making those changes. Basically, we can only due that if canceled, expired, and past due are terminal states, indicating that there's no way for the subscription to be re-activated. Otherwise, we risk creating a breaking change.

charidimostzed commented 3 years ago

What we observed is that on some cases hasSubscription:true is returned even if the state of the subscription is canceled.

Thanks a lot for the reply, looking forward for the solution that will be covering all the terminal states.

crookedneighbor commented 3 years ago

OK, I've done a little research on this.

I think I'm correct that if a payment method has an associated subscription in a pending or active state, it should have hasSubscription: true.

canceled and expired subscriptions are indeed terminal states, so I think it's safe to update the logic to hasSubscription: false for those states.

past due however, is not a terminal state. Parts of the subscription can be updated: https://developer.paypal.com/braintree/docs/guides/recurring-billing/manage#updating-past-due-subscriptions

So I think it's a little up to interpretation here whether or not a past due state should indicate it has a subscription or not. Because deleting a payment methods with a past due subscription will result in the subscription being put into a canceled state, which is terminal, I think it's probably safest to indicate that payment methods with subscriptions that are past due should report hasSubscription: true. That way, if the logic about whether to allow deleting a payment method on the client is using hasSubscription as the determiner, past due subscriptions won't be accidentally cancelled by deleting a payment method.

Does that track with your use case @charidimostzed ? Or do you have a different perspective?

charidimostzed commented 3 years ago

Hello @crookedneighbor, yes this is covers up our needs fully. Thank you very much!

charidimostzed commented 2 years ago

Hello @crookedneighbor! Do we have any updates on this one? thank you very much

crookedneighbor commented 2 years ago

No update yet, we have a lot of things on our plate and this has not yet been prioritized. I would encourage you to reach out to our support team or your account manager to get more visibility on this improvement.

charidimostzed commented 2 years ago

@crookedneighbor thanks a lot for the reply!