-
Notifications
You must be signed in to change notification settings - Fork 3
/
sample.php
69 lines (55 loc) · 1.75 KB
/
sample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* This example uses OrbitalPHP to send a NewOrder request to the Chase
* Paymentech Orbital Gateway and inspect the response.
*/
// Load OrbitalPHP
require_once '../lib/OrbitalPHP/orbitalphp.php';
// Set some convenient aliases
use OrbitalPHP\Client as OrbitalPHP;
use OrbitalPHP\Exception as OrbitalPHPException;
try {
// Create an OrbitalPHP\Client object
$orbitalPHP = new OrbitalPHP(
'ssl://orbitalvar1.paymentech.net:443', // sockethost
123451234512, // merchant id
function($request) {}, // onbeforesend
function($request, $response) {} // onaftersend
);
// Creates an OrbitalPHP\Request object of type NewOrder
$request = $orbitalPHP->newOrder(array(
'OrbitalConnectionUsername' => 'MYUSERNAME',
'OrbitalConnectionPassword' => 'MYPASSWORD',
'IndustryType' => 'EC',
'MessageType' => 'AC',
'BIN' => '000002',
'MerchantID' => '123451234512',
'TerminalID' => '001',
'AccountNum' => '5454545454545454',
'Exp' => '0915',
'CurrencyCode' => '840',
'CurrencyExponent' => '2',
'CardSecVal' => '111',
'OrderID' => time(),
'Amount' => '100',
));
// Send the request and get response object
$traceNumber = time();
$response = $orbitalPHP->send($request, $traceNumber);
// Get some response details
$statusCode = $response->getHttpStatusCode();
$procStatus = $response->getProcStatus();
// Check for success
$success = $statusCode == 200 && $procStatus === 0;
// Or, simply
if ($response->isOk()) {
// Check an individual XML element
$txRefNum = $response->getData('TxRefNum');
// Get the entire response as an array
$data = $response->getData();
}
} catch (OrbitalPHPException $e) {
// Handle the exception
} catch (Exception $e) {
// Handle the exception
}