1. Go to this page and download the library: Download smatpay/smatpay-php-sdk 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/ */
smatpay / smatpay-php-sdk example snippets
use Smatpay\Http\Smatpay;
use Smatpay\Constants\WalletName;
use Smatpay\Definitions\PaymentPayloadBuilder;
$payload = (new PaymentPayloadBuilder())
->setMerchantId('your-merchant-id')
->setMerchantKey('your-merchant-key')
->setMerchantApiKey('your-api-key')
->setPayerName('John Doe')
->setPayerMobile('0771234567')
->setPayerReference('ORDER-001')
->setPayerAccountId('ACC-001')
->setPaymentDescription('Order payment')
->setPaymentCurrency('USD')
->setAmount('10.00')
->setProfileId('your-profile-id');
$gateway = Smatpay::getInstance(WalletName::ECOCASH);
// Use second argument true for sandbox, false (default) for production
$response = $gateway->pay($payload, true);
print_r($response);
use Smatpay\Http\Smatpay;
use Smatpay\Constants\WalletName;
use Smatpay\Definitions\PaymentEnquireBuilder;
$enquiry = (new PaymentEnquireBuilder())
->setMerchantId('your-merchant-id')
->setMerchantKey('your-merchant-key')
->setMerchantApiKey('your-api-key')
->setTransactionReference('TXN-REF-001')
->setPaymentMobile('0771234567'); //
use Smatpay\Http\Smatpay;
use Smatpay\Constants\WalletName;
use Smatpay\Definitions\BulkPaymentBuilder;
$bulk = (new BulkPaymentBuilder())
->setMerchantId('your-merchant-id')
->setMerchantKey('your-merchant-key')
->setMerchantApiKey('your-api-key')
->setPayerName('John Doe')
->setPayerMobile('0771234567')
->setPayerReference('ORDER-002')
->setPayerAccountId('ACC-001')
->setPaymentDescription('Split payment')
->setPaymentCurrency('USD')
->setAmount('100.00')
->setProfileId('your-profile-id')
->setDynamicPaidList('merchant-b-id', 30) // 30% to merchant B
->setDynamicPaidList('merchant-c-id', 70); // 70% to merchant C
$gateway = Smatpay::getInstance(WalletName::ECOCASH);
$response = $gateway->bulk($bulk, true);
print_r($response);
use Smatpay\Gateway\FastCheckOut;
use Smatpay\Definitions\AuthenticationBuilder;
use Smatpay\Definitions\FastCheckoutBuilder;
$auth = (new AuthenticationBuilder())
->setMerchantId('your-merchant-id')
->setMerchantKey('your-merchant-key')
->setMerchantApiKey('your-api-key');
$checkout = (new FastCheckoutBuilder())
->setPaymentLinkName('My Store Checkout')
->setPaymentLinkDescription('Payment for Order #123')
->setPaymentLinkReference('ORDER-123')
->setPaymentLinkAmount('25.00')
->setPaymentLinkCurrency('USD')
->setPaymentLinkCurrencyId('1')
->setPaymentLinkType('ONCE_OFF_FIXED')
->setPaymentLinkProfileId('your-profile-id')
->setPaymentLinkStartDate('2026-01-01')
->setPaymentLinkEndDate('2026-12-31')
->setPaymentLinkCustomerRedirectUrl('https://yoursite.com/success')
->setPaymentCustomerFailRedirectUrl('https://yoursite.com/failed')
->setPaymentPayerFullNames('John Doe')
->setPaymentPayerEmailAddress('[email protected]')
->setPaymentPayerMobile('0771234567');
$response = (new FastCheckOut())->checkout($checkout, $auth, true);
print_r($response);
use Smatpay\Gateway\Currency;
$currencies = (new Currency())->all();
print_r($currencies);
$gateway->pay($payload, true); // sandbox
$gateway->pay($payload, false); // production (default)
use Smatpay\Exceptions\PaymentProcessingFailed;
use Smatpay\Exceptions\TokenGenerationFailed;
use Smatpay\Exceptions\EnquireFailed;
use Smatpay\Exceptions\PaymentGatewayNotFound;
try {
$response = $gateway->pay($payload, true);
} catch (TokenGenerationFailed $e) {
// Handle auth failure
} catch (PaymentProcessingFailed $e) {
// Handle payment failure
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.