fxa/packages/fxa-payments-server
Lisa Chan d3357de539
fix(payments): Adjust price and value for GA4 reports
2024-01-03 10:27:45 -05:00
..
.storybook feat(all): react 18 2023-07-18 22:26:06 -07:00
.vscode feat(payments): vscode Launch Config For Debugging Payments Server TestsE 2023-03-14 22:24:26 -07:00
public task(payments): Activate mozilla brand l10n strings 2023-10-17 18:27:36 -07:00
scripts task(CI): Improve nx caching for CI pipelines 2023-08-29 11:19:54 -07:00
server task(all): Add support for sentry performance monitoring 2023-12-19 16:05:05 -08:00
src fix(payments): Adjust price and value for GA4 reports 2024-01-03 10:27:45 -05:00
.eslintignore fix(payments): fix lint script and suggestions 2022-04-13 10:58:37 -04:00
.eslintrc.json fix(payments): Fix Typescript errors 2023-05-16 11:02:37 -04:00
.license.header chore(l10n): update fxa-payments to use fxa-shared branding 2023-11-16 12:03:25 -05:00
.nsprc fix(deps): Add exception for yargs-parser nsp advisory 1500 2020-05-11 11:40:27 -07:00
.prettierignore chore(payments): Add prettier config files to payments-server 2019-08-05 16:32:05 -07:00
.rescriptsrc.js feat(libs): move fxa-shared/l10n to libs/shared/l10n 2023-10-04 16:08:01 -04:00
Gruntfile.js chore(l10n): update fxa-payments to use fxa-shared branding 2023-11-16 12:03:25 -05:00
README.md feat(metrics): add Country_ISO field to Select Payments Events and Add Payments Location Override 2023-04-11 09:35:36 -07:00
jest.config.js task(CI): build, unit test, and integration test jobs 2023-01-10 12:52:01 -08:00
package.json Merge pull request #16152 from mozilla/FXA-8802 2023-12-18 16:48:21 -08:00
pm2.config.js task(CI): Improve nx caching for CI pipelines 2023-08-29 11:19:54 -07:00
postcss.config.js chore(deps): Upgrade tailwindcss (v1.9 to v3), autoprefixer, & all SB deps, replace postcss deps, remove other deps 2022-06-30 16:51:57 -05:00
tailwind.config.js chore(deps): Upgrade tailwindcss (v1.9 to v3), autoprefixer, & all SB deps, replace postcss deps, remove other deps 2022-06-30 16:51:57 -05:00
tsconfig.json feat: add foundational db classes 2023-07-24 14:44:12 -04:00

README.md

fxa-payments-server

This is the server that handles payments.

Storybook

This project uses Storybook to show each screen without requiring a full stack.

In local development, yarn storybook should start a Storybook server at http://localhost:6006 with hot module replacement to reflect live changes.

Latest builds

The latest builds of the various FXA Storybooks are published to Google Cloud Platform, using this GCP Storybook Publisher, and can be found in the following ways.

  • Via direct URL
    • Navigate to the Mozilla Storybooks FXA URL
    • Click the commit youd like to view. (This includes both main and PR commits)
    • Click fxa-payments-server
  • From the FXA Github repo
    • Click on the green check mark next to the latest commit off of main. (Near the top of the page)
    • Scroll down and click on “Details” for entry storybooks:pull request
    • Click fxa-payments-server

Installation notes

On Mac OS, yarn test may trigger an EMFILE error. In this case, to get tests running, you may need to brew install watchman. (If the watchman postinstall step fails, follow the instructions here to change /usr/local ownership from root to your user account.)

Secrets

Create the following file: server/config/secrets.json. It will not be tracked in Git.

Use the following as a template, and fill in your own values:

{
  "stripe": {
    "apiKey": "pk_test_123"
  },
  "paypal": {
    "clientId": "sb"
  }
}
  • apiKey should be a test Stripe Publishable Key
  • clientId should be a sandbox PayPal client ID. For local testing, the default value of "sb" should be sufficient.

Testing

This package uses Jest to test both the frontend and server. By default yarn test will run all yarn test scripts:

  • yarn test-frontend will test the React App frontend under src/
  • yarn test-server will test the Express server under server/

Test specific tests with the following commands:

# Test frontend tests for the component AlertBar
yarn test-frontend AlertBar

# Grep frontend tests for "renders as expected"
yarn test-frontend -t "renders as expected"

# Test server tests for the file server/lib/csp
yarn test-server server/lib/csp

# Grep server tests for "logs raw events"
yarn test-server -t "logs raw events"

Note that prior to testing you may need to create a build of the React App. You can do this by running yarn build.

Refer to Jest's CLI documentation for more advanced test configuration.

Location Override

When running the FxA stack locally, our geodb service needs an override to resolve a location. This override object takes the form of:

{
  "location": {
    "countryCode": <2 letter country code string>,
    "postalCode": <corresponding postal code string>
  }
}

and can be passed in either through your secrets.json or through your environment variables.

Example using secrets.json:

  "geodb": {
    "locationOverride": {
      "location": {
        "countryCode": "US",
        "postalCode": "98332"
      }
    }
  },

or with a .env file using dotenv

GEODB_LOCATION_OVERRIDE= { "location": { "countryCode": "US", "postalCode": "85001"} }

Debugging Tests

Launch configs for Visual Studio Code are provided to help debug tests. In order to use the launch config, open the fxa-payments-server folder in Visual Studio Code, then add a debugger statement in the body of the test you plan to debug. In the Visual Studio Code sidebar navigate to the Run and Debug tab, and select the "Debug FxA-Payments Frontend Tests" or "Debug FxA-Payments Server Tests." Click the run button and the tests will begin to run and a debugger will be attached to the process. You can now add further breakpoints to the test source code by clicking near the line number.

Current Debugging Limitations

As the launch config is currently offered, a debugger statement is needed to cause the debugger to properly attach; on initial run, simply selecting breakpoints on the side of the editor window will not work. Furthermore, the launch config currently runs all tests in a single process so it may take a moment before the test you are trying to debug is reached.

We use rescripts and yarn workspaces to manage our node packages. If you are encountering any error with packages not being found, please make sure to run yarn install from the FxA root directory.

L10N

Strings are automatically extracted to the fxa-content-server-l10n repo where they reach Pontoon for translations to occur by our l10n team and contributors. This is achieved by concatenating all of our .ftl (Fluent) files into a single payments.ftl file with the merge-ftl grunttask, and the script that runs in fxa-content-server-l10n on a weekly cadence. For more detailed information, check out the ecosystem platform l10n doc.

License

MPL-2.0