Installation
Download the latest release here and unzip the files into your project directory.
Autoload the SDK package with:
<?php
require __DIR__ . '/path-to-sdk-files/src/autoload.php';
// ...
?>
Set appropriate values in src/settings.ini
:
MERCHANT_ID = 6-digit integer, referenced as MERCHANT_ID in code snippets
API_KEY = used for authentication
LOG_PATH = /tmp
LOG_FILE = pinpoint.log
LOG_LEVEL = DEBUG | INFO | WARN | ERROR | FATAL
Place the data collector on your checkout page:
<?php echo Pinpoint_Request::placeCollector() ?>
Make an API request with the SDK within your checkout process before payment details are sent to your gateway.
Example Usage
<?php
require __DIR__ . '/../src/autoload.php';
session_start();
?>
<?php if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) : ?>
<?php
try {
// initialize pinpoint request object
$inquiry = new Pinpoint_Request();
// set request parameters
$inquiry->setParam('session_id', session_id());
$inquiry->setPayment('CARD', '411111XXXXXX1111');
$inquiry->setCurrency('USD');
$inquiry->setAuth('A');
$inquiry->setEmail('[email protected]');
$inquiry->setCustomerIp('123.45.678.90');
$inquiry->setShip('true');
$inquiry->setSite('DEFAULT');
$inquiry->setPrice('100');
// Pinpoint_Data_Item and Pinpoint_Data_UserField are used for array parameters
$items = array();
$items[] = new Pinpoint_Data_Item("TV", "LZG-123", "32-inch LCD", 1, 100);
$inquiry->setItems($items);
// make api request and get back a Pinpoint_Response object
$response = $inquiry->getResponse();
print_r('Transaction ID: '.$response->getTransactionId().'<br/>');
print_r('Score: '.$response->getScore().'<br/>');
print_r('Decision: '.$response->getDecision().'<br/>');
print_r('Device Info Collected: '.$response->getParam('DC').'<br/>');
} catch (Exception $e) {
print_r($e);
}
?>
<?php else : ?>
<html>
<head>
</head>
<body>
<?php echo Pinpoint_Request::placeCollector() ?>
<form method='post' action='test.php'>
<input type='submit'/>
</form>
</body>
</html>
<?php endif; ?>
A full list of available request and response parameters can be seen in our REST API documentation.
Updated 10 days ago