Skip to content

Commit

Permalink
A handy console script to test against real API.
Browse files Browse the repository at this point in the history
  • Loading branch information
onlinesid committed May 14, 2020
1 parent 8ba91d5 commit 414f26b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
composer.lock
vendor
composer.phar
.idea
43 changes: 43 additions & 0 deletions test_with_real_api.php
@@ -0,0 +1,43 @@
<?php

/**
* 1. Run this as a command line, e.g.: `php test_with_real_api.php`
* 2. Enter the merchant code and authentication code
* 3. It should print out the response print_f and 'SUCCESSFUL' or 'FAILED' at the bottom
*/

require_once 'vendor/autoload.php';

use Omnipay\Omnipay;

$merchantCode = readline("Enter the merchant code: ");
$authenticationCode = readline("Enter the authentication code: ");

$gateway = Omnipay::create('Poli');
/** @var $gateway \Omnipay\Poli\Gateway */
$gateway->setMerchantCode($merchantCode);
$gateway->setAuthenticationCode($authenticationCode);

$response = $gateway->purchase(array(
'merchantCode' => $gateway->getMerchantCode(),
'authenticationCode' => $gateway->getAuthenticationCode(),
'transactionId' => 'TEST'.rand(1000,9999),
'currency' => 'NZD',
'amount' => '1.00',
'returnUrl' => 'https://localhost/return',
'cancelUrl' => 'https://localhost/cancel'
))->send();

print_r($response);
echo "\n";

if ($response->isSuccessful()) {
echo "SUCCESSFUL";
} else {
echo "FAILED";
}

echo "\n";



0 comments on commit 414f26b

Please sign in to comment.