From 3bbd21d5e2613191f210acef0c7a2681d29696a1 Mon Sep 17 00:00:00 2001 From: nishekh-e-r Date: Thu, 22 Dec 2022 15:11:56 +0530 Subject: [PATCH] fix: decimal price error --- package-lock.json | 4 ++-- package.json | 15 ++++++++------- server/services/stripeService.js | 15 ++------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae9ea48..86497f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "strapi-stripe", - "version": "2.0.0", + "version": "3.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "strapi-stripe", - "version": "2.0.0", + "version": "3.1.0", "license": "MIT", "dependencies": { "better-sqlite3": "^7.6.2", diff --git a/package.json b/package.json index 8c8dde3..57ec6d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "strapi-stripe", - "version": "3.1.0", + "version": "3.1.1", "description": "Online payments and subscriptions made simple, secure and fast. This free plugin enables you to accept online payments and create subscriptions using Credit Card, Apple pay, Google pay, SEPA Direct Debit, ACH Direct Debit on your Strapi app via Stripe.", "strapi": { "name": "strapi-stripe", @@ -85,12 +85,13 @@ "charge", "intent", "merchant", - "credit", - "debit", - "ACH", - "SEPA", - "sepa direct debit", - "ach direct debit", + "credit card", + "debit card", + "ACH Direct Debit", + "SEPA Direct Debit", + "AliPay", + "Klarna", + "iDEAL", "card pay", "google pay", "secure payment", diff --git a/server/services/stripeService.js b/server/services/stripeService.js index 6f596f3..71d4268 100644 --- a/server/services/stripeService.js +++ b/server/services/stripeService.js @@ -64,20 +64,9 @@ module.exports = ({ strapi }) => ({ return create; }; - // if currency is eur then format the price in euro - if (stripeSettings.currency === 'eur') { - // convert decimal to euro number - productPrice = productPrice.toLocaleString('de-DE', { - currency: 'EUR', - }); - - // format to euro number - productPrice = productPrice.replace(/,/g, '.'); - } - if (isSubscription) { const plan = await stripe.plans.create({ - amount: productPrice * 100, + amount: Math.round(productPrice * 100), currency: stripeSettings.currency, interval: paymentInterval, product: product.id, @@ -86,7 +75,7 @@ module.exports = ({ strapi }) => ({ createproduct(product.id, '', plan.id); } else { const price = await stripe.prices.create({ - unit_amount: productPrice * 100, + unit_amount: Math.round(productPrice * 100), currency: stripeSettings.currency, product: product.id, });