Every example keeps the merchant API key on the server. Replace the example origin with the environment selected in Environments.

Server authentication

Create checkout

Subscription checkout

Webhook verification

Verify the raw body before parsing it. The exact signing helper belongs in your server application; never verify a re-serialized JSON object.
Store the event ID before applying a state transition. Return a 2xx response only after the event has passed authentication and schema checks.

Refund

WooCommerce correlation

Pass the WooCommerce order ID as the merchant API orderId and in metadata. Persist the returned payment or checkout-session ID in order metadata. Mark the order paid only after the signed event matches the order ID, amount, currency, and merchant account.