PHP code example of vicomm / sdk

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

    

vicomm / sdk example snippets




icomm\Vicomm;

// First setup your credentials provided by vicomm
$applicationCode = "SOME_APP_CODE";
$applicationKey = "SOME_APP_KEY";

Vicomm::init($applicationCode, $applicationKey);



use Vicomm\Vicomm;
use Vicomm\Exceptions\VicommErrorException;

Vicomm::init($applicationCode, $aplicationKey);

$card = Vicomm::card();

// Success response
$userId = "1";
$listOfUserCards = $card->getList($userId);

$totalSizeOfCardList = $listOfUserCards->result_size;
$listCards = $listOfUserCards->cards;

// Get all data of response
$response = $listOfUserCards->getData();

// Catch fail response
try {
	$listOfUserCards = $card->getList("someUID");
} catch (VicommErrorException $error) {
	// Details of exception
	echo $error->getMessage();
	// You can see the logs for complete information
}



use Vicomm\Vicomm;
use Vicomm\Exceptions\VicommErrorException;

// Card token
$cardToken = "myAwesomeTokenCard";

$charge = Vicomm::charge();

$userDetails = [
    'id' => "1", // Field => "XXXXXX", // Field 
    // Access to HTTP code from vicomm service
    $code = $error->getCode();
    $message = $error->getMessage();
}

// Get transaction status
$status = $created->transaction->status;
// Get transaction ID
$transactionId = $created->transaction->id;
// Get authorization code
$authCode = $created->transaction->authorization_code;



use Vicomm\Vicomm;
use Vicomm\Exceptions\VicommErrorException;

// Card token
$cardToken = "myAwesomeTokenCard";

$charge = Vicomm::charge();

$userDetails = [
    'id' => "1", // Field => "XXXXXX", // Field formation
    // Access to HTTP code from vicomm service
    $code = $error->getCode();
    $message = $error->getMessage();
}

// Get transaction status
$status = $authorization->transaction->status;
// Get transaction ID
$transactionId = $authorization->transaction->id;
// Get authorization code
$authCode = $authorization->transaction->authorization_code;



use Vicomm\Vicomm;
use Vicomm\Exceptions\VicommErrorException;

$charge = Vicomm::charge();

$authorization = $charge->authorize($cardToken, $orderDetails, $userDetails);
$transactionId = $authorization->transaction->id;

try {
    $capture = $charge->capture($transactionId);
} catch (VicommErrorException $error) {
    // See the console output for complete information
    // Access to HTTP code from vicomm service
    $code = $error->getCode();
    $message = $error->getMessage();
}

// Get transaction status
$status = $capture->transaction->status;

// Make a capture with different amount
$newAmountForCapture = 1000.46;
$capture = $charge->capture($transactionId, $newAmountForCapture);



use Vicomm\Vicomm;
use Vicomm\Exceptions\vicommErrorException;

$charge = Vicomm::charge();

$created = $charge->create($cardToken, $orderDetails, $userDetails);
$transactionId = $created->transaction->id;

try {
    $refund = $charge->refund($transactionId);
} catch (VicommErrorException $error) {
    // See the console output for complete information
    // Access to HTTP code from vicomm service
    $code = $error->getCode();
    $message = $error->getMessage();
}

// Get status of refund
$status = $refund->status;
$detail = $refund->detail;

// Make a partial refund
$partialAmountToRefund = 10;
$refund = $charge->refund($transactionId, $partialAmountToRefund);



use Vicomm\Vicomm;
use Vicomm\Exceptions\VicommErrorException;

$cash = Vicomm::cash();

$carrierDetails = [
    'id' => 'oxxo', // Field           'last_name' => "Perez"
        ]
    ]
];

$userDetails = [
   'id' => "1", // Field ield     // Access to HTTP code from vicomm service
    $code = $error->getCode();
    $message = $error->getMessage();
}

// Get reference code
$referenceCode = $order->transaction->reference;
// Get expiration date
$expirationData = $order->transaction->expiration_date;
// Get order status
$status = $order->transaction->status;