Official PHP SDK for MakePay server-side payment links, MakePay settings, and webhook verification.
Until the package is published to Packagist, install from the public Git repository:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/CHASH-HOSTING/makepay-php-sdk"
}
],
"require": {
"makepay/makepay-php": "^0.1"
}
}Then run:
composer update makepay/makepay-phpCreate a MakePay API key in MakeCrypto and keep the secret on your server only.
use MakePay\Client;
$makepay = new Client([
'keyId' => getenv('MAKEPAY_KEY_ID'),
'keySecret' => getenv('MAKEPAY_KEY_SECRET'),
]);$response = $makepay->createPaymentLink([
'title' => 'Order #1042',
'description' => 'Checkout for order #1042',
'amount' => '129.99',
'currency' => 'USDT',
'orderId' => 'order_1042',
'customerEmail' => 'buyer@example.com',
'returnUrl' => 'https://merchant.example/orders/1042',
'successUrl' => 'https://merchant.example/orders/1042/success',
'failureUrl' => 'https://merchant.example/orders/1042/pay',
'expirationTime' => '12h',
]);
header('Location: ' . $response['paymentLink']['publicUrl']);$links = $makepay->listPaymentLinks();
$detail = $makepay->getPaymentLink('PAYMENT_LINK_UID');
$makepay->updatePaymentLink('PAYMENT_LINK_UID', ['status' => 'paused']);
$makepay->sendPaymentRequestEmail('PAYMENT_LINK_UID', 'buyer@example.com');Read the raw request body before JSON parsing.
use MakePay\Webhook;
$rawBody = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_MAKEPAY_SIGNATURE'] ?? null;
$event = Webhook::parse($rawBody, $signature, getenv('MAKEPAY_WEBHOOK_SECRET'));
if (($event['event']['type'] ?? '') === 'status_changed') {
// Update your local order status.
}
http_response_code(200);
echo 'ok';- Create, list, read, update, and email MakePay payment links
- Read and update MakePay settings
- Verify and parse signed MakePay webhooks
- Throws
MakePay\MakePayExceptionwith HTTP status and response body on API errors