-
-
Notifications
You must be signed in to change notification settings - Fork 4
Home
This app is currently being developed as a Progressive Web App (PWA) built on Expo. You can run it by performing these steps:
-
Clone this repo locally
-
Generate the PWA code by running this Expo command:
npx expo export:web
-
Expo's export process currently doesn't generate a valid manifest.json file but there is a valid one along with some assets in the
public
folder. Just copy the contents of that folder to theweb-build
folder created in the previous step -
Publish the website locally with Serve (use webpack since it exports the service workers correctly):
npx serve web-build --single
Establish a Stripe Connect account to display Stripe's login web page embedded in your app. Populate the app's .env
file with your client ID and Stripe's authorization URL.
When performing an authentication request, a read_write
scope is used to generate a file link for rendering the account's logo. Otherwise, a read-only
scope can be used but requires Stripe support to enable it on your Stripe account:
If Authentication is successful, Revenut will save the stripe_user_id
to the device's local storage via an asynchronous, unencrypted, persistent, key-value storage API compatible with Android, iOS and Web platforms. When Revenut is accessed again, the app will retrieve this value from storage and not require logging into Stripe again.
To remove
stripe_user_id
from the device, you can clear the app's data through your device's settings or click the Logout button within the app. This will call Stripe's revoke endpoint so the Stripe account is no longer accessible by Revenut.
Revenut calculates an end-of-month (EOM) forecast with these steps executed via multiprocess-based parallelism using a pool of workers:
- Retrieve a list of charges for the requested account and sum the amounts for all records that have not been disputed or refunded as both of these result in withdrawals
- Retrieve a list of subscriptions for the requested account and:
- Attempt to get new subscriptions that are still in the trial phase for the current month by adding the amounts for all subscriptions that have a status of
trialing
and theircurrent_period_end
is less than or equal to the current end of month date - Attempt to get active subscriptions that haven't been invoiced yet by current month end by adding the amounts for all subscriptions that have a status of
active
(payment should have been successful before) and theircurrent_period_end
is also less than or equal to the current end of month date
- Attempt to get new subscriptions that are still in the trial phase for the current month by adding the amounts for all subscriptions that have a status of
Jest is a JavaScript unit testing framework that has been integrated into the Revenut app via Expo so you can write and run unit tests using the following CLI command npm run test
:
revenut-app % npm run test
> [email protected] test
> jest --setupFiles dotenv/config
PASS utils/api.test.ts
✓ api accessible and running (3727 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 4.225 s
Ran all test suites.
The metrics Revenut displays requires retrieving two months of charges (for month-to-date and month-over-month comparisons) using Stripe's API, which can result in long loading times because:
...listing charges (or most resources) can be quite slow as you need to render many objects. The Charge API especially is quite a large object to render and paginate through.
Source: https://github.com/stripe/stripe-dotnet/issues/2284#issuecomment-777192698