Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 2.15 KB

File metadata and controls

60 lines (40 loc) · 2.15 KB

CPPay WordPress Plugin

Create and query crypto payments in WordPress via the CPPay API without exposing your API key on the frontend.

中文文档

Installation

Reference: https://www.cppay.finance/docs/zh/guide/wordpress-plugin.html

Features

  • Configure API key from the WooCommerce payment settings via the Manage button
  • Register a WooCommerce payment gateway so CPPay appears at checkout
  • Create OTT after order placement and redirect to the hosted page: https://www.cppay.finance/payment/{ott}
  • Provide a WooCommerce webhook callback endpoint and automatically update order status after payment
  • Support shortcode-based payment component insertion
  • Support one-time payment "instant" and subscription payment "subscription"

WooCommerce Checkout Flow

After enabling the gateway, CPPay appears as a payment method at checkout.

Settings page URL examples:

  • wp-admin/admin.php?page=wc-settings&tab=checkout (legacy)
  • wp-admin/admin.php?page=wc-settings&tab=checkout&section=cppay_gateway (gateway manage page)
  • wp-admin/admin.php?page=wc-settings&tab=payments (new UI)

Checkout behavior:

  • Customer selects CPPay
  • Plugin calls POST /api/payment/ott/create with Authorization: ApiKey {api_key}
  • Customer is redirected to https://www.cppay.finance/payment/{ott}
  • Thank You page keeps the OTT link as fallback
  • On webhook callback, the plugin verifies payment status and updates WooCommerce order to completed or failed

Shortcode

[cppay_payment plain="instant" amount="10" order_prefix="blog" title="Pay with Crypto"]

Subscription example:

[cppay_payment plain="subscription" amount="9.99" interval_days="30" order_prefix="sub"]

API Alignment with cppay-sdk

The plugin PHP client aligns with interfaces in cppay-sdk/src/assets/request.ts:

  • GET /api/payment/token
  • POST /api/payment/create
  • GET /api/payment/query
  • POST /api/subscription/create
  • GET /api/subscription/query

It also maps response fields to SDK-style names such as paymentId, subscriptionId, paymentAmount, expireAt, and status.