impress-org / donation-block-for-stripe

A beautiful donation form block for WordPress. Accept donations in minutes using Stripe.
7 stars 1 forks source link

Add support for additional currencies with formatting #41

Closed DevinWalker closed 2 years ago

DevinWalker commented 2 years ago

Resolves #15 #38 #40

Description

This PR adds support for switching the currency of a donation form from USD to any other Stripe-supported currency.

I have reworked the block's panel options with a new section called "Donation Settings" that now includes the new currency select and donation levels that were previously under "Appearance Settings".

If Stripe does not support the chosen currency an error notice will appear when attempting to move from Step 1 to Step 2 (payment step).

This PR also includes currency formatting using Intl.NumberFormat as described in #15

I also added support for zero decimal currencies.

Affects

Currency formatting.

Testing Instructions

  1. Switch to zero decimal currency and test to ensure it processes correctly. The Japanese Yen is a popular one.
  2. Check that the currency formatting is working correctly for various currencies and cross-reference with popular eCommerce sites using that currency. Example: Iceland.
  3. Attempt to accept a donation using a non-Stripe supported currency and ensure an error notice displays.

Other

In the future we'll likely want to trim up the list to only the supported Stripe currencies. They support the vast majority of them though.

As well, RTL languages and currencies are not very well supported. We'll have to tackle that in a separate issue.

DevinWalker commented 2 years ago

@JasonTheAdams the merge conflicts have been resolved for this PR. As well, here's a short video that should provide some context for the features in this update: https://www.loom.com/share/ca459483ecc34e82a51e00178b650634

DevinWalker commented 2 years ago

@JasonTheAdams I didn't know about navigation.language, which looks like exactly what we want. Thanks for the tip, I'll refactor this now.