Skip to content

Commit

Permalink
Merge branch 'master' into enh/enable-2fa-to-all
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov authored Nov 21, 2023
2 parents 4cbfb59 + d459139 commit 49206df
Show file tree
Hide file tree
Showing 7 changed files with 811 additions and 12 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,5 @@ Untitled*

# service settings.schemas.json
services/**/settings-schema.json
services/payments/scripts/openapi.json

tests/public-api/osparc_python_wheels/*
12 changes: 9 additions & 3 deletions services/payments/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# payments
# payments service

![[doc/payments.drawio.svg]]
Payment service acts as intermediary between osparc and a `payments-gateway` connected to an external payment system (e.g. stripe, ...). Therefore the
`payments-gateway` acts as a common interface with the finaly payment system to make osparc independent of that decision. The communication
is implemented using http in two directions. This service communicates with a `payments-gateway` service using an API with this specifications [gateway/openapi.json](gateway/openapi.json)
and the latter is configured to acknoledge back to this service (i.e. web-hook) onto this API with the following specs [openapi.json](openapi.json).

- SEE https://github.com/ITISFoundation/osparc-simcore/issues/4657
Here is a diagram of how this service interacts with the rest of internal and external services
![[doc/payments.drawio.svg]]

- Further details on the use case and requirements in https://github.com/ITISFoundation/osparc-simcore/issues/4657
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ include ../../../scripts/common.Makefile


.PHONY: run-devel
run-devel: ## runs fake_payment_gateway server
run-devel: ## runs example_payment_gateway server
# SEE http://127.0.0.1:8000/docs
set -o allexport; source .env-secret; set +o allexport; \
uvicorn fake_payment_gateway:the_app --reload

uvicorn example_payment_gateway:the_app --reload

.PHONY: openapi.json
openapi.json: ## creates OAS
@set -o allexport; source .env-secret; set +o allexport; \
python fake_payment_gateway.py openapi > $@
python example_payment_gateway.py openapi > $@
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
""" This is a simple example of a payments-gateway service
- Mainly used to create the openapi specs (SEE `openapi.json`) that the payments service expects
- Also used as a fake payment-gateway for manual exploratory testing
"""

import argparse
import json
import logging
Expand Down Expand Up @@ -48,6 +54,10 @@
logging.basicConfig(level=logging.INFO)


# NOTE: please change every time there is a change in the specs
PAYMENTS_GATEWAY_SPECS_VERSION = "0.3.0"


class Settings(BaseCustomSettings):
PAYMENTS_SERVICE_API_BASE_URL: HttpUrl = "http://replace-with-ack-service.io"
PAYMENTS_USERNAME: str = "replace-with_username"
Expand Down Expand Up @@ -295,7 +305,13 @@ def batch_get_payment_methods(
@router.get(
"/{id}",
response_model=GetPaymentMethod,
responses=ERROR_RESPONSES,
responses={
"404": {
"model": ErrorModel,
"description": "Payment method not found: It was not added or incomplete (i.e. create flow failed or canceled)",
},
**ERROR_RESPONSES,
},
)
def get_payment_method(
id: PaymentMethodID,
Expand Down Expand Up @@ -346,11 +362,12 @@ async def _app_lifespan(app: FastAPI):

def create_app():
app = FastAPI(
title="fake-payment-gateway",
version="0.3.0",
title="osparc-compliant payment-gateway",
version=PAYMENTS_GATEWAY_SPECS_VERSION,
lifespan=_app_lifespan,
debug=True,
)
app.openapi_version = "3.0.0" # NOTE: small hack to allow current version of `42Crunch.vscode-openapi` to work with openapi
override_fastapi_openapi_method(app)

app.state.payments = {}
Expand Down
Loading

0 comments on commit 49206df

Please sign in to comment.