Skip to main content
Use sub2api’s built-in EasyPay provider to collect balance top-ups with KyrenPay. This guide applies to Wei-Shaw/sub2api at commit 42bc7f6, verified on October 1, 2026. Older releases and forks may have different settings; confirm that your version includes the native provider and the fields below.

Before you start

  • Prepare a KyrenPay merchant account with the required payment provider bound and credentials active. Only enable payment methods available to that account.
  • Obtain the merchant account ID for pid and the complete, current API key beginning with kyren_live_ for the merchant secret. Use the raw key, including its prefix, rather than a masked value or Webhook secret. Store it in the administrator settings only.
  • Deploy sub2api behind a public HTTPS domain, for example https://ai.example.com, with its payment callback routed to the backend.
See Developer settings and Epay compatibility.

Configure the payment provider

  1. Open Admin > System Settings > Payment Settings, turn on the Enable Payment master switch at the top of the page, and select EasyPay under Enabled Providers. When the master switch is off, payment orders cannot be created even if a provider instance is enabled.
  2. Under Provider Management, add an EasyPay provider instance, enter the settings from the table below, and turn on the instance’s Enabled switch.
  3. Save the provider instance, then click Save Settings on the payment settings page to save the master switch and provider selection.
You can obtain your KyrenPay merchant account ID (PID) and PKey from KyrenPay Merchant Dashboard > Developer Tools > API Keys. sub2api EasyPay provider settings: custom payment methods, PID, PKey, API base and notification and return addresses The screenshot shows an example interface in Simplified Chinese. Use the endpoint, site origin and credentials from the table below for your integration. The callback editor appends fixed paths. The resulting URLs are https://ai.example.com/api/v1/payment/webhook/easypay and https://ai.example.com/payment/result; enter only the origin in those base inputs. popup builds /epay/submit.php; qrcode calls /epay/mapi.php. The API base is normalized and the endpoint appended by the provider. Settings fields, callback editor, EasyPay client.

Choose payment methods

Select the built-in alipay and/or wxpay options as enabled for your merchant. This verified version also has a Custom payment methods editor. To offer other documented KyrenPay methods, add matching local and upstream type values, then select the resulting supported methods: Do not copy a different gateway’s type aliases or channel IDs. Availability also depends on your KyrenPay provider binding. If your installed version lacks the custom-method editor, verify or upgrade that version before exposing these methods. Custom-method editor and serialization.

Set the amount and credited balance

This EasyPay client does not send money_type, so KyrenPay interprets money as CNY. Changing a currency label or product-name suffix does not change the request currency. For balance top-ups, sub2api credits recharge amount × balance recharge multiplier, rounded to two decimals. Its separate recharge surcharge increases the Epay request amount, with the surcharge rounded up to cents. For an initial check, set payment_balance_recharge_multiplier = 1 and payment_recharge_fee_rate = 0: a recharge amount of 10.00 sends an Epay base amount of CNY 10.00 and credits 10.00 balance units. Choose your intended conversion policy before enabling public recharge; a USD balance display does not perform exchange conversion automatically. Order calculation, balance multiplier, surcharge rounding. The Epay base amount is not always the final checkout total. KyrenPay may add a customer-paid fee according to your payment channel’s fee-sharing settings. The example total is exactly CNY 10.00 only when no KyrenPay customer-paid fee applies. Epay notification and order-query money report the base amount; sub2api credits its stored balance amount, rather than any additional fee. Compare the base amount, displayed checkout total and expected credited balance separately.

Verify payment and crediting

  1. Save the settings, sign in as a test user and create a small top-up. Record the merchant order number (out_trade_no), Epay base amount, displayed CNY checkout total and starting balance.
  2. Complete payment and confirm that the corresponding KyrenPay order is paid. Check the sub2api payment order and confirm the intended balance increase.
  3. Confirm that the backend received the signed GET notification at /api/v1/payment/webhook/easypay, verified the Epay MD5 signature and TRADE_SUCCESS, and returned the plain text success.
  4. Confirm a repeated notification for the same order does not add balance again. A return-page visit or HTTP success response alone is insufficient evidence of crediting; check the order and balance records together.
The built-in handler accepts GET notifications and performs verification through the provider. Its acknowledgement can also cover an unknown order, so inspect backend logs if KyrenPay is paid but balance has not increased. Callback routes, callback handler. See Epay MD5 signatures and Paid but not credited.

Common configuration problems

Acceptance limits in the documented version

Local tests using the pinned commit’s real provider, Webhook handler, payment service and PostgreSQL repository found an amount tolerance: a correctly signed money = 9.99 was accepted for an expected 10.00 order and credited the stored 10.00 balance amount; a large amount mismatch was rejected without crediting. The implemented tolerance is 0.01, not exact decimal equality. Concurrent deliveries can return a retryable conflict rather than all returning success. Check that failed attempts are retried and the final order and balance show one fulfillment. These results do not establish a live payment test or an exact-match amount policy on your deployment.
  • Wrong endpoint: preserve /epay/ in the API base. Do not enter the merchant dashboard URL or a complete submit.php URL.
  • Server-side creation denied: if KyrenPay’s API IP allowlist is enabled, allow the sub2api server’s outbound IP for mapi.php. Browser submit.php checkout does not require adding each customer’s IP.
  • Notification missing: make the HTTPS callback publicly reachable, preserve GET query parameters and route it to the backend without login redirects or browser challenges.
  • Signature failure after key rotation: regenerating the KyrenPay API key invalidates the old secret. Update the provider’s PKey immediately and verify a new payment and any pending callbacks. Never publish the key in a support ticket.
These instructions were checked against source code; they do not represent a live payment test on your deployment.