Skip to content

Commit 781b874

Browse files
20210310 deployment
Initial Deployment
0 parents  commit 781b874

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6037
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
/vendor
3+
.vscode/

Examples/AchPurchase.php

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\AccountType;
6+
use GlobalPayments\Api\Entities\Enums\CheckType;
7+
use GlobalPayments\Api\Entities\Enums\SecCode;
8+
use Omnipay\GlobalPayments\ECheck;
9+
use Omnipay\Omnipay;
10+
11+
$gateway = Omnipay::create('GlobalPayments\Heartland');
12+
$gateway->setSecretApiKey('skapi_cert_McU0AgBkx2EAldEfhhtolMw0RnvahBQAnXFdLYga-Q');
13+
14+
/**
15+
* For ACH transactions we try to mimic credit card handling as closely as possible.
16+
* However, since there are required data elements, such as 'SecCode', that do not
17+
* apply to credit/debit cards, some differences are unavoidable. These unique
18+
* data elements can set using the setter methods shown below, or as an array that
19+
* is passed as the argument for ECheck($arrayOfAchInfo).
20+
*/
21+
22+
$eCheck = new ECheck();
23+
$eCheck->setSecCode(SecCode::WEB);
24+
$eCheck->setAccountType(AccountType::CHECKING);
25+
$eCheck->setCheckType(CheckType::PERSONAL);
26+
$eCheck->setBillingAddress1('6860 Dallas Pkwy');
27+
$eCheck->setBillingPostcode('750241234');
28+
$eCheck->setCheckHolderName('Tony Smedal');
29+
30+
/**
31+
* Account number and routing number can be omitted if using Heartland single-use
32+
* tokens in normal Omnipay fashion: 'token' => '$sut'
33+
*/
34+
$eCheck->setAccountNumber('1357902468');
35+
$eCheck->setRoutingNumber('122000030');
36+
37+
$response = $gateway->purchase(
38+
array(
39+
'check' =>$eCheck,
40+
'currency' => 'USD',
41+
'amount' => '56.78',
42+
'description' => 'AchPurchase.php example'
43+
)
44+
)->send();
45+
46+
if ($response->isSuccessful()) {
47+
echo 'Success! ACH transaction processed via Heartland gateway. Transaction ID is: ' . $response->getTransactionReference();
48+
} else {
49+
echo 'Failure! Something went wrong.';
50+
}

Examples/ApplePayPurchase.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\MobilePaymentMethodType;
6+
use Omnipay\Omnipay;
7+
8+
$gateway = Omnipay::create('GlobalPayments\Genius');
9+
$gateway->setMerchantName('Test Shane Logsdon');
10+
$gateway->setMerchantSiteId('BKHV2T68');
11+
$gateway->setMerchantKey('AT6AN-ALYJE-YF3AW-3M5NN-UQDG1');
12+
13+
$formData = array(
14+
'mobileType' => MobilePaymentMethodType::APPLEPAY, // required for Apple Pay
15+
'firstName' => 'Tony',
16+
'lastName' => 'Smedal',
17+
'billingAddress1' => '1 Heartland Way',
18+
'billingCity' => 'Jeffersonville',
19+
'billingState' => 'IN',
20+
'billingCountry' => 'USA',
21+
'billingPostCode' => '47130'
22+
);
23+
24+
$response = $gateway->purchase(
25+
array(
26+
'card' => $formData,
27+
'currency' => 'USD',
28+
'amount' => '56.78',
29+
'token' => 'ew0KCSJ2ZXJzaW9uIjogIkVDX3YxIiwNCgkiZ==',
30+
)
31+
)->send();
32+
33+
if ($response->isSuccessful()) {
34+
echo 'Success! Credit card transaction processed via Transit gateway. Transaction ID is: ' . $response->getTransactionReference();
35+
} else {
36+
echo 'Failure! Something went wrong: ' . $response->getMessage();
37+
}

Examples/AuthAndCapture.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\CardType;
6+
use Omnipay\Omnipay;
7+
8+
$gateway = Omnipay::create('GlobalPayments\Genius');
9+
$gateway->setMerchantName('Test Shane Logsdon');
10+
$gateway->setMerchantSiteId('BKHV2T68');
11+
$gateway->setMerchantKey('AT6AN-ALYJE-YF3AW-3M5NN-UQDG1');
12+
13+
/**
14+
* An 'authorize' transaction behaves the same was a 'purchase' except that the
15+
* transaction is not automatically captured (finalized). A subsequent 'capture'
16+
* transaction is required to receive funding for an 'authozize' transaction.
17+
*/
18+
19+
$formData = array(
20+
'number' => '5454545454545454',
21+
'expiryMonth' => '12',
22+
'expiryYear' => '2025',
23+
'cvv' => '999',
24+
'type' => CardType::VISA, // required for Transit gateway only
25+
'firstName' => 'Tony',
26+
'lastName' => 'Smedal',
27+
'billingAddress1' => '1 Heartland Way',
28+
'billingCity' => 'Jeffersonville',
29+
'billingState' => 'IN',
30+
'billingCountry' => 'USA',
31+
'billingPostCode' => '47130'
32+
);
33+
34+
$authReponse = $gateway->authorize(
35+
array(
36+
'card' => $formData,
37+
'currency' => 'USD',
38+
'amount' => '45.67',
39+
'description' => 'AuthAndCapture.php example'
40+
)
41+
)->send();
42+
43+
sleep(5);
44+
45+
$captureResponse = $gateway->capture(
46+
array(
47+
'transactionReference' => $authReponse->getTransactionReference(),
48+
'amount' => '5.00', // optional; used for specifying an amount different than the original auth
49+
)
50+
)->send();
51+
52+
if ($captureResponse->isSuccessful()) {
53+
echo 'Success! Credit card transaction captured via Genius gateway. Transaction ID is: ' . $authReponse->getTransactionReference();
54+
} else {
55+
echo 'Failure! Something went wrong: ' . $captureResponse->getMessage();
56+
}

Examples/CardOnFilePurchase.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\CardType;
6+
use GlobalPayments\Api\Entities\Enums\StoredCredentialInitiator;
7+
use Omnipay\Omnipay;
8+
9+
$gateway = Omnipay::create('GlobalPayments\Heartland');
10+
$gateway->setSecretApiKey('skapi_cert_McU0AgBkx2EAldEfhhtolMw0RnvahBQAnXFdLYga-Q');
11+
12+
/**
13+
* Purchase example using a Card Reference as well as two key card-on-file elements
14+
*/
15+
16+
$formData = array(
17+
'type' => CardType::VISA, // required for Transit gateway only
18+
'firstName' => 'Tony',
19+
'lastName' => 'Smedal',
20+
'billingAddress1' => '1 Heartland Way',
21+
'billingCity' => 'Jeffersonville',
22+
'billingState' => 'IN',
23+
'billingCountry' => 'USA',
24+
'billingPostCode' => '47130',
25+
'cardBrandTransId' => '123456789',
26+
'storedCredInitiator' => StoredCredentialInitiator::MERCHANT,
27+
);
28+
29+
$response = $gateway->purchase(
30+
array(
31+
'cardReference' => 'E7LxbO22Af9gKxAECJC65454', // obtained using CreateCard.php
32+
'card' => $formData,
33+
'currency' => 'USD',
34+
'amount' => '45.67',
35+
'description' => 'Purchase.php example'
36+
)
37+
)->send();
38+
39+
if ($response->isSuccessful()) {
40+
echo 'Success! Credit card transaction processed via Heartland gateway. Transaction ID is: ' . $response->getTransactionReference();
41+
} else {
42+
echo 'Failure! Something went wrong: ' . $response->getMessage();
43+
}

Examples/CreateCard.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\CardType;
6+
use Omnipay\Omnipay;
7+
8+
$gateway = Omnipay::create('GlobalPayments\Heartland');
9+
$gateway->setSecretApiKey('skapi_cert_McU0AgBkx2EAldEfhhtolMw0RnvahBQAnXFdLYga-Q');
10+
11+
/**
12+
* 'Card reference' in the context of Omnipay/Global-Payments integrations is
13+
* synonymous with Multi-Use Tokens. For Heartland, a MUT can
14+
* represent the card number and exipration date.
15+
*/
16+
17+
18+
$formData = array(
19+
'number' => '5454545454545454',
20+
'expiryMonth' => '12',
21+
'expiryYear' => '2025',
22+
'cvv' => '123',
23+
'type' => CardType::MASTERCARD, // required for Transit gateway only
24+
'firstName' => 'Tony',
25+
'lastName' => 'Smedal',
26+
'billingAddress1' => '1 Heartland Way',
27+
'billingCity' => 'Jeffersonville',
28+
'billingState' => 'IN',
29+
'billingCountry' => 'USA',
30+
'billingPostCode' => '47130'
31+
);
32+
33+
$response = $gateway->createCard(
34+
array(
35+
'card' => $formData,
36+
)
37+
)->send();
38+
39+
if ($response->isSuccessful()) {
40+
echo 'Success! Card-reference successfully generated. Card reference is: ' . $response->getCardReference();
41+
} else {
42+
echo 'Failure! Something went wrong: ' . $response->getMessage();
43+
}

Examples/Purchase.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\CardType;
6+
use Omnipay\Omnipay;
7+
8+
$gateway = Omnipay::create('GlobalPayments\Transit');
9+
$gateway->setDeviceId('88500000322601');
10+
$gateway->setMerchantId('885000003226');
11+
$gateway->setUserName('TA5748226');
12+
$gateway->setTransactionKey('DPJLWWAD1MOAX8XPCHZAXP15U0UME5U0');
13+
14+
/**
15+
* Card transactions can be processed using the core parameters from Omnipay's
16+
* CreditCard class. However, when using the Transit gateway specifically (as
17+
* this example does) it is important to use one additional parameter: 'type'.
18+
* This allows the proper elements to be sent for specific card brands as required
19+
* by the Transit gateway.
20+
*/
21+
22+
$formData = array(
23+
'number' => '4012000098765439',
24+
// 'number' => '5454545454545454', // will result in a DNH decline when used w/Transit gateway
25+
'expiryMonth' => '12',
26+
'expiryYear' => '2025',
27+
'cvv' => '999',
28+
'type' => CardType::VISA, // required for Transit gateway only
29+
'firstName' => 'Tony',
30+
'lastName' => 'Smedal',
31+
'billingAddress1' => '1 Heartland Way',
32+
'billingCity' => 'Jeffersonville',
33+
'billingState' => 'IN',
34+
'billingCountry' => 'USA',
35+
'billingPostCode' => '47130'
36+
);
37+
38+
$response = $gateway->purchase(
39+
array(
40+
'card' => $formData,
41+
'currency' => 'USD',
42+
'amount' => '45.67',
43+
'description' => 'Purchase.php example'
44+
)
45+
)->send();
46+
47+
if ($response->isSuccessful()) {
48+
echo 'Success! Credit card transaction processed via Transit gateway. Transaction ID is: ' . $response->getTransactionReference();
49+
} else {
50+
echo 'Failure! Something went wrong: ' . $response->getMessage();
51+
}

Examples/Refund.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
include_once 'vendor/autoload.php';
4+
5+
use GlobalPayments\Api\Entities\Enums\CardType;
6+
use Omnipay\Omnipay;
7+
8+
$gateway = Omnipay::create('GlobalPayments\Heartland');
9+
$gateway->setSecretApiKey('skapi_cert_McU0AgBkx2EAldEfhhtolMw0RnvahBQAnXFdLYga-Q');
10+
11+
/**
12+
* Refunds are processed using basic Omnipay methodology, simply pass in
13+
* the target transaction's reference number.
14+
*/
15+
16+
$formData = array(
17+
'number' => '5454545454545454',
18+
'expiryMonth' => '12',
19+
'expiryYear' => '2025',
20+
'cvv' => '999',
21+
'type' => CardType::MASTERCARD, // required for Transit gateway only
22+
'firstName' => 'Tony',
23+
'lastName' => 'Smedal',
24+
'billingAddress1' => '1 Heartland Way',
25+
'billingCity' => 'Jeffersonville',
26+
'billingState' => 'IN',
27+
'billingCountry' => 'USA',
28+
'billingPostCode' => '47130'
29+
);
30+
31+
// Purchase
32+
$purchaseResponse = $gateway->purchase(
33+
array(
34+
'card' => $formData,
35+
'currency' => 'USD',
36+
'amount' => 11.20
37+
)
38+
)->send();
39+
40+
sleep(1);
41+
42+
// Void
43+
$refundResponse = $gateway->refund(
44+
array(
45+
'transactionReference' => $purchaseResponse->getTransactionReference(),
46+
'amount' => '5.00', // required; refund-amount <= purchase-amount
47+
'description' => 'Customer returned merchandise.', // optional
48+
'currency' => 'USD' // required
49+
)
50+
)->send();
51+
52+
if ($refundResponse->isSuccessful()) {
53+
echo 'Transaction successfully refunded!' . PHP_EOL;
54+
echo 'Transaction ID for the purchase is: '. $purchaseResponse->getTransactionReference() . PHP_EOL;
55+
echo 'Transaction ID for the refund is: ' . $refundResponse->getTransactionReference();
56+
} else {
57+
echo 'Failure! Something went wrong: ' . $response->getMessage();
58+
}

0 commit comments

Comments
 (0)