Skip to content

Commit

Permalink
Merge pull request #68 from manishkatyan/AS-63-strapi-stripe-paramete…
Browse files Browse the repository at this point in the history
…r_invalid_integer---unit_amount,when-rounding-decimal-prices

fix: decimal price error
  • Loading branch information
arun-hel authored Dec 22, 2022
2 parents 1ba7d6b + 3bbd21d commit 1aacb7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 2 additions & 13 deletions server/services/stripeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
});
Expand Down

0 comments on commit 1aacb7b

Please sign in to comment.