-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAuthAndCapture.php
56 lines (47 loc) · 1.68 KB
/
AuthAndCapture.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
<?php
include_once 'vendor/autoload.php';
use GlobalPayments\Api\Entities\Enums\CardType;
use Omnipay\Omnipay;
$gateway = Omnipay::create('GlobalPayments\Genius');
$gateway->setMerchantName('Test Shane Logsdon');
$gateway->setMerchantSiteId('BKHV2T68');
$gateway->setMerchantKey('AT6AN-ALYJE-YF3AW-3M5NN-UQDG1');
/**
* An 'authorize' transaction behaves the same was a 'purchase' except that the
* transaction is not automatically captured (finalized). A subsequent 'capture'
* transaction is required to receive funding for an 'authozize' transaction.
*/
$formData = array(
'number' => '5454545454545454',
'expiryMonth' => '12',
'expiryYear' => '2025',
'cvv' => '999',
'type' => CardType::VISA, // required for Transit gateway only
'firstName' => 'Tony',
'lastName' => 'Smedal',
'billingAddress1' => '1 Heartland Way',
'billingCity' => 'Jeffersonville',
'billingState' => 'IN',
'billingCountry' => 'USA',
'billingPostCode' => '47130'
);
$authReponse = $gateway->authorize(
array(
'card' => $formData,
'currency' => 'USD',
'amount' => '45.67',
'description' => 'AuthAndCapture.php example'
)
)->send();
sleep(5);
$captureResponse = $gateway->capture(
array(
'transactionReference' => $authReponse->getTransactionReference(),
'amount' => '5.00', // optional; used for specifying an amount different than the original auth
)
)->send();
if ($captureResponse->isSuccessful()) {
echo 'Success! Credit card transaction captured via Genius gateway. Transaction ID is: ' . $authReponse->getTransactionReference();
} else {
echo 'Failure! Something went wrong: ' . $captureResponse->getMessage();
}