dex-connector-paypal 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. dex_connector_paypal-0.1.0/.gitignore +6 -0
  2. dex_connector_paypal-0.1.0/PKG-INFO +55 -0
  3. dex_connector_paypal-0.1.0/README.md +44 -0
  4. dex_connector_paypal-0.1.0/examples/resource_read/__init__.py +3 -0
  5. dex_connector_paypal-0.1.0/examples/resource_read/flow.py +95 -0
  6. dex_connector_paypal-0.1.0/examples/resource_read/worker.py +51 -0
  7. dex_connector_paypal-0.1.0/pyproject.toml +37 -0
  8. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/__init__.py +61 -0
  9. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/__init__.py +2 -0
  10. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/config.py +26 -0
  11. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/connection.py +142 -0
  12. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/definitions.py +58 -0
  13. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/mock.py +119 -0
  14. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/models.py +104 -0
  15. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/_generated/steps.py +134 -0
  16. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/client.py +534 -0
  17. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/connection.py +50 -0
  18. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/dex-connector.json +87 -0
  19. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/models.py +43 -0
  20. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/paypalmock/__init__.py +50 -0
  21. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/py.typed +0 -0
  22. dex_connector_paypal-0.1.0/src/dex_connectors/paypal/steps.py +35 -0
  23. dex_connector_paypal-0.1.0/tests/test_conformance.py +33 -0
  24. dex_connector_paypal-0.1.0/tests/test_manifest_contract.py +15 -0
  25. dex_connector_paypal-0.1.0/tests/test_operations.py +253 -0
  26. dex_connector_paypal-0.1.0/uv.lock +932 -0
@@ -0,0 +1,6 @@
1
+ /.dex-local/dexcli
2
+ /.dex-local/dex-server-zd
3
+ /.dex-local/data/
4
+ /.dex-local/cli.log
5
+ /.dex-local/visualize.json
6
+ /.dex-local/visualize.err
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-paypal
3
+ Version: 0.1.0
4
+ Summary: PayPal connector for Dex Flows
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: dex-connectors-sdk==0.1.0
8
+ Requires-Dist: dex-python-sdk>=1.28.0
9
+ Requires-Dist: httpx>=0.27
10
+ Description-Content-Type: text/markdown
11
+
12
+ # PayPal connector for Python
13
+
14
+ Install with `pip install dex-connector-paypal==0.1.0`. The package requires
15
+ `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
16
+ manifest Queries `getOrder` and `listTransactions` with the same branches,
17
+ defaults, and failure classification as the Go module.
18
+
19
+ ## Operations
20
+
21
+ | Operation | Factory | Happy branch | Optional branches |
22
+ | --- | --- | --- | --- |
23
+ | `getOrder` | `new_get_order_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
24
+ | `listTransactions` | `new_list_transactions_step` | `listed` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
25
+
26
+ `getOrder` reads `/v2/checkout/orders/<orderId>` and returns the order ID and
27
+ status. `listTransactions` reads one page of `/v1/reporting/transactions` for
28
+ an RFC 3339 window of at most 31 days and returns each transaction's ID,
29
+ status, and amount.
30
+
31
+ Each client exchanges the REST app's client ID and secret at
32
+ `/v1/oauth2/token` and caches the bearer token, per credential pair, until 30
33
+ seconds before it expires (at most 24 hours). A 401 from a read clears the
34
+ cache. Reads retry on 408, 429, 5xx, and transport failures; 404 selects
35
+ `notFound`; other statuses select `providerRejected`. A rejected token
36
+ exchange selects `providerRejected`, and a malformed token response selects
37
+ `invalidResponse`.
38
+
39
+ ## Authorization
40
+
41
+ Create a Dex Web connection named `paypal` as described in the
42
+ [connector README](../README.md#authentication-and-configuration). The client
43
+ secret travels only in the token exchange's Basic `Authorization` header and
44
+ is resolved for every attempt.
45
+
46
+ ## Example
47
+
48
+ [`examples/resource_read`](examples/resource_read/flow.py) reads one checkout
49
+ order. Run the Worker with `uv run python -m examples.resource_read.worker`
50
+ after `dexcli dev` has loaded a project containing the `paypal` connection.
51
+
52
+ ## Tests
53
+
54
+ `paypalmock.Mock` scripts both operations and defaults to the manifest answers.
55
+ Run `uv run pytest tests` for provider parity and manifest contract checks.
@@ -0,0 +1,44 @@
1
+ # PayPal connector for Python
2
+
3
+ Install with `pip install dex-connector-paypal==0.1.0`. The package requires
4
+ `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
5
+ manifest Queries `getOrder` and `listTransactions` with the same branches,
6
+ defaults, and failure classification as the Go module.
7
+
8
+ ## Operations
9
+
10
+ | Operation | Factory | Happy branch | Optional branches |
11
+ | --- | --- | --- | --- |
12
+ | `getOrder` | `new_get_order_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
13
+ | `listTransactions` | `new_list_transactions_step` | `listed` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
14
+
15
+ `getOrder` reads `/v2/checkout/orders/<orderId>` and returns the order ID and
16
+ status. `listTransactions` reads one page of `/v1/reporting/transactions` for
17
+ an RFC 3339 window of at most 31 days and returns each transaction's ID,
18
+ status, and amount.
19
+
20
+ Each client exchanges the REST app's client ID and secret at
21
+ `/v1/oauth2/token` and caches the bearer token, per credential pair, until 30
22
+ seconds before it expires (at most 24 hours). A 401 from a read clears the
23
+ cache. Reads retry on 408, 429, 5xx, and transport failures; 404 selects
24
+ `notFound`; other statuses select `providerRejected`. A rejected token
25
+ exchange selects `providerRejected`, and a malformed token response selects
26
+ `invalidResponse`.
27
+
28
+ ## Authorization
29
+
30
+ Create a Dex Web connection named `paypal` as described in the
31
+ [connector README](../README.md#authentication-and-configuration). The client
32
+ secret travels only in the token exchange's Basic `Authorization` header and
33
+ is resolved for every attempt.
34
+
35
+ ## Example
36
+
37
+ [`examples/resource_read`](examples/resource_read/flow.py) reads one checkout
38
+ order. Run the Worker with `uv run python -m examples.resource_read.worker`
39
+ after `dexcli dev` has loaded a project containing the `paypal` connection.
40
+
41
+ ## Tests
42
+
43
+ `paypalmock.Mock` scripts both operations and defaults to the manifest answers.
44
+ Run `uv run pytest tests` for provider parity and manifest contract checks.
@@ -0,0 +1,3 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """PayPal resource read example Flow."""
@@ -0,0 +1,95 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Runnable PayPal resource read Flow using the getOrder Query."""
4
+
5
+ from dataclasses import dataclass, field
6
+
7
+ import dex
8
+ from dex_connectors.sdk import QueryResult
9
+
10
+ from dex_connectors.paypal import Connection, GetOrderInput, Order, new_get_order_step
11
+
12
+ FLOW_TYPE = "PayPalResourceRead"
13
+ CONNECTION_NAME = "paypal"
14
+ _READ_STEP_TYPE = "ReadPayPalResource"
15
+
16
+
17
+ @dataclass(frozen=True, slots=True)
18
+ class ResourceReadRequest:
19
+ """The checkout order ID to read."""
20
+
21
+ order_id: str = field(default="", metadata={"dex_json_name": "orderID"})
22
+
23
+
24
+ @dataclass(frozen=True, slots=True)
25
+ class ResourceReadOutcome:
26
+ """The order PayPal returned."""
27
+
28
+ value: Order = field(default_factory=Order)
29
+
30
+
31
+ _OUTCOME = dex.Attribute("paypal-resource-read-outcome", ResourceReadOutcome)
32
+
33
+
34
+ def map_to_operation_input(request: ResourceReadRequest) -> GetOrderInput:
35
+ """Read the requested checkout order."""
36
+ return GetOrderInput(request.order_id)
37
+
38
+
39
+ # dex:group group-id:resource-read group-label:"Resource read"
40
+ # dex:explanation text:"Validate the request before reading the provider."
41
+ class _PrepareRequest(dex.Step[ResourceReadRequest]):
42
+ def get_step_type(self) -> str:
43
+ return "PrepareResourceRead"
44
+
45
+ def execute(self, context: dex.Context, input: ResourceReadRequest) -> dex.StepDecision:
46
+ if not input.order_id:
47
+ return dex.force_fail("OrderID is required")
48
+ return dex.go_to(dex.StepRef(_READ_STEP_TYPE), input)
49
+
50
+
51
+ # dex:group group-id:resource-result group-label:"Resource result"
52
+ # dex:explanation text:"Persist and return the provider result as the Flow outcome."
53
+ class _CompleteRead(dex.Step[QueryResult[Order]]):
54
+ def get_step_type(self) -> str:
55
+ return "CompleteResourceRead"
56
+
57
+ def execute(self, context: dex.Context, input: QueryResult[Order]) -> dex.StepDecision:
58
+ outcome = ResourceReadOutcome(input.value)
59
+ _OUTCOME.set(context, outcome)
60
+ return dex.graceful_complete(outcome)
61
+
62
+
63
+ class ResourceReadFlow(dex.Flow[ResourceReadRequest]):
64
+ """Read one PayPal checkout order through the static paypal connection."""
65
+
66
+ def __init__(self, connection: Connection) -> None:
67
+ if connection.reference.name != CONNECTION_NAME:
68
+ raise ValueError("resource read requires the static paypal connection")
69
+ self._prepare = _PrepareRequest()
70
+ self._complete = _CompleteRead()
71
+ self._read = new_get_order_step(
72
+ step_type=_READ_STEP_TYPE,
73
+ step_input_type=ResourceReadRequest,
74
+ annotations={
75
+ "groupId": "paypal",
76
+ "groupLabel": "PayPal",
77
+ "explanation": "Read the requested PayPal resource.",
78
+ },
79
+ connection=connection,
80
+ connection_name=CONNECTION_NAME,
81
+ map_to_operation_input=map_to_operation_input,
82
+ found=self._complete,
83
+ )
84
+
85
+ def get_flow_type(self) -> str:
86
+ """Return the stable Flow identity used in Dex Web."""
87
+ return FLOW_TYPE
88
+
89
+ def get_steps(self) -> dex.StepList[ResourceReadRequest]:
90
+ """Register request preparation, the PayPal read, and completion Steps."""
91
+ return dex.StepList.start_step(self._prepare).other_steps(self._read, self._complete)
92
+
93
+ def get_persistence_schema(self) -> dex.PersistenceSchema:
94
+ """Persist the order outcome."""
95
+ return dex.PersistenceSchema.of(_OUTCOME)
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Worker entrypoint for the PayPal resource read Flow."""
4
+
5
+ import asyncio
6
+ import os
7
+ import tempfile
8
+ from pathlib import Path
9
+
10
+ import dex
11
+ from dex_connectors.sdk.projectconfig import load_from_environment
12
+
13
+ from dex_connectors.paypal import new_project_connection
14
+
15
+ from .flow import CONNECTION_NAME, ResourceReadFlow
16
+
17
+
18
+ async def run_worker() -> None:
19
+ """Load the named Dex Web connection and serve PayPal resource reads."""
20
+ project = await load_from_environment()
21
+ connection = None
22
+ cache = None
23
+ try:
24
+ connection = new_project_connection(project, CONNECTION_NAME)
25
+ registry = dex.Registry([ResourceReadFlow(connection)], allow_async_handlers=True)
26
+ cache_directory = os.environ.get(
27
+ "DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-paypal-resource-read-blobs")
28
+ )
29
+ cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 30))
30
+ worker = dex.AsyncWorker(
31
+ registry,
32
+ cache,
33
+ dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
34
+ )
35
+ async with worker:
36
+ await worker.start()
37
+ finally:
38
+ if connection is not None:
39
+ await connection.aclose()
40
+ if cache is not None:
41
+ cache.close()
42
+ await project.close()
43
+
44
+
45
+ def main() -> None:
46
+ """Run until the Worker stops or the process receives an interrupt."""
47
+ asyncio.run(run_worker())
48
+
49
+
50
+ if __name__ == "__main__":
51
+ main()
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dex-connector-paypal"
7
+ version = "0.1.0"
8
+ description = "PayPal connector for Dex Flows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = ["dex-connectors-sdk==0.1.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
13
+
14
+ [dependency-groups]
15
+ dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "pyyaml>=6", "types-PyYAML>=6"]
16
+
17
+ [tool.hatch.build.targets.wheel]
18
+ packages = ["src/dex_connectors"]
19
+
20
+ [tool.pytest.ini_options]
21
+ testpaths = ["tests"]
22
+ pythonpath = [".", "src"]
23
+ asyncio_mode = "auto"
24
+ asyncio_default_fixture_loop_scope = "function"
25
+
26
+ [tool.mypy]
27
+ python_version = "3.11"
28
+ strict = true
29
+ mypy_path = "src"
30
+ explicit_package_bases = true
31
+
32
+ [tool.ruff]
33
+ target-version = "py311"
34
+ line-length = 110
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,61 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """PayPal order and transaction operations for Dex connector Steps."""
4
+
5
+ from .client import (
6
+ CONNECTOR_ID,
7
+ DEFECT,
8
+ FOUND,
9
+ GET_ORDER_DEFINITION,
10
+ INVALID_RESPONSE,
11
+ LIST_TRANSACTIONS_DEFINITION,
12
+ LISTED,
13
+ NOT_FOUND,
14
+ PROVIDER_REJECTED,
15
+ Client,
16
+ Config,
17
+ Credentials,
18
+ GetOrderOperation,
19
+ ListTransactionsOperation,
20
+ )
21
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
22
+ from .models import (
23
+ GetOrderInput,
24
+ ListTransactionsInput,
25
+ Order,
26
+ TransactionAmount,
27
+ TransactionDetail,
28
+ TransactionInfo,
29
+ TransactionPage,
30
+ )
31
+ from .steps import new_get_order_step, new_list_transactions_step
32
+
33
+ __all__ = [
34
+ "Client",
35
+ "Config",
36
+ "Connection",
37
+ "Credentials",
38
+ "GetOrderInput",
39
+ "GetOrderOperation",
40
+ "ListTransactionsInput",
41
+ "ListTransactionsOperation",
42
+ "Order",
43
+ "TransactionAmount",
44
+ "TransactionDetail",
45
+ "TransactionInfo",
46
+ "TransactionPage",
47
+ "new_connection",
48
+ "new_connection_with_operations",
49
+ "new_get_order_step",
50
+ "new_list_transactions_step",
51
+ "new_project_connection",
52
+ "CONNECTOR_ID",
53
+ "DEFECT",
54
+ "FOUND",
55
+ "GET_ORDER_DEFINITION",
56
+ "INVALID_RESPONSE",
57
+ "LIST_TRANSACTIONS_DEFINITION",
58
+ "LISTED",
59
+ "NOT_FOUND",
60
+ "PROVIDER_REJECTED",
61
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,26 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from dex_connectors.sdk import SecretString
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class Config:
12
+
13
+ base_url: str = "https://api-m.paypal.com"
14
+ timeout_seconds: float = 15
15
+ max_response_bytes: int = 2097152
16
+
17
+ setattr(Config, '__module__', 'dex_connectors.paypal.client')
18
+
19
+
20
+ @dataclass(frozen=True, slots=True)
21
+ class Credentials:
22
+
23
+ client_id: str
24
+ client_secret: SecretString
25
+
26
+ setattr(Credentials, '__module__', 'dex_connectors.paypal.client')
@@ -0,0 +1,142 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+ from dex_connectors.sdk import ConnectionRef, Query, Call, SecretString
9
+ from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
10
+
11
+ from ..client import Client, Config, Credentials
12
+ from .definitions import CONNECTOR_ID, GET_ORDER_DEFINITION, LIST_TRANSACTIONS_DEFINITION
13
+ from ..models import GetOrderInput, ListTransactionsInput, Order, TransactionPage
14
+
15
+ class Connection:
16
+
17
+ __slots__ = ('_list_transactions', '_get_order', '_client', 'reference')
18
+
19
+ def __init__(self,
20
+ reference: ConnectionRef,
21
+ list_transactions: Query[ListTransactionsInput, TransactionPage],
22
+ get_order: Query[GetOrderInput, Order],
23
+ client: Client | None = None,
24
+ ) -> None:
25
+ reference.validate()
26
+ if reference.provider != CONNECTOR_ID or list_transactions is None or get_order is None:
27
+ raise ValueError("PayPal connection provider and operations are required")
28
+ if list_transactions.definition().operation != LIST_TRANSACTIONS_DEFINITION.operation:
29
+ raise ValueError("PayPal connection operation identity differs")
30
+ if get_order.definition().operation != GET_ORDER_DEFINITION.operation:
31
+ raise ValueError("PayPal connection operation identity differs")
32
+ self.reference = reference
33
+ self._list_transactions = list_transactions
34
+ self._get_order = get_order
35
+ self._client = client
36
+
37
+ def list_transactions(self) -> Query[ListTransactionsInput, TransactionPage]:
38
+ return self._list_transactions
39
+
40
+ def get_order(self) -> Query[GetOrderInput, Order]:
41
+ return self._get_order
42
+
43
+ async def aclose(self) -> None:
44
+ if self._client is not None:
45
+ await self._client.aclose()
46
+
47
+ def __repr__(self) -> str:
48
+ return "paypal.Connection([REDACTED])"
49
+
50
+ def __reduce__(self) -> tuple[object, ...]:
51
+ raise TypeError("PayPal connections cannot be serialized")
52
+
53
+ setattr(Connection, '__module__', 'dex_connectors.paypal.connection')
54
+
55
+
56
+ def new_connection(client: Client, reference: ConnectionRef) -> Connection:
57
+ if client is None:
58
+ raise ValueError("PayPal client is required")
59
+ return Connection(reference, client.list_transactions(), client.get_order(), client)
60
+
61
+ setattr(new_connection, '__module__', 'dex_connectors.paypal.connection')
62
+
63
+
64
+ def new_connection_with_operations(
65
+ list_transactions: Query[ListTransactionsInput, TransactionPage],
66
+ get_order: Query[GetOrderInput, Order],
67
+ reference: ConnectionRef,
68
+ ) -> Connection:
69
+ return Connection(reference, list_transactions, get_order)
70
+
71
+ setattr(new_connection_with_operations, '__module__', 'dex_connectors.paypal.connection')
72
+
73
+
74
+ class _ProjectCredentialSource:
75
+
76
+ def __init__(self, project: LoadedProject, key: ConnectionKey) -> None:
77
+ self.project = project
78
+ self.key = key
79
+
80
+ async def resolve(self, call: Call) -> Credentials:
81
+ material = await self.project.resolve_credential(self.key, str(call.id))
82
+ if not isinstance(material, dict):
83
+ raise ValueError("PayPal stored credential does not match the connector credential fields")
84
+ if set(material) - set(('client_id', 'client_secret')):
85
+ raise ValueError("PayPal stored credential does not match the connector credential fields")
86
+ client_id = material.get("client_id")
87
+ if client_id is not None and not (isinstance(client_id, str)):
88
+ raise ValueError("PayPal credential client_id has an invalid type")
89
+ client_secret = material.get("client_secret")
90
+ if client_secret is not None and not (isinstance(client_secret, str)):
91
+ raise ValueError("PayPal credential client_secret has an invalid type")
92
+ if not client_id:
93
+ raise ValueError("PayPal credential client_id is required")
94
+ if not client_secret:
95
+ raise ValueError("PayPal credential client_secret is required")
96
+ return Credentials(client_id, SecretString(client_secret))
97
+
98
+
99
+ def new_project_connection(
100
+ project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
101
+ ) -> Connection:
102
+ if project is None:
103
+ raise ValueError("PayPal connection requires loaded project configuration")
104
+ reference = ConnectionRef(CONNECTOR_ID, connection_name)
105
+ reference.validate()
106
+ key = ConnectionKey(CONNECTOR_ID, connection_name)
107
+ matching = [
108
+ entry
109
+ for entry in project.configuration.connections
110
+ if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
111
+ ]
112
+ if len(matching) != 1:
113
+ raise ValueError("PayPal project connection is missing or duplicated")
114
+ if matching[0].provider != CONNECTOR_ID:
115
+ raise ValueError("PayPal project connection provider differs")
116
+ config = _decode_config(matching[0].configuration)
117
+ client = Client(config, _ProjectCredentialSource(project, key), http_client)
118
+ return new_connection(client, reference)
119
+
120
+ setattr(new_project_connection, '__module__', 'dex_connectors.paypal.connection')
121
+
122
+
123
+ def _decode_config(value: dict[str, Any]) -> Config:
124
+ if set(value) - {"baseUrl", "timeout", "maxResponseBytes"}:
125
+ raise ValueError("PayPal configuration has unknown fields")
126
+ config_arguments: dict[str, Any] = {}
127
+ if "baseUrl" in value:
128
+ base_url = value["baseUrl"]
129
+ if not (isinstance(base_url, str)):
130
+ raise ValueError("PayPal configuration baseUrl has an invalid type")
131
+ config_arguments['base_url'] = base_url
132
+ if "timeout" in value:
133
+ timeout = value["timeout"]
134
+ if not (type(timeout) is int):
135
+ raise ValueError("PayPal configuration timeout has an invalid type")
136
+ config_arguments['timeout_seconds'] = timeout / 1_000_000_000
137
+ if "maxResponseBytes" in value:
138
+ max_response_bytes = value["maxResponseBytes"]
139
+ if not (type(max_response_bytes) is int):
140
+ raise ValueError("PayPal configuration maxResponseBytes has an invalid type")
141
+ config_arguments['max_response_bytes'] = max_response_bytes
142
+ return Config(**config_arguments)
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from datetime import timedelta
6
+
7
+ from dex_connectors.sdk import (
8
+ BranchDefinition,
9
+ MutationDefinition,
10
+ OperationRef,
11
+ QueryDefinition,
12
+ RetryPolicy,
13
+ StepDefaults,
14
+ default_connector_step_execute_retry_policy,
15
+ )
16
+
17
+ CONNECTOR_ID = "paypal"
18
+ PROVIDER = "paypal"
19
+ LIST_TRANSACTIONS_OPERATION_ID = "listTransactions"
20
+ GET_ORDER_OPERATION_ID = "getOrder"
21
+ DEFECT = "defect"
22
+ FOUND = "found"
23
+ INVALID_RESPONSE = "invalidResponse"
24
+ LISTED = "listed"
25
+ NOT_FOUND = "notFound"
26
+ PROVIDER_REJECTED = "providerRejected"
27
+
28
+ LIST_TRANSACTIONS_DEFINITION = QueryDefinition(
29
+ OperationRef(CONNECTOR_ID, LIST_TRANSACTIONS_OPERATION_ID),
30
+ (
31
+ BranchDefinition(LISTED, "List one page of PayPal transactions in a date range.", False),
32
+ BranchDefinition(NOT_FOUND, "The requested resource was not found.", True),
33
+ BranchDefinition(PROVIDER_REJECTED, "The provider conclusively rejected the request.", True),
34
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
35
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
36
+ ),
37
+ StepDefaults(
38
+ timedelta(seconds=30),
39
+ 2,
40
+ execute_retry=default_connector_step_execute_retry_policy(),
41
+ ),
42
+ )
43
+
44
+ GET_ORDER_DEFINITION = QueryDefinition(
45
+ OperationRef(CONNECTOR_ID, GET_ORDER_OPERATION_ID),
46
+ (
47
+ BranchDefinition(FOUND, "Read one PayPal checkout order.", False),
48
+ BranchDefinition(NOT_FOUND, "The requested resource was not found.", True),
49
+ BranchDefinition(PROVIDER_REJECTED, "The provider conclusively rejected the request.", True),
50
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
51
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
52
+ ),
53
+ StepDefaults(
54
+ timedelta(seconds=30),
55
+ 2,
56
+ execute_retry=default_connector_step_execute_retry_policy(),
57
+ ),
58
+ )