The SDK is for server-side PHP applications. Never expose your merchant API key in browser code or commit it to your repository.
Requirements
- PHP 8.3 or later
- PHP
curlextension - PHP
jsonextension
Install
Install the package with Composer:Configure the client
Create an API key from the API Information page, then pass the merchant bearer token to the client:base_uri should point to your BillingServ installation and end in /api/v2, for example:
base_uri, the SDK uses the public demo API URL. Set it explicitly for production and for self-hosted BillingServ installations. The timeout option is in seconds and defaults to 30.
Store configuration in environment variables or another secret store. For example:
Make API calls
Resource clients are exposed as properties on theBillingServ instance. For example, list customers and create a customer with an idempotency key:
Available resources
Each SDK method maps to a documented v2 API endpoint. Use the API reference to check required fields, permissions, and response details.
Hosted checkout and domains
Create a hosted checkout URL, then redirect the customer to the returned URL:Handle errors
Successful responses are returned as plain PHP arrays. API and network failures throw exceptions:ApiException exposes getStatus(), getErrors(), getErrorCode(), getRequestId(), and getResponse(). Record the request ID with your application logs when reporting an API failure.
Verify webhooks
When webhook signing is enabled, verify the raw request body before parsing it. The SDK checks theBillingServ-Signature header and rejects stale or invalid signatures: