Run prettier on all *.md files

```
prettier '{app,source}/**/**.md' --write
```
This commit is contained in:
Oliver Davies 2020-03-08 17:52:59 +00:00
parent a3ceeaf0f3
commit 85a10c545b
170 changed files with 5127 additions and 2282 deletions

View file

@ -1,30 +1,44 @@
---
title: "Drupal 8 Commerce: Fixing 'No Such Customer' error on checkout"
date: 2018-08-15
excerpt: Fixing a Drupal Commerce error when a user tries to complete a checkout.
excerpt:
Fixing a Drupal Commerce error when a user tries to complete a checkout.
tags:
- drupal
- drupal-8
- drupal-commerce
- stripe
- drupal
- drupal-8
- drupal-commerce
- stripe
---
Recently I was experiencing an issue on the Drupal 8 website Im working on, where a small number of users were not able to complete the checkout process and instead got a generic `The site has encountered an unexpected error` message.
Looking at the log, I was able to see the error being thrown (the customer ID has been redacted):
Recently I was experiencing an issue on the Drupal 8 website Im working on,
where a small number of users were not able to complete the checkout process and
instead got a generic `The site has encountered an unexpected error` message.
> Stripe\Error\InvalidRequest: No such customer: cus_xxxxxxxxxxxxxx in Stripe\ApiRequestor::_specificAPIError() (line 124 of /var/www/vendor/stripe/stripe-php/lib/ApiRequestor.php).
Looking at the log, I was able to see the error being thrown (the customer ID
has been redacted):
Logging in to the Stripe account, I was able to confirm that the specified customer ID did not exist. So where was it coming from, and why was Drupal trying to retrieve a non-existent customer?
> Stripe\Error\InvalidRequest: No such customer: cus_xxxxxxxxxxxxxx in
> Stripe\ApiRequestor::\_specificAPIError() (line 124 of
> /var/www/vendor/stripe/stripe-php/lib/ApiRequestor.php).
Logging in to the Stripe account, I was able to confirm that the specified
customer ID did not exist. So where was it coming from, and why was Drupal
trying to retrieve a non-existent customer?
## Investigation
After some investigation, I found a table in the database named `user__commerce_remote_id` which stores the remote customer ID for each payment method (again, the customer ID has been redacted).
After some investigation, I found a table in the database named
`user__commerce_remote_id` which stores the remote customer ID for each payment
method (again, the customer ID has been redacted).
![A screenshot of a row in the user__commerce_remote_id table](/images/blog/commerce-stripe-error/remote-id-table.png){.border.p-1}
The `entity_id` and `revision_id` values in this case refer to the user that the Stripe customer has been associated with.
The `entity_id` and `revision_id` values in this case refer to the user that the
Stripe customer has been associated with.
As there was no customer in Stripe with this ID, I think that this must be a customer ID from the test environment (the data from which was deleted before the site went live).
As there was no customer in Stripe with this ID, I think that this must be a
customer ID from the test environment (the data from which was deleted before
the site went live).
### Drupal code
@ -77,4 +91,6 @@ private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $err
## Solution
After confirming that it was the correct user ID, simply removing that row from the database allowed the new Stripe customer to be created and for the user to check out successfully.
After confirming that it was the correct user ID, simply removing that row from
the database allowed the new Stripe customer to be created and for the user to
check out successfully.