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
2 changes: 1 addition & 1 deletion app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const metadata = {
template: '%s | Selcom Developers'
},
description:
'Open-source community clients for the Selcom payment API in Java, Node.js, PHP and Laravel. Not affiliated with Selcom Paytech Ltd.'
'Open-source community clients for the Selcom payment API in Java, Node.js, Python, PHP and Laravel. Not affiliated with Selcom Paytech Ltd.'
}

const navbar = (
Expand Down
3 changes: 2 additions & 1 deletion components/landing/hero.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Stamp } from './stamp'
const clients = [
{ href: '/clients/java', label: 'Java' },
{ href: '/clients/node', label: 'Node.js' },
{ href: '/clients/python', label: 'Python' },
{ href: '/clients/php', label: 'PHP' },
{ href: '/clients/laravel', label: 'Laravel' }
]
Expand Down Expand Up @@ -65,7 +66,7 @@ export function Hero() {
Call the Selcom API without paying anyone twice.
</h1>
<p className="mt-6 max-w-[54ch] text-lg leading-relaxed text-ink-soft">
Open-source clients for Java, Node.js, PHP and Laravel, built from one shared spec. Every
Open-source clients for Java, Node.js, Python, PHP and Laravel, built from one shared spec. Every
request is signed, every outcome has a typed status, and no payment is ever retried
behind your back.
</p>
Expand Down
1 change: 1 addition & 0 deletions components/landing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const installs = [
</dependency>`
},
{ value: 'node', label: 'Node.js', registry: 'npm', runtime: 'Node 20 or later', href: '/clients/node', lang: 'bash', code: 'npm i @selcom-developers/selcom' },
{ value: 'python', label: 'Python', registry: 'PyPI', runtime: 'Python 3.10 or later', href: '/clients/python', lang: 'bash', code: 'pip install selcompy' },
{ value: 'php', label: 'PHP', registry: 'Packagist', runtime: 'PHP 8.2 or later', href: '/clients/php', lang: 'bash', code: 'composer require selcom-developers/selcom-php' },
{
value: 'laravel',
Expand Down
12 changes: 11 additions & 1 deletion components/landing/same-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ if (status.status() == Status.SUCCESS) { /* fulfil */ }`
code: `const status = await selcom.orderStatus({ orderId: "ORD-1001" });
if (status.status === "SUCCESS") { /* fulfil */ }`
},
{
name: 'Python',
href: '/clients/python',
runtime: 'Python 3.10 or later',
pkg: 'selcompy',
lang: 'python',
code: `status = client.order_status("ORD-1001")
if status.status is Status.SUCCESS:
... # fulfil`
},
{
name: 'PHP',
href: '/clients/php',
Expand All @@ -45,7 +55,7 @@ if ($status->status === Status::Success) { /* fulfil */ }`

export function SameSpec() {
return (
<div className="grid gap-4 md:grid-cols-2">
<div className="grid gap-4 md:grid-cols-2 md:[&>*:last-child:nth-child(odd)]:col-span-2">
{clients.map((client) => (
<article key={client.name} className="flex min-w-0 flex-col rounded-xl border border-rule bg-card">
<header className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 px-5 pt-5">
Expand Down
2 changes: 1 addition & 1 deletion components/site/code.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let highlighter
function getHighlighter() {
highlighter ??= createHighlighter({
themes: [lightTheme, darkTheme],
langs: ['js', 'ts', 'java', 'php', 'xml', 'bash', 'http']
langs: ['js', 'ts', 'java', 'php', 'python', 'xml', 'bash', 'http']
})
return highlighter
}
Expand Down
1 change: 1 addition & 0 deletions content/clients/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
index: 'Overview',
java: 'Java',
node: 'Node.js',
python: 'Python',
php: 'PHP',
laravel: 'Laravel'
}
1 change: 1 addition & 0 deletions content/clients/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The community clients follow the same [spec](/spec), so they sign requests and r
<LinkCards>
<LinkCard href="/clients/java" title="Java" detail="io.github.selcom-developers:selcom4j">Java 17 or later. One runtime dependency: Jackson databind.</LinkCard>
<LinkCard href="/clients/node" title="Node.js" detail="@selcom-developers/selcom">TypeScript and JavaScript on Node 20 or later. No runtime dependencies.</LinkCard>
<LinkCard href="/clients/python" title="Python" detail="selcompy">Python 3.10 or later. Sync and async clients on httpx.</LinkCard>
<LinkCard href="/clients/php" title="PHP" detail="selcom-developers/selcom-php">PHP 8.2 or later, any framework. PSR-18 HTTP.</LinkCard>
<LinkCard href="/clients/laravel" title="Laravel" detail="selcom-developers/laravel-selcom">Laravel 12 or 13, built on the PHP client.</LinkCard>
</LinkCards>
Expand Down
4 changes: 2 additions & 2 deletions content/clients/laravel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ SELCOM_VENDOR=... # the vendor (till) ID
SELCOM_PIN=... # float PIN: payout operations only
```

{/* TODO(laravel-quickstart): re-check this quickstart against the laravel-selcom main README once v1 is merged. */}

## Quickstart

The `Selcom` facade proxies the PHP client, so every operation of the [PHP client](/clients/php) is available.
Expand Down Expand Up @@ -62,6 +60,8 @@ match ($result->status) {
$status = Selcom::orderStatus(new OrderStatusRequest('ORD-1001'));
```

You can also type-hint `SelcomDevelopers\Selcom\Client` and let the container inject it.

The [README](https://github.com/selcom-developers/laravel-selcom#readme) covers the container bindings, the webhook route, events, models, artisan commands and testing.

## How it behaves
Expand Down
81 changes: 81 additions & 0 deletions content/clients/python.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Python client
description: The community Python client for the Selcom payment API, with a synchronous and an asynchronous client on httpx. Python 3.10 or later.
---

# Python client

Request signing, checkout, payouts and webhooks for Python 3.10 or later. A synchronous `Client` and an asynchronous `AsyncClient` share the same operations, built on [httpx](https://www.python-httpx.org/), the only runtime dependency.

Repository: [selcom-developers/selcompy](https://github.com/selcom-developers/selcompy)

## Install

```bash
pip install selcompy
```

## Quickstart

Pay a utility bill from your float account and act on the typed status.

```python
from selcompy import (
Client,
Config,
Credentials,
Environment,
Status,
UtilityPaymentRequest,
)

config = Config(
environment=Environment.SANDBOX, # no default: you always choose
credentials=Credentials(
api_key="...",
api_secret="...",
vendor="TILL123",
pin="...",
),
)

with Client(config) as client:
result = client.utility_payment(
UtilityPaymentRequest(
transid="PAYOUT-1001", # your own deterministic ID
utilitycode="LUKU",
utilityref="54100000001",
amount=5000, # whole TZS
)
)
if result.status is Status.SUCCESS:
print(result.value.receipt)
```

The asynchronous client has the same operations, and every method is a coroutine:

```python
from selcompy import AsyncClient

async with AsyncClient(config) as client:
result = await client.order_status("ORD-1001")
```

The environment is required and has no default. Every operation returns a `Result` with one of the typed statuses: `SUCCESS`, `PENDING`, `AMBIGUOUS`, `FAILED` or `NOT_FOUND`.

The [README](https://github.com/selcom-developers/selcompy#readme) covers configuration, every operation, results and errors, idempotency, replacing the transport, webhooks and security.

## How it behaves

The client follows the [shared spec](/spec). These pages explain what it does:

<LinkCards>
<LinkCard href="/spec/signing" title="Request signing">How every request is signed, with worked examples.</LinkCard>
<LinkCard href="/spec/results" title="Results and retries">The typed statuses, idempotency and when to query.</LinkCard>
<LinkCard href="/spec/webhooks" title="Webhooks">Verify a delivery, then confirm it with order status.</LinkCard>
<LinkCard href="/spec/client-requirements" title="Client requirements">What every client does, in every language.</LinkCard>
</LinkCards>

## Help and issues

Found a problem, or want to help? Open an issue in the [repository](https://github.com/selcom-developers/selcompy/issues), or read [Contributing](/community/contributing). For security problems, see [Security reporting](/community/security).
1 change: 1 addition & 0 deletions content/community/contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Thank you for helping. These projects are run by the community, and every fix co
| Rules, test vectors, API notes | [selcom-spec](https://github.com/selcom-developers/selcom-spec) |
| Java client | [selcom4j](https://github.com/selcom-developers/selcom4j) |
| Node.js client | [selcom-node](https://github.com/selcom-developers/selcom-node) |
| Python client | [selcompy](https://github.com/selcom-developers/selcompy) |
| PHP client | [selcom-php](https://github.com/selcom-developers/selcom-php) |
| Laravel package | [laravel-selcom](https://github.com/selcom-developers/laravel-selcom) |
| This site | [selcom-developers.github.io](https://github.com/selcom-developers/selcom-developers.github.io) |
Expand Down
1 change: 1 addition & 0 deletions content/getting-started/choosing-a-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Every client follows the same [spec](/spec). They sign the same way, read result
|---|---|---|
| Java or a JVM language | [Java](/clients/java) | Maven `io.github.selcom-developers:selcom4j` |
| Node.js, TypeScript or JavaScript | [Node.js](/clients/node) | npm `@selcom-developers/selcom` |
| Python | [Python](/clients/python) | PyPI `selcompy` |
| PHP without a framework, or another framework | [PHP](/clients/php) | Packagist `selcom-developers/selcom-php` |
| Laravel | [Laravel](/clients/laravel) | Packagist `selcom-developers/laravel-selcom` |

Expand Down
2 changes: 1 addition & 1 deletion content/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ The clients are written to the [shared spec](/spec). They sign every request, in
## Next step

<LinkCards>
<LinkCard href="/getting-started/choosing-a-client" title="Choose a client">Java, Node.js, PHP or Laravel: which one fits your stack.</LinkCard>
<LinkCard href="/getting-started/choosing-a-client" title="Choose a client">Java, Node.js, Python, PHP or Laravel: which one fits your stack.</LinkCard>
<LinkCard href="/spec/results" title="Results and retries">Read this before you send your first payment.</LinkCard>
</LinkCards>
2 changes: 1 addition & 1 deletion content/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Community clients for the Selcom payment API
description: Open-source clients for the Selcom payment API in Java, Node.js, PHP and Laravel, built from one shared spec. Not affiliated with Selcom Paytech Ltd.
description: Open-source clients for the Selcom payment API in Java, Node.js, Python, PHP and Laravel, built from one shared spec. Not affiliated with Selcom Paytech Ltd.
---

import { Landing } from '@/components/landing'
Expand Down
4 changes: 2 additions & 2 deletions content/spec/client-requirements.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: What every community client must do.

# What every client must do

The Java, Node/TypeScript, PHP and Laravel clients differ in idiom, not in behaviour. This is the checklist they are reviewed against. MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119.
The Java, Node/TypeScript, Python, PHP and Laravel clients differ in idiom, not in behaviour. This is the checklist they are reviewed against. MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119.

## Configuration and environments

Expand Down Expand Up @@ -84,7 +84,7 @@ If the HTTP library cannot tell which case it is, the answer is `UNKNOWN_OUTCOME
- One method per v1 operation, named after it (`createOrder`, `walletPayment`, `orderStatus`, `utilityPayment`, `utilityQuery`, and so on, in each language's style).
- Submitting and querying are separate methods. Nothing hides a query inside a submit.
- Every method returns the result object from [Results and retries](/spec/results#the-result-object): the typed status, the code and text, the HTTP status, the decoded data and the raw body.
- The HTTP transport is injectable (PSR-18 in PHP, `fetch` in Node, `java.net.http.HttpClient` or an interface over it in Java) so that tests can run without a network.
- The HTTP transport is injectable (PSR-18 in PHP, `fetch` in Node, `httpx` transports in Python, `java.net.http.HttpClient` or an interface over it in Java) so that tests can run without a network.
- Webhook support: `verify(headers, rawBody)` returning the verdicts in [Webhooks](/spec/webhooks#verification), and an amount parser. The Laravel package adds a route, middleware and an event, and follows the handling steps in that page.
- Clients SHOULD send a `User-Agent` naming the client and its version, for example `selcom-node/0.1.0`.

Expand Down