PHP code example of contipay / php-sdk

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

    

contipay / php-sdk example snippets




use ContiPay\PhpSdk\Card;
use ContiPay\PhpSdk\Mobile;

 'your_api_secret');

 // update Contipay URL (optional)
$contipay->updateContipayURL('new-dev-url', 'new-live-url');

// Process a payment
$response = $contipay->mobile([
    'amount' => '50.00',
    'currency' => 'ZWG',
    'phone' => '0782000340',
    'reference' => uniqid('PAY-'),
    'provider' => 'EcoCash',
    'code' => 'EC'
]);

OR

// Initialize the SDK
$contipay = new Card('your_api_key', 'your_api_secret');

// Process a payment
$response = $contipay->card([
    'accountNumber' => '4111111111111111',
    'accountExpiry' => '12/26',
    'cvv' => '123',
    'phone' => '0782000340',
    'amount' => '50.00',
    'currency' => 'USD',
    'reference' => uniqid('CARD-'),
    'provider' => 'Visa',
    'code' => 'VA'
]);



use ContiPay\PhpSdk\Mobile;
use ContiPay\PhpSdk\Card;

 $mode, $method);

// Card payments
$card = new Card($apiKey, $apiSecret, $mode, $method);



use ContiPay\PhpSdk\Mobile;

ey', 'your_api_secret');

// Configure merchant details
$contipay->setMerchantId(12345);
$contipay->setWebhookUrl('https://your-domain.com/webhook');

try {
    $response = $contipay->ecocash([
        'amount' => '50.00',
        'currency' => 'USD',
        'phone' => '0782000340',
        'reference' => uniqid('ECO-'),
    ]);
    
    $result = json_decode($response, true);
    // Handle success
} catch (\Throwable $e) {
    // Handle error
}



use ContiPay\PhpSdk\Mobile;

ey', 'your_api_secret');

// Configure merchant details
$contipay->setMerchantId(12345);
$contipay->setWebhookUrl('https://your-domain.com/webhook');

// Required for redirect flow
$contipay->setSuccessUrl('https://your-domain.com/success');
$contipay->setErrorUrl('https://your-domain.com/error');

try {
  $response = $contipay->mobile([
        'amount' => '50.00',
        'currency' => 'USD',
        'phone' => '0782000340',
        'reference' => uniqid('PAY-'),
        'provider' => 'EcoCash',
        'code' => 'EC'
    ]);

    $result = json_decode($response, true);
    // Handle success
} catch (\Throwable $e) {
    // Handle error
}



use ContiPay\PhpSdk\Card;

ey', 'your_api_secret', 'live', 'redirect');

// Configure merchant details
$contipay->setMerchantId(12345);
$contipay->setWebhookUrl('https://your-domain.com/webhook');

// Required for redirect flow
$contipay->setSuccessUrl('https://your-domain.com/success');
$contipay->setErrorUrl('https://your-domain.com/error');

try {
    $response = $contipay->visa([
        'firstName' => 'John',
        'lastName' => 'Doe',
        'accountNumber' => '4111111111111111',
        'accountExpiry' => '12/26',
        'cvv' => '123',
        'phone' => '0782000340',
        'email' => '[email protected]',
        'amount' => '50.00',
        'currency' => 'USD',
        'country' => 'ZW',
        'reference' => uniqid('CARD-'),
        'description' => 'Premium Subscription'
    ]);
    
    $result = json_decode($response, true);
    // Handle success
} catch (\Throwable $e) {
    // Handle error
}



use ContiPay\PhpSdk\Card;

ey', 'your_api_secret', 'dev', 'redirect');

// Configure merchant details
$contipay->setMerchantId(12345);
$contipay->setWebhookUrl('https://your-domain.com/webhook');

// Required for redirect flow
$contipay->setSuccessUrl('https://your-domain.com/success');
$contipay->setErrorUrl('https://your-domain.com/error');

try {
  $response = $contipay->card([
        'accountNumber' => '4111111111111111',
        'accountExpiry' => '12/26',
        'cvv' => '123',
        'phone' => '0782000340',
        'amount' => '50.00',
        'currency' => 'USD',
        'reference' => uniqid('CARD-'),
        'provider' => 'Visa',
        'code' => 'VA'
    ]);

    $result = json_decode($response, true);
    // Handle success
} catch (\Throwable $e) {
    // Handle error
}
bash
composer