DEPRECATED - payment subscription REST api for customers
Перейти к файлу
Scott Idler 932e92b6b8 switched out npm for yarn to manage node deps 2019-06-04 08:37:55 -05:00
docs Document how to restore a DynamoDB backup 2019-05-31 06:33:25 -07:00
services/fxa added sls symlink for convenience 2019-06-03 11:19:39 -05:00
subhub Refactor subhub_api.yaml, payments.py: Update API response formatting 2019-06-03 12:56:29 -07:00
.gitignore add task to run locally 2019-05-17 15:53:20 -05:00
.travis.yml add task to run locally 2019-05-17 15:53:20 -05:00
CODE_OF_CONDUCT.md added the required coc 2019-05-07 12:23:37 -05:00
LICENSE Initial commit 2019-03-21 12:27:53 -07:00
README.md switched out npm for yarn to manage node deps 2019-06-04 08:37:55 -05:00
dodo.py switched out npm for yarn to manage node deps 2019-06-04 08:37:55 -05:00
package.json added the dynamodb-local pkg back as it seems to be required for deploys 2019-05-21 18:31:17 -05:00
requirements.txt add more checks and deps to dodo.py 2019-05-20 10:35:56 -05:00
setup.cfg feat: refactor helper functions, add more thorough error handling 2019-05-08 14:21:51 -05:00
setup.py SS-167 Build Webhook proccess for Stripe events 2019-05-23 14:47:36 -07:00
tox.ini SS-167 Build Webhook proccess for Stripe events 2019-05-23 14:47:36 -07:00
yarn.lock switched out npm for yarn to manage node deps 2019-06-04 08:37:55 -05:00

README.md

SubHub

payment subscription REST api for customers:

  • FxA (Firefox Accounts)

Required Software

  • python3.7: requires python3.7 interpreter for creating virtual envionments for testing and running subhub
  • yarn (https://yarnpkg.com): package manager for node modules for setting up serverless for running and deploying subhub

Important Environment Variables

The CFG object is for accessing values either from the subhub/.env file and|or superceeded by env vars. A value that is known to be set or have a default can be accessed:

CFG.SOME_VALUE

Otherwise the value can be accessed and given a default if it doesn't exist:

CFG("OTHER_VALUE", "SOME_DEFAULT")

These values can be enabled as an env var or listed in a .env in the subhub/ directory.

STRIPE_API_KEY

This value is used for producion deployments as well as testing (testing key).

USER_TABLE

This is the name of the table to be created in dynamodb. Defaults to testing if not specified.

LOCAL_FLASK_PORT

This value is used only when running the subhub flask app locally. Defaults to 5000.

DYNALITE_PORT

This value is used only when running dynalite locally. Defaults to 8000.

DYNALITE_FILE

This is the value of the file that will be written to by the dynalite process. Defaults to dynalite.out.

PAYMENT_API_KEY

This is the payment api key. Defaults to fake_payment_api_key

SUPPORT_API_KEY

This is the support api key. Defaults to fake_support_api_key

Other Important CFG Properties

These values are calculated and not to be set by a user. They are mentioned here for clarity.

APP_DEPENV

The deployment environment is determined by the branch name:

  • master: prod
  • stage/*: stage
  • qa/*: qa
  • *: dev

APP_REPOROOT

This is the path to the root of the checked out mozilla/subhub git repo. This value only makes sense in the git repo, not in the AWS Lambda environment.

APP_PROJNAME

This is the project's name, subhub, as determined by the second part of the reposlug mozilla/subhub.

APP_PROJPATH

This is the path to the project code in the git repo. It is APP_REPOPATH + APP_PROJNAME. It is only valid in the git repo, not in the AWS Lambda environment.

APP_BRANCH

This is the branch name of the deployed code. Should be available locally as well as when deployed to AWS Lambda.

APP_REVISION

This is the 40 digit sha1 commit hash for the code. This is available in the git repo as well as when deployed to AWS Lambda.

APP_VERSION

This is the git describe --abbrev=7 value, useful for describing the code version. This is available in the git repo as well as when deployed to AWS Lambda.

doit

http://pydoit.org/

doit comes from the idea of bringing the power of build-tools to execute any kind of task The doit program is used to solve a dependency of tasks just like make does but written in python for easier writing and maintaining. It also has some capabilities that make does not. Visit the website above for more details.

install requirements to run doit

Either of the following commands should install the minimum requirements to run doit and load the CFG

python3 ./dodo.py
pip3 install -r requirements.txt

list tasks available to run

The list task is a built-in doit task that lists any functions in dodo.py that start with task_ (similar to pytest, test_). If this runs, doit is installed and working.

doit list

run black formatter on subhub code

This task will run the black code formatter on the subhub/ directory.

doit black

install npm packages

The npm task installs packages defined in the package.json file. These are for use with serverless and dyanlite.

doit npm

run checks

These are a series of checks which help ensure that the system is in good order to run other doit tasks.

doit check

Running doit check will run all of the subtasks listed below.

The check task have several subtasks:

  • doit check:noroot This makes sure the doit command is not run as a root user.
  • doit check:python3.7 This makes sure the python3.7 interpreter is installed.
  • doit check:awscli This makes sure the awscli is installed (unless running in travis-ci)
  • doit check:json This makes sure all of the json files in the git repo can be loaded.
  • doit check:yaml This makes sure all of the yaml files in the git repo can be loaded.
  • doit check:black This runs black --check to ensure formatting.
  • doit check:reqs This compares subhub/requirements.txt vs what is installed via pip freeze.

setup the virtualenv (venv)

This task will create the virtual env and install all of the requirements for use in running code locally.

doit venv

dynalite

The dynalite npm package is a database webserver.

start dynalite

This starts, if not already running, the dynalite process on the DYNALITE_PORT (default: 8000)

doit dynalite:start

stop dynalite

This stops, if already running, the dynalite process on the DYNALITE_PORT (default: 8000)

doit dynalite:stop

run locally

This task does all the steps required to get the subhub flask server running in a venv.

doit local

run tests and coverage

This runs the pytests via tox and setup.py specifications. Currently, STRIPE_API_KEY must be set for tests to run successfully.

doit test

Note: The test task is a dependency of package, local and deploy tasks, however you can skip them by setting SKIP_TESTS=<something>.

run package

This runs the serverless package command to zip up the subhub code and its dependencies.

doit package

ensure creds

This checks to see if aws sts get-caller-identity can successfully run, verifying that valid AWS credentials are present. This is a dependency for deploy, the next task, to run.

doit creds

deploy

This run the serverless deploy command and requires the user to be logged into the AWS Account for subhub.

doit deploy