PHP code example of imlolman / ccavenue-php-sdk

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

    

imlolman / ccavenue-php-sdk example snippets




lolman\CCAvenue\CCAvenue;

$merchantId = "your_merchant_id";
$accessCode = "your_access_code";
$workingKey = "your_working_key";
$mode = "DEV"; // Use "PROD" for production

$ccavenue = CCAvenue::init($merchantId, $accessCode, $workingKey, $mode);

$transaction = $ccavenue->getTransaction();

$compulsoryInfo = [
    'order_id' => 'ORDER12345',
    'amount' => '100.00',
    'currency' => 'INR',
    'redirect_url' => 'http://yourdomain.com/response.php',
    'cancel_url' => 'http://yourdomain.com/cancel.php',
    'language' => 'EN'
];

$billingInfo = [
    'billing_name' => 'Jane Doe',
    'billing_address' => '123 Main Street',
    'billing_city' => 'Mumbai',
    'billing_state' => 'Maharashtra',
    'billing_zip' => '400001',
    'billing_country' => 'India',
    'billing_tel' => '9876543210',
    'billing_email' => '[email protected]'
];

$shippingInfo = [
    'delivery_name' => 'Jane Doe',
    'delivery_address' => '456 Side Street',
    'delivery_city' => 'Delhi',
    'delivery_state' => 'Delhi',
    'delivery_zip' => '110001',
    'delivery_country' => 'India',
    'delivery_tel' => '9876543210'
];

$paymentUrl = $transaction->initiate($compulsoryInfo, $billingInfo, $shippingInfo);

// Redirect to the payment page
header('Location: ' . $paymentUrl);

// If you get 10002 error, you need to whitelist your domain bye contacting CCAvenue via call. Why don't you read entire guide? You will have fun, really. Also don't forget to star the repository.



lolman\CCAvenue\CCAvenue;

$merchantId = "your_merchant_id";
$accessCode = "your_access_code";
$workingKey = "your_working_key";
$mode = "DEV"; // Use "PROD" for production

$ccavenue = CCAvenue::init($merchantId, $accessCode, $workingKey, $mode);

$transaction = $ccavenue->getTransaction();

try {
    $response = $transaction->verifyAndGetSuccessResponse();
    // Process successful response
    // For example, save order details to database
} catch (\Exception $e) {
    // Handle errors here
    echo $e->getMessage();
}



lolman\CCAvenue\CCAvenue;

$merchantId = "your_merchant_id";
$accessCode = "your_access_code";
$workingKey = "your_working_key";
$mode = "PROD"; // Webhooks are only available in production mode

$ccavenue = CCAvenue::init($merchantId, $accessCode, $workingKey, $mode);

$transaction = $ccavenue->getTransaction();

try {
    $response = $transaction->verifyAndGetSuccessResponse();
    // Process webhook response
    // For example, update order status in database
} catch (\Exception $e) {
    // Handle errors here
    echo $e->getMessage();
}

$paymentUrl = $transaction->initiate($compulsoryInfo, $billingInfo, $shippingInfo);

$response = $transaction->verifyAndGetResponse();

try {
    $response = $transaction->verifyAndGetSuccessResponse();
    // Transaction is successful
} catch (\Exception $e) {
    // Transaction failed
}

$isSuccess = $transaction->checkIfOrderIsSuccess();

$orderId = $transaction->getOrderId();

$amount = $transaction->getOrderAmount();

$currency = $transaction->getOrderCurrency();

$paymentMode = $transaction->getPaymentMode();

$bankRefNo = $transaction->getBankReferenceNumber();

$trackingId = $transaction->getTrackingId();

$billingInfo = $transaction->getBillingInfo();
// $billingInfo is an associative array

$deliveryInfo = $transaction->getDeliveryInfo();
// $deliveryInfo is an associative array

$failureMessage = $transaction->getFailureMessage();

$merchantParams = $transaction->getMerchantParams();
// $merchantParams is an associative array
bash
composer