Fixed check for existing Stripe Prices

Since we updated the currency variable to be lowercase we needed to
update the check for existing Stripe Price currencies to lowercase
too. Without this we will create extra Prices in Stripe, but the
functionality will still work.

We could consider using value objects for currency in future so that
we can provide an `equals` method which handles all of this for us.
This commit is contained in:
Fabien "egg" O'Carroll 2022-11-09 14:56:16 +07:00
parent eb4e591e6b
commit e255102976

View File

@ -220,7 +220,7 @@ class PaymentsService {
for (const row of rows) {
try {
const price = await this.stripeAPIService.getPrice(row.stripe_price_id);
if (price.active && price.currency.toUpperCase() === currency && price.unit_amount === amount && price.recurring?.interval === cadence) {
if (price.active && price.currency.toLowerCase() === currency && price.unit_amount === amount && price.recurring?.interval === cadence) {
return {
id: price.id
};