[9.0] Do not update card in createAsStripeCustomer method #588
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At the moment when using the
createAsStripeCustomer
method on aBillable
entity, it could be that the creation of the customer succeeds but the updating of the card fails. When this happens it's impossible to know which customer was created in Stripe and therefor also impossible to remove this record again when the card update fails.It seems that the
updateCard
method shouldn't be in thecreateAsStripeCustomer
method as this couples these two API calls too much. If we remove the call from thecreateAsStripeCustomer
method it can be used just for the purpose that it states. This will always return aCustomer
object and allow the developer to remove it again if theupdateCard
method after that fails.This is a breaking change which will require developers to call the
updateCard
method manually after they callcreateAsStripeCustomer
. I've already adjusted the behavior of thegetStripeCustomer
call in theSubscriptionBuilder
so there's no breaking changes there.You might notice that at the moment the same problem exists for the
getStripeCustomer
call but at least with these changes the developers have full control to first create the customer and then do a try/catch check around theupdateCard
method and revert the customer creation if they want.This will require changes to the docs as well which I'll send in as soon as this PR is merged.
Fixes #575