-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_with_real_api.php
43 lines (31 loc) · 1.05 KB
/
test_with_real_api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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";