Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 📝 Fix batch get payment #5060

Merged
merged 8 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading