Velocity PHP SDK
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sdk
README.md
index.php
velocityClients.php

README.md

Velocity PHP SDK Documentation

Installation

Download ZIP and unzip to a web server. The SDK alone can be found in the actual SDK folder. The index.php file is an example payments form utilizing Velocity's transparent redirect. The transparent redirect does a Verify (zero-dollar authorization) in order to tokenize the cardholder data. This reduces the PCI-scope of the payments form by sending the payment data directly from the client's browser (via javascript) to the Velocity server. It then redirects the payment form to the velocityClients.php page which utilizes the card data token to perform further payment operations exposed by the SDK.

Dependencies

Credentials for the velocity platform are required for configuration (IdentityToken, WorkflowId, ApplicationProfileId, & MerchantProfileId). You should obtain these from your solutions consultant.

Tutorial

1. Include PHP sdk

require_once '/sdk/Velocity.php';

2. Instantiate processor

// ensure to keep this identity token secret
$identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPSIxIiBBc3NlcnRpb25JRD0iXzdlMDhiNzdjLTUzZWEtNDEwZC1hNmJiLTAyYjJmMTAzMzEwYyIgSXNzdWVyPSJJcGNBdXRoZW50aWNhdGlvbiIgSXNzdWVJbnN0YW50PSIyMDE0LTEwLTEwVDIwOjM2OjE4LjM3OVoiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjEuMDphc3NlcnRpb24iPjxzYW1sOkNvbmRpdGlvbnMgTm90QmVmb3JlPSIyMDE0LTEwLTEwVDIwOjM2OjE4LjM3OVoiIE5vdE9uT3JBZnRlcj0iMjA0NC0xMC0xMFQyMDozNjoxOC4zNzlaIj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBZHZpY2U+PC9zYW1sOkFkdmljZT48c2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PHNhbWw6U3ViamVjdD48c2FtbDpOYW1lSWRlbnRpZmllcj5GRjNCQjZEQzU4MzAwMDAxPC9zYW1sOk5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2RvQ2IrZXpBcVJnbk5EVSs3NlVYOEZFSEN3Q2c5a0tLSzQwMXdYNXpLd2FPRGJJUFpEYitBPT08L1NpZ25hdHVyZVZhbHVlPjxLZXlJbmZvPjxvOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2UgeG1sbnM6bz0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzLzIwMDQvMDEvb2FzaXMtMjAwNDAxLXdzcy13c3NlY3VyaXR5LXNlY2V4dC0xLjAueHNkIj48bzpLZXlJZGVudGlmaWVyIFZhbHVlVHlwZT0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzL29hc2lzLXdzcy1zb2FwLW1lc3NhZ2Utc2VjdXJpdHktMS4xI1RodW1icHJpbnRTSEExIj5ZREJlRFNGM0Z4R2dmd3pSLzBwck11OTZoQ2M9PC9vOktleUlkZW50aWZpZXI+PC9vOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2U+PC9LZXlJbmZvPjwvU2lnbmF0dXJlPjwvc2FtbDpBc3NlcnRpb24+";
$applicationprofileid = 14644;  
$merchantprofileid = "PrestaShop Global HC"; 
$workflowid = 2317000001;
$isTestAccount = true; 

try {
	$velocityProcessor = new Velocity_Processor($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken);
} catch (Exception $e) {
	echo $e->getMessage();
}

Here we instantiate the processor in order to use it to process payments. It takes all of our configuration parameters as well as a boolean indicating whether we are testing or not.

3. Use payment methods of processor

To understand the Authorization & Capture process, please read our Integration Guidance. Also, the tokenization process should be understood. For each payment method taking cardholder data below (Verify, Authorize, AuthorizeAndCapture, ReturnUnlinked) you can use four different types of data: Keyed data, swiped data, tokenized data, or encrypted data. While swiped and keyed data are obtained directly from the card, tokenized data is obtained from a solution like the Transparent Redirect, or by a direct call to Verify via the SDK. Utilizing tokens can help reduce your PCI scope. Encrypted data is obtained from an encrypted card reader and can also greatly reduce your PCI scope.

Below is an example of an authorize and capture with each of the different types of data:

Authorize and capture with token

try {
	
	$response = $velocityProcessor->authorizeAndCapture(array(
		'amount' => 10.03, 
		'avsdata' => array(   
			'Street' => 'xyz', 
			'City' => 'cityname', 
			'StateProvince' => 'statecode', 
			'PostalCode' => 'postcode', 
			'Country' => 'countrycode three letter'
		),
		'token' => $paymentAccountDataToken, 								      
		'order_id' => '629203',
	));
	
	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'AuthorizeAndCapture Successful!</br>';
		echo 'Masked PAN: ' . $response['MaskedPAN'] . '</br>';
		echo 'Approval Code: ' . $response['ApprovalCode'] . '</br>';
		echo 'Amount: ' . $response['Amount'] . '</br>'; 
		echo 'TransactionId: ' . $response['TransactionId']; 
	} else {
		// some error
		print_r($response);
	}
	
	$authCapTransactionid = $response['TransactionId'];
	
} catch(Exception $e) {
	echo $e->getMessage(); 
} 

Authorize and capture with keyed data

try {	
	$response = $velocityProcessor->authorizeAndCapture(array(
		'amount' => 10.03, 
		'avsdata' => array(   
			'Street' => 'xyz', 
			'City' => 'cityname', 
			'StateProvince' => 'statecode', 
			'PostalCode' => 'postcode', 
			'Country' => 'countrycode three letter'
		 ),
		'carddata' => array(    
			'cardowner' => 'Jane Doe', 
			'cardtype' => 'Visa', 
			'pan' => '4012888812348882', 
			'expire' => '1215', 
			'cvv' => '123'
		),
		'order_id' => '629203',
	));

Authorize and capture with swiped data

	$response = $velocityProcessor->authorizeAndCapture(array(
		'amount' => 10.03, 
		'avsdata' => array(   
			'Street' => 'xyz', 
			'City' => 'cityname', 
			'StateProvince' => 'statecode', 
			'PostalCode' => 'postcode', 
			'Country' => 'countrycode three letter'
		 ),
		'carddata' => array(    
			'track2data' => '4012000033330026=09041011000012345678', 
			'cardtype' => 'Visa'
		),
		'order_id' => '629203',
	));

Authorize and capture with encrypted data

Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative):

	$workflowid = 'BBBAAA0001';
	try {
		$velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken );
	} catch (Exception $e) {
	    echo $e->getMessage();
	}

Then you can perform the transaction:

	$response = $velocityProcessor->authorizeAndCapture(array(
		'amount' => 10.03, 
		'avsdata' => array(   
			'Street' => 'xyz', 
			'City' => 'cityname', 
			'StateProvince' => 'statecode', 
			'PostalCode' => 'postcode', 
			'Country' => 'countrycode three letter'
		 ),
		'p2pedata' => array(
			'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88',
			'EncryptionKeyId' => '9010010B257DC7000084'
		),
		'order_id' => '629203',
	));

The rest of the payment methods can be found below:

Authorize method

try {
	
	$response = $velocityProcessor->authorize(array(
		'amount' => 10,  
		'avsdata' => array(   
			'Street' => 'xyz', 
			'City' => 'cityname', 
			'StateProvince' => 'statecode', 
			'PostalCode' => 'postcode', 
			'Country' => 'countrycode three letter'
		),
		'token' => $paymentAccountDataToken,
		'order_id' => '629203'
	)); 
	
	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'Authorize Successful!</br>';
		echo 'Masked PAN: ' . $response['MaskedPAN'] . '</br>';
		echo 'Approval Code: ' . $response['ApprovalCode'] . '</br>';
		echo 'Amount: ' . $response['Amount'] . '</br>'; 
		echo 'TransactionId: ' . $response['TransactionId']; 
	} else {
		// some error
		print_r($response);
	}

	$authTransactionid = $response['TransactionId'];
		
} catch (Exception $e) {
	echo $e->getMessage();	
}        

Capture

try {
	
	$response = $velocityProcessor->capture(array(
		'amount' => 6.03, 
		'TransactionId' => $authTransactionid
	));	

	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'Capture Successful!</br>';
		echo 'Amount: ' . $response['TransactionSummaryData']['NetTotals']['NetAmount']; 
	} else {
		// some error
		print_r($response);
	}

	$captxnid = $response['TransactionId'];
		
} catch(Exception $e) {
	echo $e->getMessage();
}

Undo (Void/Reversal)

try {
	
	$response = $velocityProcessor->undo(array(
		'TransactionId' => $adjusttxnid
	));
	
	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'Undo Successful!</br>';
		echo 'TransactionId: ' . $response['TransactionId'] . '</br></br>'; 
	} else {
		// some error
		print_r($response);
	}
							   		
} catch (Exception $e) {
	echo $e->getMessage();
} 

Adjust

try {
		
	$response = $velocityProcessor->adjust(array(
		'amount' => 3.01, 
		'TransactionId' => $captxnid
	));
	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'Adjust Successful!</br>';
		echo 'Amount: ' . $response['Amount'] . '</br></br>'; 
		$adjusttxnid = $response['TransactionId'];
	} else {
		// some error
		print_r($response);
	}
		
} catch (Exception $e) {
	echo $e->getMessage();
}

ReturnById

try {
	$response = $velocityProcessor->returnById(array(
		'amount' => 5.03, 
		'TransactionId' => $authCapTransactionid
	));
	
	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'ReturnById Successful!</br>';
		echo 'ApprovalCode: ' . $response['ApprovalCode'] . '</br></br>'; 
	} else {
		// some error
		print_r($response);
	}

} catch (Exception $e) {
	echo $e->getMessage();
}

ReturnUnlinked with token:

try {
				
	$response = $velocityProcessor->returnUnlinked(array( 
		'amount' => 1.03, 
		'token' => $paymentAccountDataToken, 
		'order_id' => '629203'
	));
		
	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'ReturnUnlinked Successful!</br>';
		echo 'ApprovalCode: ' . $response['ApprovalCode'] . '</br></br>'; 
	} else {
		// some error
		print_r($response);
	}

} catch (Exception $e) {
	echo $e->getMessage();
}

Verify method

try {
	
	$response = $velocityProcessor->verify(array(  									
		'avsdata' => array(   
			'Street' => 'xyz', 
			'City' => 'cityname', 
			'StateProvince' => 'statecode', 
			'PostalCode' => 'postcode', 
			'Country' => 'countrycode three letter'
		),
		'carddata' => array(    
			'cardowner' => 'Jane Doe', 
			'cardtype' => 'Visa', 
			'pan' => '4012888812348882', 
			'expire' => '1215', 
			'cvv' => '123'
		)										
	)); 

	if (isset($response['Status']) && $response['Status'] == 'Successful') {
		echo 'Verify Successful!</br>';
		echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . '</br>'; 
		echo 'CVResult: ' . $response['CVResult']; 
	} else {
		// some error
		print_r($response);
	}

} catch(Exception $e) {
	echo $e->getMessage();
}

####CaptureAll Method:

    try{
		$velocityProcessor->captureAll();
    } catch (Exception $ex) {
		echo $e->getMessage();
    }

####QueryTransactionDetail Method:

    try {
		$response = $VelocityProcessor->queryTransactionsDetail(array(
			'querytransactionparam' => array(
			'Amounts' => array(10.00),
			'ApprovalCodes' => array('VI0000'),
			'BatchIds' => array('0539'),
			'CaptureDateRange' => array(
				'EndDateTime' => '2015-03-17 02:03:40',
				'StartDateTime' => '2015-03-13 02:03:40'
			),
			'CaptureStates' => array('ReadyForCapture'),
			'CardTypes' => array('Visa'),
			'MerchantProfileIds' => array('PrestaShop Global HC'),
			'OrderNumbers' => array('629203'),
			'ServiceIds' => array('2317000001'),
			'ServiceKeys' => array('FF3BB6DC58300001'),
			'TransactionClassTypePairs' => array( array(
				'TransactionClass' => 'CREDIT',
				'TransactionType' => 'AUTHONLY'
				)
			),
			'TransactionDateRange' => array(
				'EndDateTime' => '2015-03-17 02:03:40',
				'StartDateTime' => '2015-03-13 02:03:40'
			),
			'TransactionIds' =>             array('9B935E96763F43C3866F603319BE7B52'),
			'TransactionStates' => array('Authorized')                        
			),
			'PagingParameters' => array(
				'page' => '0',
				'pagesize' => '3'
			),
		));
    } catch(Exception $e) {
	    echo $e->getMessage();
    }