Skip to content

♻️ Feedback on payments plugin and service #4763

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

Merged
merged 13 commits into from
Sep 18, 2023
5 changes: 5 additions & 0 deletions api/specs/web-server/_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ async def update_wallet(wallet_id: WalletID, body: PutWalletBodyParams):
@router.post(
"/wallets/{wallet_id}/payments",
response_model=Envelope[WalletPaymentCreated],
response_description="Successfully initialized",
status_code=status.HTTP_202_ACCEPTED,
)
async def create_payment(wallet_id: WalletID, body: CreateWalletPayment):
"""Creates payment to wallet `wallet_id`"""
Expand All @@ -87,6 +89,7 @@ async def list_all_payments(params: Annotated[PageQueryParameters, Depends()]):

@router.post(
"/wallets/{wallet_id}/payments/{payment_id}:cancel",
response_description="Successfully cancelled",
status_code=status.HTTP_204_NO_CONTENT,
)
async def cancel_payment(wallet_id: WalletID, payment_id: PaymentID):
Expand All @@ -99,6 +102,8 @@ async def cancel_payment(wallet_id: WalletID, payment_id: PaymentID):
@router.post(
"/wallets/{wallet_id}/payments-methods:init",
response_model=Envelope[PaymentMethodInit],
response_description="Successfully initialized",
status_code=status.HTTP_202_ACCEPTED,
)
async def init_creation_of_payment_method(wallet_id: WalletID):
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ class Config(OutputSchema.Config):
}


class PaymentMethodTransaction(OutputSchema):
# Used ONLY in socketio interface
wallet_id: WalletID
payment_method_id: PaymentMethodID
state: Literal["PENDING", "SUCCESS", "FAILED", "CANCELED"]

class Config(OutputSchema.Config):
schema_extra: ClassVar[dict[str, Any]] = {
"examples": [
{
"walletId": 1,
"paymentMethodId": "pm_0987654321",
"state": "SUCCESS",
}
]
}


class PaymentMethodGet(OutputSchema):
idr: PaymentMethodID
wallet_id: WalletID
Expand Down
2 changes: 1 addition & 1 deletion services/payments/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
48 changes: 46 additions & 2 deletions services/payments/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "simcore-service-payments web API",
"description": " Service that manages creation and validation of registration payments",
"version": "1.0.0"
"version": "1.1.0"
},
"paths": {
"/": {
Expand Down Expand Up @@ -217,6 +217,15 @@
"message": {
"type": "string",
"title": "Message"
},
"saved": {
"allOf": [
{
"$ref": "#/components/schemas/SavedPaymentMethod"
}
],
"title": "Saved",
"description": "If the user decided to save the payment methodafter payment it returns the payment-method acknoledgement response.Otherwise it defaults to None."
}
},
"type": "object",
Expand All @@ -226,8 +235,20 @@
"title": "AckPayment"
},
"AckPaymentMethod": {
"properties": {},
"properties": {
"success": {
"type": "boolean",
"title": "Success"
},
"message": {
"type": "string",
"title": "Message"
}
},
"type": "object",
"required": [
"success"
],
"title": "AckPaymentMethod"
},
"Body_login_to_create_access_token": {
Expand Down Expand Up @@ -311,6 +332,29 @@
"docs_url": "https://foo.io/doc"
}
},
"SavedPaymentMethod": {
"properties": {
"success": {
"type": "boolean",
"title": "Success"
},
"message": {
"type": "string",
"title": "Message"
},
"payment_method_id": {
"type": "string",
"format": "uuid",
"title": "Payment Method Id"
}
},
"type": "object",
"required": [
"success",
"payment_method_id"
],
"title": "SavedPaymentMethod"
},
"Token": {
"properties": {
"access_token": {
Expand Down
4 changes: 2 additions & 2 deletions services/payments/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.0
current_version = 1.1.0
commit = True
message = services/payments version: {current_version} → {new_version}
tag = False
Expand All @@ -9,5 +9,5 @@ commit_args = --no-verify

[tool:pytest]
asyncio_mode = auto
markers =
markers =
testit: "marks test to run during development"
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ class _BaseAck(BaseModel):
message: str = Field(default=None)


class AckPayment(_BaseAck):
class AckPaymentMethod(_BaseAck):
...


class AckPaymentMethod(BaseModel):
...
class SavedPaymentMethod(AckPaymentMethod):
payment_method_id: PaymentMethodID


class AckPayment(_BaseAck):
saved: SavedPaymentMethod | None = Field(
default=None,
description="If the user decided to save the payment method"
"after payment it returns the payment-method acknoledgement response."
"Otherwise it defaults to None.",
)


assert PaymentID # nosec
Expand Down
1 change: 1 addition & 0 deletions services/web/server/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ aiosmtplib # email
asyncpg # db
cryptography # security
expiringdict
faker # Only used in dev-mode for proof-of-concepts
gunicorn[setproctitle]
jinja_app_loader # email
json2html
Expand Down
6 changes: 5 additions & 1 deletion services/web/server/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ et-xmlfile==1.1.0
# via openpyxl
expiringdict==1.2.1
# via -r requirements/_base.in
faker==19.6.1
# via -r requirements/_base.in
frozenlist==1.3.0
# via
# aiohttp
Expand Down Expand Up @@ -338,7 +340,9 @@ pyjwt==2.4.0
pyrsistent==0.18.1
# via jsonschema
python-dateutil==2.8.2
# via arrow
# via
# arrow
# faker
python-engineio==4.3.4
# via python-socketio
python-magic==0.4.25
Expand Down
4 changes: 3 additions & 1 deletion services/web/server/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ exceptiongroup==1.1.3
execnet==2.0.2
# via pytest-xdist
faker==19.6.1
# via -r requirements/_test.in
# via
# -c requirements/_base.txt
# -r requirements/_test.in
flaky==3.7.0
# via -r requirements/_test.in
frozenlist==1.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3806,8 +3806,8 @@ paths:
$ref: '#/components/schemas/CreateWalletPayment'
required: true
responses:
'200':
description: Successful Response
'202':
description: Successfully initialized
content:
application/json:
schema:
Expand Down Expand Up @@ -3870,7 +3870,7 @@ paths:
in: path
responses:
'204':
description: Successful Response
description: Successfully cancelled
/v0/wallets/{wallet_id}/payments-methods:init:
post:
tags:
Expand All @@ -3887,12 +3887,12 @@ paths:
name: wallet_id
in: path
responses:
'200':
description: Successful Response
'202':
description: Successfully initialized
content:
application/json:
schema:
$ref: '#/components/schemas/Envelope_CreatePaymentMethodInitiated_'
$ref: '#/components/schemas/Envelope_PaymentMethodInit_'
/v0/wallets/{wallet_id}/payments-methods/{payment_method_id}:cancel:
post:
tags:
Expand Down Expand Up @@ -4777,6 +4777,7 @@ components:
enum:
- AWS
- ON_PREMISE
- ON_DEMAND
type: string
description: An enumeration.
CodePageParams:
Expand Down Expand Up @@ -4804,30 +4805,6 @@ components:
title: Cluster Id
minimum: 0
type: integer
CreatePaymentMethodInitiated:
title: CreatePaymentMethodInitiated
required:
- walletId
- paymentMethodId
- paymentMethodFormUrl
type: object
properties:
walletId:
title: Walletid
exclusiveMinimum: true
type: integer
minimum: 0
paymentMethodId:
title: Paymentmethodid
minLength: 1
type: string
paymentMethodFormUrl:
title: Paymentmethodformurl
maxLength: 2083
minLength: 1
type: string
description: Link to external site that holds the payment submission form
format: uri
CreateWalletBodyParams:
title: CreateWalletBodyParams
required:
Expand Down Expand Up @@ -4997,14 +4974,6 @@ components:
$ref: '#/components/schemas/ComputationTaskGet'
error:
title: Error
Envelope_CreatePaymentMethodInitiated_:
title: Envelope[CreatePaymentMethodInitiated]
type: object
properties:
data:
$ref: '#/components/schemas/CreatePaymentMethodInitiated'
error:
title: Error
Envelope_Error_:
title: Envelope[Error]
type: object
Expand Down Expand Up @@ -5117,6 +5086,14 @@ components:
$ref: '#/components/schemas/PaymentMethodGet'
error:
title: Error
Envelope_PaymentMethodInit_:
title: Envelope[PaymentMethodInit]
type: object
properties:
data:
$ref: '#/components/schemas/PaymentMethodInit'
error:
title: Error
Envelope_PresignedLink_:
title: Envelope[PresignedLink]
type: object
Expand Down Expand Up @@ -6906,6 +6883,30 @@ components:
title: Created
type: string
format: date-time
PaymentMethodInit:
title: PaymentMethodInit
required:
- walletId
- paymentMethodId
- paymentMethodFormUrl
type: object
properties:
walletId:
title: Walletid
exclusiveMinimum: true
type: integer
minimum: 0
paymentMethodId:
title: Paymentmethodid
minLength: 1
type: string
paymentMethodFormUrl:
title: Paymentmethodformurl
maxLength: 2083
minLength: 1
type: string
description: Link to external site that holds the payment submission form
format: uri
PaymentTransaction:
title: PaymentTransaction
required:
Expand Down
Loading