From woocommerce-commerce
Build WooCommerce payment gateways extending WC_Payment_Gateway for direct/redirect/hosted integrations, tokenization, subscriptions, refunds, and PCI compliance.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin woocommerce-commerceThis skill is limited to using the following tools:
**Fetch live docs**:
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
Fetch live docs:
site:developer.woocommerce.com payment gateway api for payment gateway guidewoocommerce payment gateway tutorial for implementation patternshttps://woocommerce.github.io/code-reference/classes/WC-Payment-Gateway.html for class referenceAll gateways extend WC_Payment_Gateway (which extends WC_Settings_API):
| Property | Description |
|---|---|
$id | Unique gateway identifier |
$method_title | Admin-facing title |
$method_description | Admin-facing description |
$title | Customer-facing title |
$description | Customer-facing description |
$icon | URL to gateway icon |
$has_fields | Whether gateway has payment fields on checkout |
$supports | Array of supported features |
Filter woocommerce_payment_gateways:
add_filter( 'woocommerce_payment_gateways', function( $gateways ) {
$gateways[] = 'My_Payment_Gateway';
return $gateways;
});
__construct() — set $id, $method_title, $supports, call init_form_fields(), init_settings(), load saved settings, register process_admin_options hookinit_form_fields() — define admin settings (API keys, sandbox mode, etc.)process_payment( $order_id ) — core payment logic, returns result + redirect arraypayment_fields() — render custom payment form HTML on checkoutvalidate_fields() — validate payment form inputprocess_refund( $order_id, $amount, $reason ) — handle refundsget_icon() — customize the gateway icon displayreturn [
'result' => 'success', // or 'failure'
'redirect' => $order->get_checkout_order_received_url(),
];
Gateway processes payment inline:
payment_fields() (or tokenized via JS SDK)process_payment()$order->payment_complete( $transaction_id )Customer redirected to external payment page:
process_payment() returns redirect URL to processorPayment form loaded in iframe on checkout page:
$has_fields = truepayment_fields()$this->supports = [
'products', // Basic payment support
'refunds', // process_refund()
'tokenization', // Saved payment methods
'subscriptions', // WooCommerce Subscriptions
'subscription_cancellation',
'subscription_reactivation',
'subscription_suspension',
'subscription_amount_changes',
'subscription_date_changes',
];
WC_Payment_Token_CC (credit cards) or WC_Payment_Token (generic)$this->supports[] = 'tokenization'tokenization_script() to enqueue JSWC_Payment_Tokens::set_users_default()Use WC_API to register callback URLs:
add_action( 'woocommerce_api_{$id}', [ $this, 'handle_webhook' ] )home_url( '/wc-api/{$id}/' )$order->update_status( 'processing', 'Payment received' ) — status + note$order->payment_complete( $transaction_id ) — marks paid, triggers emails$order->update_status( 'failed', 'Payment failed' ) — mark failed$order->add_order_note( 'Note text' ) — add admin/customer noteFor block-based checkout, gateways need a JS integration:
@woocommerce/blocks-registry → registerPaymentMethod()content, edit, labelcanMakePayment callbackonPaymentSetup eventcart_checkout_blocks compatibility and provide block checkout integration$order->payment_complete() — it handles status, stock reduction, and email triggers$order->set_transaction_id()Fetch the WooCommerce payment gateway documentation and code reference for exact method signatures, supported features, and block checkout integration patterns before implementing.