Skip to content

Send zero-decimal currency amounts to Stripe Lite in whole units - #580

Merged
sorinmarta merged 2 commits into
masterfrom
fix-391
Nov 9, 2026
Merged

sorinmarta merged 2 commits into
masterfrom
fix-391

Conversation

@sorinmarta

Copy link
Copy Markdown
Contributor

Fixes Strategy11/business-directory-premium#391
Stripe Lite now sends JPY, KRW and other zero-decimal amounts (checkout, plans, coupons) in whole units and records their renewals at the full amount; ISK/UGX are sent without fractions. Mirrors Strategy11/business-directory-stripe#70.

Fixes Strategy11/business-directory-premium#391
JPY, KRW and other zero-decimal currencies are no longer charged 100x, and their renewals are recorded at the full amount.
@sorinmarta sorinmarta added run analysis Runs phpcs and phpunit franky-review labels Nov 9, 2026
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7813e088-3f08-40e4-95a4-ae9a20619f3c
Commits

Reviewing files that changed from the base of the PR and between dac5326 and a973534.

Files selected for processing: 3

  • includes/gateways/class-stripe-gateway.php
  • includes/gateways/stripe/controllers/classStrpEventsController.php
  • includes/gateways/stripe/helpers/classStrpAppHelper.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 9, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approve — the zero-decimal fix is correct and complete for this gateway; one non-blocking note.

Verified

  • Harness that loads the real WPBDPStripeGateway::formated_amount() (via reflection) and WPBDPStrpAppHelper from base dac5326 and head a973534: JPY 1000 → 100000 on base, 1000 at head; KRW, VND and BIF likewise; USD 10.5 → 1050, EUR 19.99 → 1999 unchanged; ISK 1234.5 → 123500 and UGX 5000.4 → 500000 (whole units sent as two-decimal, as Stripe expects).
  • Webhook side: amount_from_stripe( $invoice->total, ... ) returns 1000.0 for jpy, 19.99 for eur, 1234.0 for isk (Stripe sends a lowercase currency code, strtoupper handles it), and falls back to / 100 for a null currency.
  • All four formated_amount call sites (checkout line item, coupon amount_off, plan fingerprint, create_stripe_plan) now pass $payment->currency_code, and $payment is in scope at each. The only other / 100 on a Stripe amount in the gateway code is the one in the events controller. The zero-decimal list covers every zero-decimal currency in supports_currency(); the three-decimal currencies (BHD, KWD, …) are not in that supported list.
  • The plan fingerprint now differs for zero-decimal currencies, so a merchant who previously got a 100x JPY plan gets a new correctly-priced plan rather than reusing the old one.
  • php -l clean on all three files. CI at a973534: PHPCS, PHPStan and PHP 7.4 tests (WP 5.8 and master) all pass. The new code uses ?? (the plugin requires PHP 7.4).

Non-blocking: no test covers the new currency branching, and tests/unit is empty in this repo so there is nowhere obvious to add one. A small parameterized test on formated_amount / amount_from_stripe (JPY, USD, ISK) would pin it.

Not exercised: a live Stripe Checkout or renewal in JPY (no Stripe keys here). I read the code directly and did not run the code-review/security-review/simplify skills on this PR.

Tests run: PHP harness above (base vs a9735346) → base 100x, head correct.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 9, 2026
@sorinmarta
sorinmarta merged commit 20e8846 into master Nov 9, 2026
9 checks passed
@sorinmarta
sorinmarta deleted the fix-391 branch November 9, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run analysis Runs phpcs and phpunit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant