Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The original task: https://dev.azure.com/dynamicwebsoftware/Dynamicweb/_workitems/edit/26614
The description: "I discovered this bug while investigating a Stripe issue.
Stripe needs a customer ID to associate a transaction with their data. We retrieve the customer ID from one of the customer's saved cards (it's stored in the saved card details) and then attempt to use that ID to complete the transaction.
But if the customer has been deleted or blocked, we get an exception (preventing the payment from being processed!). This is completely stupid and must be fixed immediately, before any customer will face this.
Also, we really need to add logging of requests/responses to the Stripe provider."
Explanations of problem:
"Stripe uses a customer ID to manage payments. This is necessary so that Stripe can register a customer and link all their payments to a single account, allowing the Stripe account administrator to easily understand how many orders a customer has placed and what payment methods they use (cards, etc.). For an existing customer, their payment information will be pre-filled with Stripe data (in the Stripe payment system form), so the user receives their card details and just clicks the "pay" button.
We don't have any option to not create the customer (we MUST create a Stripe customer to make a payment). We can only create a new customer for payment or use an existing one. For saved cards, we must explicitly (there's no other way) use the existing customer data, just like for recurring orders. Regarding a new card, there's a small issue.
In the existing code, I get the saved customer ID through the saved dynamicweb card. When we create a new card, the code scans the customer's saved cards and looks for the customer ID there. However, I discovered a bug where if the customer's ID is invalid (for example, if the customer has been deleted), we get an error preventing payment.
We need the customer's ID to link the customer's new card to the general customer record in the Stripe admin panel system."
So, what I did here: