PHP code example of makepay / makepay-php

1. Go to this page and download the library: Download makepay/makepay-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

makepay / makepay-php example snippets


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' => '[email protected]',
    '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']);

$makepay->listPaymentLinks();
$makepay->getPaymentLink('PAYMENT_LINK_UID');
$makepay->updatePaymentLink('PAYMENT_LINK_UID', ['status' => 'paused']);
$makepay->sendPaymentRequestEmail('PAYMENT_LINK_UID', '[email protected]');

$donation = $makepay->createDonationLink([
    'title' => 'Spring campaign',
    'description' => 'Support the 2026 spring fundraiser.',
    'defaultAmountUsd' => '25',
    'minimumAmountUsd' => '5',
    'donationSlug' => 'spring-campaign',
]);

$makepay->listDonationLinks();
$makepay->getDonationLink('DONATION_UID');
$makepay->updateDonationLink('DONATION_UID', ['status' => 'paused']);

$response = Client::createAnonymousPaymentLink([
    'amount' => '25',
    'settlement' => [
        'currency' => 'USDT',
        'priorities' => [
            [
                'chain' => 'ETH',
                'address' => '0xYourSettlementWallet',
                'asset' => 'ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7',
            ],
        ],
    ],
    'title' => 'Invoice #1042',
    'customerEmail' => '[email protected]',
    'webhookUrl' => 'https://merchant.example/webhooks/makepay',
]);

$paymentUid = $response['paymentLink']['uid'];

$hostedUrl = $makepay->hostedCheckoutUrl($paymentUid);
$embedUrl = $makepay->embeddedCheckoutUrl($paymentUid, [
    'parentOrigin' => 'https://merchant.example',
]);

echo $makepay->embedButtonHtml($paymentUid, [
    'buttonLabel' => 'Pay with crypto',
]);

echo $makepay->iframeHtml($paymentUid, [
    'iframeTitle' => 'Secure MakePay checkout',
]);

$makepay->hostedDonationUrl('spring-campaign');
$makepay->embeddedDonationUrl('spring-campaign', [
    'parentOrigin' => 'https://merchant.example',
]);

$makepay->upsertCustomer([
    'email' => '[email protected]',
    'name' => 'Buyer Example',
    'clientId' => 'crm_123',
    'metadata' => ['plan' => 'pro'],
]);

$makepay->listCustomers();

$makepay->createCustomerPortal('CUSTOMER_ID', [
    'returnUrl' => 'https://merchant.example/account',
]);

$makepay->createSubscription([
    'amountUsd' => '29',
    'customerEmail' => '[email protected]',
    'label' => 'Monthly plan',
    'billingIntervalUnit' => 'month',
    'billingIntervalCount' => 1,
    'sendPaymentRequestEmail' => true,
]);

$makepay->listSubscriptions();

$terminal = $makepay->createPosTerminal([
    'name' => 'Front counter',
    'pin' => '1234',
    'allowedAssets' => ['ETH.USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7'],
    'emailCollectionMode' => 'optional_after_deposit',
    'catalogEnabled' => true,
]);

$makepay->listPosTerminals();
$makepay->updatePosTerminal('POS_UID', ['name' => 'Front counter', 'pin' => '5678']);

$makepay->createProduct([
    'name' => 'Digital guide',
    'productType' => 'digital',
    'basePriceUsd' => '19',
    'shopSlug' => 'digital-guide',
    'images' => [
        ['url' => 'https://merchant.example/guide.png', 'alt' => 'Guide cover'],
    ],
]);

$makepay->createProductDownload('PRODUCT_UID', [
    'fileName' => 'guide.pdf',
    'contentType' => 'application/pdf',
    'url' => 'https://merchant.example/downloads/guide.pdf',
]);

$makepay->updateShop([
    'slug' => 'merchant-shop',
    'displayCurrency' => 'USD',
    'checkoutMode' => 'hosted',
    'branding' => ['accentColor' => '#14b8a6'],
]);

$makepay->updateShopDomain('shop.merchant.example');
$makepay->refreshShopDomain();
$makepay->createShopCoupon([
    'code' => 'SPRING10',
    'discountType' => 'percent',
    'value' => '10',
]);
$makepay->listShopOrders(['status' => 'paid', 'limit' => 25]);

$makepay->createBookkeepingInvoice([
    'title' => 'Invoice #1042',
    'currency' => 'USD',
    'issueDate' => '2026-05-15',
    'dueDate' => '2026-05-30',
    'counterparty' => [
        'name' => 'Buyer Example',
        'email' => '[email protected]',
        'clientId' => 'crm_123',
    ],
    'lineItems' => [
        [
            'description' => 'Implementation services',
            'quantity' => '1',
            'unitAmount' => '500',
            'taxAmount' => '0',
        ],
    ],
]);

$makepay->createBookkeepingInvoicePaymentLink('INVOICE_UID', [
    'sendPaymentRequestEmail' => true,
]);

$makepay->listBookkeepingInvoices();
$makepay->getBookkeepingInvoice('INVOICE_UID');
$makepay->updateBookkeepingInvoice('INVOICE_UID', ['status' => 'open']);

$makepay->createBookkeepingExpense([
    'title' => 'Hosting',
    'amount' => '49',
    'currency' => 'USD',
    'incurredOn' => '2026-05-15',
    'category' => 'Infrastructure',
    'counterparty' => ['name' => 'Vendor Example', 'type' => 'vendor'],
]);

$makepay->createBookkeepingExpenseFromActivity([
    'walletActivityEventKey' => 'CHAIN_EVENT_KEY',
    'category' => 'Settlement',
]);

$makepay->createBookkeepingReconciliation([
    'invoiceId' => 'INVOICE_UID',
    'paymentSessionId' => 'PAYMENT_SESSION_ID',
    'linkType' => 'payment',
]);

$makepay->uploadBookkeepingDocument([
    'file' => __DIR__ . '/receipt.pdf',
    'fileName' => 'receipt.pdf',
    'contentType' => 'application/pdf',
    'documentType' => 'receipt',
    'expenseId' => 'EXPENSE_UID',
]);

$makepay->listBookkeepingDocuments();
$makepay->getBookkeepingDocumentDownloadUrl('DOCUMENT_UID');
$makepay->runBookkeepingDocumentOcr('DOCUMENT_UID');
$makepay->getBookkeepingSummary();

$makepay->updateBranding([
    'brandName' => 'Merchant',
    'supportEmail' => '[email protected]',
    'brandingBrandColor' => '#111827',
    'brandingAccentColor' => '#14b8a6',
    'paymentLinkTheme' => 'system',
    'paymentLinkDomain' => 'pay.merchant.example',
    'emailSendingDomain' => 'mail.merchant.example',
]);

$makepay->getBranding();
$makepay->refreshBrandingDomains('all');

$makepay->getSettings();
$makepay->updateSettings([
    'callbackUrl' => 'https://merchant.example/webhooks/makepay',
]);
$makepay->listDestinationAssets();
$makepay->listWebhookRequests(['limit' => 25]);

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';

use MakePay\MakePayException;

try {
    $makepay->getPaymentLink('PAYMENT_LINK_UID');
} catch (MakePayException $error) {
    error_log($error->getMessage());
    error_log((string) $error->getStatusCode());
}
bash
composer