PHP code example of mvestil / omnipay-rocketgate
1. Go to this page and download the library: Download mvestil/omnipay-rocketgate library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mvestil / omnipay-rocketgate example snippets
// Initialize the gateway
$gateway = Omnipay::create('RocketGate');
$gateway->initialize(array(
'merchantID' => 'XXXXXXXXXXXX',
'merchantPassword' => 'XXXXXXXXXXXX',
'testMode' => true,
));
// Create a credit card object
$card = new CreditCard(array(
'firstName' => 'Example',
'lastName' => 'Customer',
'number' => '4242424242424242',
'expiryMonth' => '01',
'expiryYear' => '2032',
'cvv' => '123',
'email' => '[email protected] ',
'billingAddress1' => 'Consolacion, Cebu',
'billingCountry' => 'PH',
'billingCity' => 'Philippines',
'billingPostcode' => '567278',
'billingState' => 'Philippines',
));
// Do a purchase transaction on the gateway
$transactorId = random_int(0, 1000000000);
$transaction = $gateway->purchase(array(
'amount' => '50.00',
'currency' => 'USD',
'card' => $card,
'transactorId' => $transactorId,
'transactionId' => random_int(0, 1000000000),
));
$response = $transaction->send();
if ($response->isSuccessful()) {
echo "Purchase transaction was successful!\n";
$token = $response->getCardReference();
echo "Card reference = " . $token . "\n";
}
// Do a token transaction on the gateway
$transaction = $gateway->purchase(array(
'amount' => '50.0',
'currency' => 'USD',
'transactorId' => $transactorId,
'transactionId' => random_int(0, 1000000000),
'cardReference' => $response->getCardReference(),
));