The official PkPayPlus PHP SDK lets you use the Merchant API from plain PHP or Laravel. You can manage products, create and verify checkout sessions, and authenticate with your Merchant Secret Key.
This SDK is for server-side (merchant backend) use only. Never expose your secret key in frontend code.
Requirements
Installation
Install the SDK with Composer:
Configuration
The SDK loads configuration in this order:
- Config array passed to
Client
- Environment variables
- Default base URL
Environment variables (recommended)
Create a .env file in your project root:
Do not commit .env to version control.
Passing config manually
You can pass options when creating the client:
Quick start (plain PHP)
Authentication
All Merchant API requests use:
The SDK sets this header automatically when you use your secret key.
Products API
The merchant is inferred from your secret key. The SDK uses these endpoints:
List products
Create product
Get product
Update product
Delete product
Checkout sessions (Merchant API)
Use checkout sessions for backend-driven flows (e.g. WooCommerce-style plugins).
Endpoints:
POST /merchant-api/{merchant_id}/checkout-sessions — create session
GET /merchant-api/{merchant_id}/{session_id} — get/verify session
Create checkout session
Verify checkout session
Laravel usage
.env
Add to your .env:
config/services.php
Register the PkPayPlus config:
Example usage
Testing
The SDK ships with:
- Unit tests — mocked HTTP
- Integration tests — real API (opt-in)
Run unit tests
Integration tests (real API)
Integration tests are skipped unless you enable them.
Add to .env:
Then run:
Common errors
Missing secret key
Ensure your environment has:
Security notes
- Never expose your secret key in frontend or client-side code.
- Use the publishable key for client-side checkout.
- Use the secret key only on the backend.
Resources