|
| 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 | +} |
0 commit comments