Skip to main content

Python SDK for Siglume Direct Request Payment checkout integrations

Project description

@siglume/direct-request-payment

Merchant SDK for Siglume Direct Request Payment checkout integrations.

Use this package when an external EC site, booking service, membership service, or paid API wants to accept Siglume wallet payments without taking custody of customer funds.

This SDK is intentionally separate from @siglume/api-sdk:

  • @siglume/api-sdk is for publishing agent-facing APIs to the Siglume API Store.
  • @siglume/direct-request-payment is for external merchants integrating Siglume Direct Request Payment into their own checkout.

Install

npm install @siglume/direct-request-payment
pip install siglume-direct-request-payment

Node.js 18 or later is required for the TypeScript SDK. Python 3.11 or later is required for the Python SDK.

Current Platform Contract

The public product name is Siglume Direct Request Payment. The current platform payload still uses the internal mode name external_402; this SDK sets that value for you when creating a payment requirement.

Payment requirement creation must run in the authenticated buyer's Siglume context. Your merchant server must not use a merchant secret or API key to charge a customer wallet. The merchant server creates the signed challenge; the buyer-facing Siglume payment flow creates and pays the requirement.

DirectRequestPaymentClient requires the buyer's Siglume bearer token. Do not use a Developer Portal cli_ API key with this package.

Trial Pricing

Siglume Direct Request Payment is currently offered with trial-phase merchant pricing designed for small EC sites, booking services, membership services, paid APIs, and agent-to-agent payment experiments.

Plan Monthly fee Payment fee
Launch JPY 0 0% through 100 payments/month, then 1.8%
Starter JPY 980 1.0%
Growth JPY 2,980 0.7%
Pro JPY 9,800 0.5%

The minimum fee is JPY 3 for each fee-bearing payment, including Launch-plan payments after the included monthly allowance. A merchant billing mandate is required before accepting payments, even on the Launch plan. The API and merchant registry may still expose the internal plan key free for this tier. See docs/pricing.md for details.

Per-payment fees are deducted at payment settlement time, so the merchant receives the net amount. Monthly base fees are collected through the merchant billing mandate. The listed public pricing is JPY-denominated; USD/USDC merchant billing requires separately agreed terms.

Merchant Server: Create a Challenge

import { createDirectRequestPaymentChallenge } from "@siglume/direct-request-payment";

const challenge = await createDirectRequestPaymentChallenge({
  merchant: "example_merchant",
  amount_minor: 1200,
  currency: "JPY",
  secret: process.env.SIGLUME_DIRECT_PAYMENT_CHALLENGE_SECRET!,
  nonce: "order_123-attempt_1",
});

// Return only challenge.challenge to the buyer-facing checkout.
// Never return the challenge secret to the browser.
console.log(challenge.challenge);
import os

from siglume_direct_request_payment import create_direct_request_payment_challenge

challenge = create_direct_request_payment_challenge(
    merchant="example_merchant",
    amount_minor=1200,
    currency="JPY",
    secret=os.environ["SIGLUME_DIRECT_PAYMENT_CHALLENGE_SECRET"],
    nonce="order_123-attempt_1",
)

print(challenge["challenge"])

The signed challenge binds:

  • merchant key
  • amount in minor units
  • currency
  • nonce

Changing any of those values invalidates the challenge. The nonce must not contain : because the current platform challenge format is scheme:nonce:signature.

Buyer Payment Flow

Use DirectRequestPaymentClient only with the authenticated buyer's Siglume bearer token. SIGLUME_AUTH_TOKEN may be used in server-side payment-confirmation helpers; SIGLUME_API_KEY and Developer Portal cli_ keys are not accepted.

import { DirectRequestPaymentClient } from "@siglume/direct-request-payment";

const siglume = new DirectRequestPaymentClient({
  auth_token: buyerSiglumeBearerToken,
});

const requirement = await siglume.createPaymentRequirement({
  merchant: "example_merchant",
  amount_minor: 1200,
  currency: "JPY",
  challenge: challengeFromMerchantServer,
});

if (requirement.approve_transaction_request) {
  await siglume.executeAllowanceTransaction(requirement, { await_finality: true });
}

const payment = await siglume.executePaymentTransaction(requirement, {
  await_finality: true,
});

const receiptId = String(payment.receipt?.receipt_id ?? "");
const verified = await siglume.verifyPaymentRequirement(requirement.requirement_id, {
  receipt_id: receiptId,
  await_finality: false,
});

console.log(verified.status);
from siglume_direct_request_payment import DirectRequestPaymentClient

siglume = DirectRequestPaymentClient(auth_token=buyer_siglume_bearer_token)

requirement = siglume.create_payment_requirement(
    merchant="example_merchant",
    amount_minor=1200,
    currency="JPY",
    challenge=challenge_from_merchant_server,
)

if requirement.get("approve_transaction_request"):
    siglume.execute_allowance_transaction(requirement, await_finality=True)

payment = siglume.execute_payment_transaction(requirement, await_finality=True)
receipt_id = str((payment.get("receipt") or {}).get("receipt_id") or "")

verified = siglume.verify_payment_requirement(
    requirement["requirement_id"],
    receipt_id=receipt_id,
    await_finality=False,
)

print(verified["status"])

Webhooks

Your merchant system should treat Siglume webhooks as the durable delivery signal. Always verify the signature against the raw request body before trusting the payload. Create a marketplace webhook subscription with POST /v1/market/webhooks/subscriptions; the response returns the whsec_ signing secret once.

import { verifyDirectRequestPaymentWebhook } from "@siglume/direct-request-payment";

const { event } = await verifyDirectRequestPaymentWebhook(
  process.env.SIGLUME_WEBHOOK_SECRET!,
  rawRequestBody,
  request.headers["siglume-signature"],
);

if (event.type === "direct_payment.confirmed") {
  // Mark the order paid if event.data.challenge_hash/order mapping matches.
}
import os

from siglume_direct_request_payment import verify_direct_request_payment_webhook

verified = verify_direct_request_payment_webhook(
    os.environ["SIGLUME_WEBHOOK_SECRET"],
    raw_request_body,
    siglume_signature_header,
)

if verified["event"]["type"] == "direct_payment.confirmed":
    # Mark the order paid if event.data.challenge_hash/order mapping matches.
    pass

Security Rules

  • Keep the challenge secret on the merchant server only.
  • Keep merchant order amount and currency server-authored.
  • Use one nonce per order payment attempt.
  • Store challenge_hash with the order and reject mismatches.
  • Make order fulfillment idempotent by requirement_id and order id.
  • Verify webhook signatures against the raw body.
  • Do not use a merchant token to charge a customer wallet.
  • Do not treat Direct Request Payment as stored value, prepaid points, escrow, or a platform balance.

Read docs/security.md before going live.

Documentation

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siglume_direct_request_payment-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

siglume_direct_request_payment-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file siglume_direct_request_payment-0.1.0.tar.gz.

File metadata

File hashes

Hashes for siglume_direct_request_payment-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f80cc9056b801b97ed1cd052a992bd89355347e880f588c1c84be8102569b776
MD5 bd62f37d742a11843d3e503006507e2a
BLAKE2b-256 9bbd0d1738cc9610b92d3ed14d67373dbfd410a69e5ef7f2a508023ed99a1c7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for siglume_direct_request_payment-0.1.0.tar.gz:

Publisher: release-pypi.yml on taihei-05/siglume-direct-request-payment

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file siglume_direct_request_payment-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for siglume_direct_request_payment-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e3dec68087d338dcb5a9d98644b1e882ba765362caa9bcfd2b748be5a1b35ad
MD5 4a2c672e7259b7f3821521e78c901246
BLAKE2b-256 8c8db7557764fd65ef4de68aacd8ba2734d5d25069ab4045ba6fc2e3168cf01b

See more details on using hashes here.

Provenance

The following attestation bundles were made for siglume_direct_request_payment-0.1.0-py3-none-any.whl:

Publisher: release-pypi.yml on taihei-05/siglume-direct-request-payment

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page