Skip to main content
Follow this guide when you want your server to create KyrenPay checkout sessions through the API. If you want to learn the dashboard first, start with Dashboard overview.

Prerequisites

  • A KyrenPay merchant account (sign up here)
  • Your API key (found in the Developer section of your dashboard)
  • A product created in the dashboard or through the Products API
  • A server-side environment where your API key can be stored securely
  • A Webhook endpoint for payment notifications before you go live
For one-time payments, the product must be ACTIVE, hosted Checkout must be enabled for your merchant, and an enabled channel must support the product’s currency and amount. Resolve merchant agreement restrictions when applicable. Product creation alone does not guarantee an available payment method. Current per-order caps are USD 630.00, CNY 4,000.00, HKD 5,000.00 and IDR 10,000,000.00; channel and merchant limits may be lower. If an API IP whitelist is configured, allow your server’s outbound IP. Before the first payment, configure a public HTTPS Webhook URL and obtain its separate Webhook Secret in Developer Tools > Webhook Settings. This is not your API Key. Unconfigured Webhooks do not queue ordinary order.paid events; later configuration does not automatically replay past payments.

Step 1: Get your API Key

After signing up, navigate to Dashboard > Developer Tools > API Keys. A full key is shown only when generated. Use your securely stored original value, not its masked display. Regeneration immediately invalidates the old key.
  • Live key: kyren_live_xxxxxxxxxxxx — use this for production
Keep your API keys secure. Never expose them in client-side code or public repositories.
Privately put the full value in your application’s server-side KYREN_API_KEY setting, not in an Agent chat. Generate a key on this page if none exists. If you already have one, use its securely saved full value rather than regenerating it as a routine integration step.

Configure Webhook and get its Secret

  1. Open Dashboard > Developer Tools > Webhooks.
  2. Enter your application’s actual public HTTPS callback URL in Webhook URL and save, for example https://your-app.example/webhooks/kyren. Use the path implemented by your application. Kyren cannot reach localhost; local testing needs a reachable HTTPS host or an authorized tunnel.
  3. First configuration generates a Webhook Secret. Immediately copy its full value into your application’s private server-side KYREN_WEBHOOK_SECRET setting. If no Secret exists, click Generate.
  4. If a Secret is already configured, use its securely saved original. Its masked display cannot verify signatures. Regeneration immediately invalidates the old Secret and requires updating every server that uses it; do not rotate it as a default setup step.
The Webhook Secret and API key are different values. An existing Webhook URL may serve another application; confirm its use before changing it. See Developer settings. This guide uses production addresses. If your integration selects a Kyren-provided development or other environment, use that environment’s dashboard, API Base URL and matching credentials throughout instead of switching to the production examples.

Step 2: Initialize Product Mappings

For an application integration, have its setup code or Agent initialize products from the existing catalog. Query the paginated GET /v1/products list and reuse an unambiguously matching ACTIVE one-time product, checking identity, price and currency. If none matches, create one with POST /v1/products within the user’s authorization. Read data.items and data.pagination for lists and data.id for creation. Persist each local SKU-to-Kyren-product-ID mapping in the application’s database or existing durable catalog, scoped to the environment and merchant. Its backend resolves the mapping when creating Checkout; users do not need to copy every product ID themselves. Price alone is not a product identity. Ask the user to resolve ambiguous matches, and identify missing credentials or creation authorization. Repeated initialization should reuse mappings. Reconcile a create timeout or failed local save before retrying; do not recreate products on every startup or purchase. The following is a manual single-product example. You can also create/select a product in Dashboard > Product Management and copy its Product ID:
Save data.id from the JSON response. For example, { "code": 0, "message": "success", "data": { "id": "prod_abc123" } } illustrates the envelope with other product fields omitted. A product ID is not a secret, merchant PID, Checkout ID or order ID. KYREN_PRODUCT_ID is only an optional setting for a simple single-product application, not an environment variable the platform requires. For Agent-assisted integration, prefer implementing lookup, authorized creation and durable mappings; the user confirms the catalog/prices and privately configures credentials. The application provides its actual initialization and reload commands.

Step 3: Create a Checkout Session

When a customer wants to pay, create a checkout session:
Use displayMerchantName when this checkout should show a campaign, store, or app name that differs from your account name. The response is { "code": 0, "message": "success", "data": { ... } }. Read data.id, data.url, data.amount, data.currency and data.expiresAt (Unix milliseconds), and persist them against your server-generated business order before returning its URL to the browser. Product ID, user identity and metadata must come from trusted server records. Session amount and currency come from the product; price, quantity and currency overrides are not supported. Create one pending Session per business purchase and reuse it on repeated clicks. Sessions expire after 24 hours. The API has no Checkout creation idempotency key, so persist a creation reservation and reconcile timeouts or failed local saves before creating another Session. See the full example.

Step 4: Redirect to Checkout

Redirect the customer to the checkout URL returned in Step 3. They will see a hosted payment page where they can choose their preferred payment method.

Step 5: Handle the Webhook

After payment, KyrenPay sends a signed JSON POST to your configured Webhook URL. Register the raw-body route before any global JSON parser. The following route requires the signature function and the durable inbox adapter described in the full example:
Configure your URL in Dashboard > Developer Tools > Webhook Settings. Verify, persist, then return 2xx within 10 seconds. A durable worker must retry failures, deduplicate event IDs and credit each business order only once using a unique KyrenPay order ID and a database transaction.
successUrl and cancelUrl are browser navigation, not payment evidence. Your backend can query GET /v1/checkouts/{id}: OPEN is pending, COMPLETE includes the successfully associated orderId, and EXPIRED closes the Session. For missed notifications, query GET /v1/orders/{orderId}, verify payment and its product/base amount/currency/metadata association, and use the same idempotent fulfillment transaction as Webhooks. Session creation does not return an orderId. Use the exact returned data.url. successUrl is required; cancelUrl is optional.

What’s Next?

Authentication

Learn about API authentication in detail

Webhook Signatures

Implement secure webhook verification

Testing

Test safely with KyrenPay-issued staging credentials or low-risk live checks

Code Examples

See examples in Python, Node.js, Go, and more