PHP code example of kimoslim / omnipay-merchant-warrior
1. Go to this page and download the library: Download kimoslim/omnipay-merchant-warrior 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/ */
kimoslim / omnipay-merchant-warrior example snippets
$gateway = Omnipay::create('MerchantWarrior');
$gateway->setMerchantUUID('merchant UUID');
$gateway->setApiKey('API KEY');
$gateway->setApiPassphrase('API PASS');
$card = new CreditCard(array(
'firstName' => 'Joe',
'lastName' => 'Bloggs',
'number' => '4444333322221111',
'expiryMonth' => '01',
'expiryYear' => '2019',
'billingAddress1' => 'street',
'billingCountry' => 'AU',
'billingCity' => 'SUBURB',
'billingPostcode' => 'POSTCODE',
'billingState' => 'STATE',
'email' => '[email protected] ',
));
$purchase = [
'amount' => '1.00',
'currency' => 'AUD',
'transactionType' => 'Purchase',
'transactionId' => 'TRANSACTION ID',
'transactionProduct'=> 'Test Transaction Description',
'card' => $card
];
$request = $gateway->purchase($purchase);
$response = $request->send();
if ($response->isSuccessful()) {
// insert the transaction
$txn_id = $response->getTransactionReference();
$auth_code = $response->getAuthCode();
$message = $response->getMessage();
echo 'Payment successful: TXN ID - '.$txn_id.' auth code: '.$auth_code.' message:'.$message.PHP_EOL;
}
else
{
echo 'Credit Card Failed: '.$response->getMessage().PHP_EOL;
}
$authorize = [
'amount' => '1.00',
'currency' => 'AUD',
'transactionType' => 'Authorize',
'transactionId' => 'TRANSACTION ID',
'transactionProduct'=> 'Test Authorisation Description',
'card' => $card
];
$request = $gateway->authorize($authorize);
$response = $request->send();
if ($response->isSuccessful()) {
// insert the transaction
$txn_id = $response->getTransactionReference();
$auth_code = $response->getAuthCode();
$message = $response->getMessage();
echo 'Payment successful: TXN ID - '.$txn_id.' auth code: '.$auth_code.' message:'.$message.PHP_EOL;
}
else
{
echo 'Credit Card Failed: '.$response->getMessage().PHP_EOL;
}