Skip to content
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

Use statement_descriptor_suffix for card payments and fallback to Stripe account statement descriptions for all payments #2833

Merged
merged 11 commits into from Jan 24, 2024

Conversation

james-allan
Copy link
Contributor

@james-allan james-allan commented Jan 16, 2024

Fixes #2830

Changes proposed in this Pull Request:

According to Stripe's docs, using the statement_descriptor parameter for card payments is deprecated since January 2nd 2024. We're suppose to be using statement_descriptor_suffix instead.

No one internally has been able to replicate this issue, however many merchants have already reported this and experiencing this error.

This PR does a number of things to fix this:

  1. Customisable Statement descriptors from within the plugin settings are essentially removed.
    • The Stripe plugin settings screen now pulls the statement descriptions from the Stripe Account.
    • These fields are no longer editable.

Screenshot 2024-01-16 at 5 35 41 pm

  1. To make sure changes that users make to their Stripe Account are instantly reflected in the WC Settings. I've made sure that the account cache is cleared on loading the Stripe settings page.
  2. All transactions now don't pass the statement_descriptor arg.
    • Stripe already sets the transaction statement description to the one set on the account anyway.
  3. If the store has enabled dynamic statement descriptions (the "Add customer order number to the bank statement" setting), Card transactions now provide that via the statement_descriptor_suffix.

Testing instructions

Base tests

  1. Go to the Stripe plugin settings.
    • On develop you'll notice the bank statement description settings are customisable.
    • On this branch those text fields are now read only and cannot be changed. I've also added some information about how merchants can update those bank statement descriptors.
Before After
Screenshot 2024-01-16 at 5 47 11 pm Screenshot 2024-01-17 at 3 57 20 pm
  1. On this branch switching between checking the "Add customer order number to the bank statement" setting should still toggle the example statement descriptions.
  2. Change the statement descriptions in your Stripe settings (https://dashboard.stripe.com/settings/public). Refresh the Stripe plugin settings page and notice the changes are reflected in the settings immediately.

Repeat the following steps with both UPE enabled and disabled.

  1. Turn off the "Add customer order number to the bank statement" setting.
  2. Make a purchase using the Card payment method.
  3. View the transaction in your Stripe dashboard.
    • It should include a statement descriptor which matches the setting in the Stripe settings and Stripe plugin settings

Screenshot 2024-01-16 at 5 53 51 pm

  1. Place an order and use another PM like Giropay.
    • Note: other APMs don't include bank statement descriptions.
  2. Place an order and use Google or Apple pay.
  3. View the transaction in your Stripe dashboard.
    • It should include a statement descriptor which matches the setting in the Stripe settings and Stripe plugin settings.
  4. Turn on the "Add customer order number to the bank statement" setting.
  5. Repeat all the example purchases I mentioned above.
    • APM (Giropay) - Still no statement description.
    • Card payments and express payment methods (Google or Apple Pay) - you should see the statement description now includes the order number.

Screenshot 2024-01-16 at 6 02 09 pm


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge


// Stripe requires at least 1 latin (alphabet) character in the suffix so we add the first character of the prefix before the order number.
if ( 0 === preg_match( '/[a-zA-Z]/', $suffix ) ) {
$suffix = substr( $prefix, 0, 1 ) . ' ' . $suffix;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to add some additional details for the reviewer. Stripe requires the statement_descriptor_suffix to have at least 1 latin character in it - ie an letter from the alphabet.

Normally the get_order_number() wouldn't include a letter as it would just be #1245. Some folks do customise the order number to include a letter so I've made this conditional based on that.

If the order number doesn't include a letter, I just took the first letter of the prefix from the Stripe account settings and added it.

eg the suffix may look like this WCDEV* W #123.

I considered an "O" for order. I considered the customers first name initial. I didn't like either of those two options though. Feedback is very welcome :)

@james-allan james-allan requested review from a team and diegocurbelo and removed request for a team January 19, 2024 00:04
@james-allan
Copy link
Contributor Author

I managed to actually get this error today.

Screenshot 2024-01-19 at 10 14 54 am

I'm not sure why but to replicate I had to use a Brazilian Stripe account. It might not be limited to Brazil merchants. Perhaps its just new users. 🤷‍♂️

@james-allan james-allan changed the base branch from develop to trunk January 19, 2024 07:29
@james-allan
Copy link
Contributor Author

@diegocurbelo I'm just noting that because develop has now progressed past trunk and I suspect we'll want to release a patch for this, I've rebased this PR and pointed it at trunk rather than develop.

I'm still not sure what causes it. But now that I have been able replicate on own account I have a feeling it's either new accounts or specific to certain countries.

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work investigating this @james-allan!

The code looks good, and it works great (the fields updating with the Stripe on refresh are great).

The required latin character in the suffix is not ideal, and I don't have a different idea 🤷🏼, but we should update the preview in the settings to reflex that extra character.

Screenshot 2024-01-19 at 18 57 11

@james-allan
Copy link
Contributor Author

we should update the preview in the settings to reflex that extra character.

Thanks for the feedback @diegocurbelo. I've updated the statement previews to include the latin character inserted into the description. I changed the description in my Stripe settings to confirm it is updated in the previews too.

Screenshot 2024-01-22 at 6 11 12 pm Screenshot 2024-01-22 at 6 03 40 pm

@diegocurbelo diegocurbelo self-requested a review January 23, 2024 23:12
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @james-allan! 🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use statement_descriptor_suffix when making card payments
2 participants