PHP code example of tzsmm / tzsmmpay

1. Go to this page and download the library: Download tzsmm/tzsmmpay 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/ */

    

tzsmm / tzsmmpay example snippets


use Tzsmmpay\TzsmmpayClient;
use Tzsmmpay\TzsmmpayResponse;

$apiKey = 'xOevYGbzFmJCm1rkzDrf';  // Your API key

$tzsmm = new TzsmmpayClient($apiKey);

$paymentData = [
    'cus_name' => 'Demo User',
    'cus_email' => '[email protected]',
    'cus_number' => '01700000000',
    'amount' => 1,
    'success_url' => 'https://domain.com/success-url',
    'cancel_url' => 'https://domain.com/cancel-url/dashboard',
    'callback_url' => 'https://domain.com/callback-url',
];

$response = $tzsmm->createPayment($paymentData);

if ($response->isSuccess()) {
    echo "Payment created successfully!";
    echo "Transaction ID: " . $response->getData()['transaction_id'];
    echo "Payment URL: " . $response->getData()['payment_url'];
} else {
    echo "Error: " . $response->getMessage();
}

$transactionId = 'trx_123456';  // Replace with actual transaction ID

$response = $tzsmm->verifyPayment($transactionId);

if ($response->isSuccess()) {
    if ($response->getData()['status'] == 'Completed') {
        echo "Payment verified successfully!";
    } else {
        echo 'Your Payment is ' . $response->getData()['status'];
    }
} else {
    echo "Verification failed: " . $response->getMessage();
}

if (!$response->isSuccess()) {
    echo "Error: " . $response->getMessage();
}