Skip to content
hbcondo edited this page Aug 15, 2023 · 10 revisions

Installation

This app is currently being developed as a Progressive Web App (PWA) built on Expo. You can run it by performing these steps:

  1. Install Expo CLI and Serve CLI

  2. Clone this repo locally

  3. Generate the PWA code by running this Expo command:

    npx expo export:web
    
  4. 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 the web-build folder created in the previous step

  5. Publish the website locally with Serve (use webpack since it exports the service workers correctly):

    npx serve web-build --single
    

Stripe Integration

Establish a Stripe Connect account to allow the mobile app to display the Stripe login web page. Use the API key of the Stripe Connect account to make calls to the Stripe API.

Storage

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.

Metrics

Revenut calculates an end-of-month (EOM) forecast with these steps executed via multiprocess-based parallelism using a pool of workers:

  1. 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
  2. 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 their current_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 their current_period_end is also less than or equal to the current end of month date

Testing

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.
Clone this wiki locally