Skip to content
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
16 changes: 14 additions & 2 deletions fragment/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema,
CreateLedgerCreateLedgerInternalError,
)
from .create_payment import (
CreatePayment,
CreatePaymentCreatePaymentBadRequestError,
CreatePaymentCreatePaymentInternalError,
CreatePaymentCreatePaymentPayment,
)
from .delete_custom_txs import (
DeleteCustomTxs,
DeleteCustomTxsDeleteCustomTxsBadRequestError,
Expand Down Expand Up @@ -97,8 +103,8 @@
SchemaConsistencyMode,
SchemaLedgerAccountStatus,
SchemaLedgerEntryStatus,
SchemaPaymentEntryStatus,
SchemaPaymentTypeDirection,
SchemaPaymentTypeStatus,
SchemaSystemLineKind,
StripeEnv,
TxType,
Expand Down Expand Up @@ -184,6 +190,7 @@
CreateLedgerAccountInput,
CreateLedgerAccountsInput,
CreateLedgerInput,
CreatePaymentInput,
CurrencyFilter,
CurrencyMatchInput,
CustomAccountInput,
Expand Down Expand Up @@ -462,6 +469,11 @@
"CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema",
"CreateLedgerCreateLedgerInternalError",
"CreateLedgerInput",
"CreatePayment",
"CreatePaymentCreatePaymentBadRequestError",
"CreatePaymentCreatePaymentInternalError",
"CreatePaymentCreatePaymentPayment",
"CreatePaymentInput",
"CurrencyCode",
"CurrencyFilter",
"CurrencyMatchInput",
Expand Down Expand Up @@ -707,12 +719,12 @@
"SchemaMatchInput",
"SchemaPaymentAccountingInput",
"SchemaPaymentEntryInput",
"SchemaPaymentEntryStatus",
"SchemaPaymentInput",
"SchemaPaymentLineInput",
"SchemaPaymentTypeDetailsInput",
"SchemaPaymentTypeDirection",
"SchemaPaymentTypeInput",
"SchemaPaymentTypeStatus",
"SchemaPaymentsInput",
"SchemaRepeatedConfigInput",
"SchemaSystemLineKind",
Expand Down
48 changes: 48 additions & 0 deletions fragment/sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .create_custom_currency import CreateCustomCurrency
from .create_custom_link import CreateCustomLink
from .create_ledger import CreateLedger
from .create_payment import CreatePayment
from .delete_custom_txs import DeleteCustomTxs
from .delete_ledger import DeleteLedger
from .delete_schema import DeleteSchema
Expand Down Expand Up @@ -1786,3 +1787,50 @@ async def create_custom_currency(
)
data = self.get_data(response)
return CreateCustomCurrency.model_validate(data)

async def create_payment(
self,
ik: Any,
ledger_ik: Any,
type_: Any,
type_version: Optional[int] = None,
parameters: Optional[Any] = None,
**kwargs: Any
) -> CreatePayment:
query = gql("""
mutation createPayment($ik: SafeString!, $ledgerIk: SafeString!, $type: SafeString!, $typeVersion: Int, $parameters: JSON) {
createPayment(
ik: $ik
ledger: {ik: $ledgerIk}
payment: {type: $type, typeVersion: $typeVersion, parameters: $parameters}
) {
__typename
... on Payment {
clientSecret
status
}
... on BadRequestError {
code
message
retryable
}
... on InternalError {
code
message
retryable
}
}
}
""")
variables: dict[str, object] = {
"ik": ik,
"ledgerIk": ledger_ik,
"type": type_,
"typeVersion": type_version,
"parameters": parameters,
}
response = await self.execute(
query=query, operation_name="createPayment", variables=variables, **kwargs
)
data = self.get_data(response)
return CreatePayment.model_validate(data)
40 changes: 40 additions & 0 deletions fragment/sdk/create_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by fragment (with the help of ariadne-codegen)
# Source: queries/

from typing import Literal, Union

from pydantic import Field

from .base_model import BaseModel
from .enums import PaymentStatus


class CreatePayment(BaseModel):
create_payment: Union[
"CreatePaymentCreatePaymentBadRequestError",
"CreatePaymentCreatePaymentInternalError",
"CreatePaymentCreatePaymentPayment",
] = Field(alias="createPayment", discriminator="typename__")


class CreatePaymentCreatePaymentBadRequestError(BaseModel):
typename__: Literal["BadRequestError"] = Field(alias="__typename")
code: str
message: str
retryable: bool


class CreatePaymentCreatePaymentInternalError(BaseModel):
typename__: Literal["InternalError"] = Field(alias="__typename")
code: str
message: str
retryable: bool


class CreatePaymentCreatePaymentPayment(BaseModel):
typename__: Literal["Payment"] = Field(alias="__typename")
client_secret: str = Field(alias="clientSecret")
status: PaymentStatus


CreatePayment.model_rebuild()
10 changes: 5 additions & 5 deletions fragment/sdk/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ class LinkType(str, Enum):


class PaymentStatus(str, Enum):
needs_payment_method = "needs_payment_method"
processing = "processing"
requires_confirmation = "requires_confirmation"
settled = "settled"


Expand Down Expand Up @@ -299,15 +299,15 @@ class SchemaLedgerEntryStatus(str, Enum):
disabled = "disabled"


class SchemaPaymentEntryStatus(str, Enum):
active = "active"


class SchemaPaymentTypeDirection(str, Enum):
payin = "payin"
payout = "payout"


class SchemaPaymentTypeStatus(str, Enum):
active = "active"


class SchemaSystemLineKind(str, Enum):
payment_fee_line = "payment_fee_line"
payment_settlement_line = "payment_settlement_line"
Expand Down
17 changes: 14 additions & 3 deletions fragment/sdk/input_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
SchemaConsistencyMode,
SchemaLedgerAccountStatus,
SchemaLedgerEntryStatus,
SchemaPaymentEntryStatus,
SchemaPaymentTypeDirection,
SchemaPaymentTypeStatus,
SchemaSystemLineKind,
TxType,
)
Expand Down Expand Up @@ -120,6 +120,17 @@ class CreateLedgerInput(BaseModel):
type_: Optional[LedgerTypes] = Field(alias="type", default=None)


class CreatePaymentInput(BaseModel):
"""EXPERIMENTAL: The Payment to create."""

parameters: Optional[Any] = None
"Parameters for the specific Payment Type. Must be a key-value pair of strings. Must be a flat object: nested objects and arrays are rejected."
type_: Any = Field(alias="type")
"The type of the Payment. Must be defined in the Schema linked to the Ledger."
type_version: Optional[int] = Field(alias="typeVersion", default=None)
"The version of the Payment Type. Defaults to the latest active version."


class CurrencyFilter(BaseModel):
equal_to: Optional["CurrencyMatchInput"] = Field(alias="equalTo", default=None)
"Must match the value provided"
Expand Down Expand Up @@ -895,7 +906,7 @@ class SchemaPaymentAccountingInput(BaseModel):
"""EXPERIMENTAL: The Ledger Entries a Payment Type posts as a payment moves
through its lifecycle, keyed by lifecycle transition."""

needs_confirmation_to_processing: Optional["SchemaPaymentEntryInput"] = None
needs_payment_method_to_processing: Optional["SchemaPaymentEntryInput"] = None
"Posted when the payment enters processing. Optional."
processing_to_settled: "SchemaPaymentEntryInput"
"Posted when the payment settles. Every Payment Type must define it."
Expand Down Expand Up @@ -950,7 +961,7 @@ class SchemaPaymentTypeInput(BaseModel):
"The Ledger Entries posted as the payment moves through its lifecycle."
payment: "SchemaPaymentTypeDetailsInput"
"The payment this Payment Type creates."
status: SchemaPaymentEntryStatus
status: SchemaPaymentTypeStatus
"The status of this Payment Type."
type_: Any = Field(alias="type")
"The type of this Payment Type. This is a stable, unique identifier for it.\nUniqueness is enforced at the Schema level."
Expand Down
34 changes: 34 additions & 0 deletions fragment/std_queries/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1241,3 +1241,37 @@ mutation createCustomCurrency(
}
}
}

mutation createPayment(
$ik: SafeString!
$ledgerIk: SafeString!
$type: SafeString!
$typeVersion: Int
$parameters: JSON
) {
createPayment(
ik: $ik
ledger: { ik: $ledgerIk }
payment: {
type: $type
typeVersion: $typeVersion
parameters: $parameters
}
) {
__typename
... on Payment {
clientSecret
status
}
... on BadRequestError {
code
message
retryable
}
... on InternalError {
code
message
retryable
}
}
}
16 changes: 14 additions & 2 deletions fragment/sync_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema,
CreateLedgerCreateLedgerInternalError,
)
from .create_payment import (
CreatePayment,
CreatePaymentCreatePaymentBadRequestError,
CreatePaymentCreatePaymentInternalError,
CreatePaymentCreatePaymentPayment,
)
from .delete_custom_txs import (
DeleteCustomTxs,
DeleteCustomTxsDeleteCustomTxsBadRequestError,
Expand Down Expand Up @@ -96,8 +102,8 @@
SchemaConsistencyMode,
SchemaLedgerAccountStatus,
SchemaLedgerEntryStatus,
SchemaPaymentEntryStatus,
SchemaPaymentTypeDirection,
SchemaPaymentTypeStatus,
SchemaSystemLineKind,
StripeEnv,
TxType,
Expand Down Expand Up @@ -183,6 +189,7 @@
CreateLedgerAccountInput,
CreateLedgerAccountsInput,
CreateLedgerInput,
CreatePaymentInput,
CurrencyFilter,
CurrencyMatchInput,
CustomAccountInput,
Expand Down Expand Up @@ -461,6 +468,11 @@
"CreateLedgerCreateLedgerCreateLedgerResultLedgerSchema",
"CreateLedgerCreateLedgerInternalError",
"CreateLedgerInput",
"CreatePayment",
"CreatePaymentCreatePaymentBadRequestError",
"CreatePaymentCreatePaymentInternalError",
"CreatePaymentCreatePaymentPayment",
"CreatePaymentInput",
"CurrencyCode",
"CurrencyFilter",
"CurrencyMatchInput",
Expand Down Expand Up @@ -706,12 +718,12 @@
"SchemaMatchInput",
"SchemaPaymentAccountingInput",
"SchemaPaymentEntryInput",
"SchemaPaymentEntryStatus",
"SchemaPaymentInput",
"SchemaPaymentLineInput",
"SchemaPaymentTypeDetailsInput",
"SchemaPaymentTypeDirection",
"SchemaPaymentTypeInput",
"SchemaPaymentTypeStatus",
"SchemaPaymentsInput",
"SchemaRepeatedConfigInput",
"SchemaSystemLineKind",
Expand Down
48 changes: 48 additions & 0 deletions fragment/sync_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .create_custom_currency import CreateCustomCurrency
from .create_custom_link import CreateCustomLink
from .create_ledger import CreateLedger
from .create_payment import CreatePayment
from .delete_custom_txs import DeleteCustomTxs
from .delete_ledger import DeleteLedger
from .delete_schema import DeleteSchema
Expand Down Expand Up @@ -1780,3 +1781,50 @@ def create_custom_currency(
)
data = self.get_data(response)
return CreateCustomCurrency.model_validate(data)

def create_payment(
self,
ik: Any,
ledger_ik: Any,
type_: Any,
type_version: Optional[int] = None,
parameters: Optional[Any] = None,
**kwargs: Any
) -> CreatePayment:
query = gql("""
mutation createPayment($ik: SafeString!, $ledgerIk: SafeString!, $type: SafeString!, $typeVersion: Int, $parameters: JSON) {
createPayment(
ik: $ik
ledger: {ik: $ledgerIk}
payment: {type: $type, typeVersion: $typeVersion, parameters: $parameters}
) {
__typename
... on Payment {
clientSecret
status
}
... on BadRequestError {
code
message
retryable
}
... on InternalError {
code
message
retryable
}
}
}
""")
variables: dict[str, object] = {
"ik": ik,
"ledgerIk": ledger_ik,
"type": type_,
"typeVersion": type_version,
"parameters": parameters,
}
response = self.execute(
query=query, operation_name="createPayment", variables=variables, **kwargs
)
data = self.get_data(response)
return CreatePayment.model_validate(data)
Loading
Loading