PFlux DOCS
GitHub Integration enquiries Start integrating
REFERENCE/SDKS

SDKs

Two thin clients over the same HTTP API. Neither is required, and neither is published to a package registry yet.

JS@p2flux/sdk · 0.1.0
PHPp2flux/p2flux-php · 0.1.0
DEPENDENCIESNone
REGISTRYNot published yet

Both clients are thin wrappers over the HTTP API. They normalize result codes and nothing else — no scheduling, no storage, no retry loops. Anything either can do, a plain HTTPS request can do too.

Install

NOT ON NPM OR PACKAGIST

Neither package is published to a registry yet. Install from a pinned git tag, as the SDK repositories themselves instruct.

JavaScript
npm install github:P2Flux/sdk-js#v0.1.0   # not on npm yet
PHP — composer.json
{
  "repositories": [{ "type": "vcs", "url": "https://github.com/P2Flux/sdk-php" }],
  "require": { "p2flux/p2flux-php": "v0.1.0" }
}

JavaScript / TypeScript

Zero dependencies. charge() never throws on a payment outcome — an unreachable API comes back as NETWORK_ERROR / RETRY_LATER rather than an exception.

renewal job
import { createP2Flux } from '@p2flux/sdk'

const p2flux = createP2Flux({
  apiUrl: process.env.P2FLUX_API_URL,
  timeoutMs: 30_000   // default 60s: a charge waits for confirmation
})

const result = await p2flux.charge(ref)
result.ok            // CHARGED or ALREADY_CHARGED
result.action        // SUCCESS | WAIT | RETRY_LATER | …
result.retryable     // safe to repeat the identical call
result.raw           // the untouched API body
METHODWHAT IT DOES
charge(ref)Attempt this period’s payment. Safe to retry.
status(ref)Current state read from the chain.
prepareSubscriptionCancellation(ref)Calldata the customer’s wallet sends to cancel one subscription.
prepareAllowanceRevocation()Calldata for approve(contract, 0) — the customer’s global stop.

PHP

PHP 8.1+, curl by default, no framework and no Composer runtime dependencies. The constructor takes an optional transport callable, so a host application can route requests through its own HTTP stack — wp_remote_post, Guzzle — or stub them in tests.

PHP
use P2Flux\P2FluxClient;

$p2flux = new P2FluxClient([
  'apiUrl'    => getenv('P2FLUX_API_URL'),
  'timeout'   => 30,
  'transport' => fn($url, $payload, $timeout) => [$status, $body],
]);

$result = $p2flux->charge($subscriptionRef);   // never throws on an outcome

What each client covers

The two clients are not at parity today. The PHP client wraps the full surface; the JavaScript client implements the renewal path only. Anything missing is a plain POST away.

CALLJSPHP
chargeYesYes
statusYesYes
prepareSubscriptionCancellationYesYes
prepareAllowanceRevocationYesYes
createPaymentYes
verifyPaymentYes
createSubscriptionYes
createCancellationSessionYes

Or use REST

No SDK is required for any part of the integration. Every endpoint is a POST with a JSON body and no authentication — see the API reference. Python and other languages have no client yet; call the API directly.

sdk-js on GitHubSource, tests and the built client.sdk-php on GitHubSource, smoke tests and transport hook.contracts on GitHubSolidity, ABIs and EIP-712 definitions.
Something more than a standard integration?
Marketplace flows, platform billing and custom settlement logic.
Discuss an integration