<?php
require_once 'eway-rapid-php-master/include_eway.php';

$apiKey = '60CF3Ce97nRS1Z1Wp5m9kMmzHHEh8Rkuj31QCtVxjPWGYA9FymyqsK0Enm1P6mHJf0THbR';
$apiPassword = 'API-P4ss';
$apiEndpoint = \Eway\Rapid\Client::MODE_SANDBOX; // Use \Eway\Rapid\Client::MODE_PRODUCTION when you go live
$client = \Eway\Rapid::createClient($apiKey, $apiPassword, $apiEndpoint);

$customer = [
    'Title' => 'Mr.',
    'FirstName' => 'John',
    'LastName' => 'Smith',
    'Country' => 'au',
    'CardDetails' => [
        'Name' => 'John Smith',
        'Number' => '4444333322221111',
        'ExpiryMonth' => '12',
        'ExpiryYear' => '25',
        'CVN' => '123',
    ]
];

$response = $client->createCustomer(\Eway\Rapid\Enum\ApiMethod::DIRECT, $customer);
echo "<pre>";
print_r($response);
echo "</pre>";
$tokencustomerid = $response->Customer->TokenCustomerID;
echo $tokencustomerid;
exit;

/*$transaction = [
    'Customer' => [
        'Reference' => 'A12345',
        'Title' => 'Mr.',
        'FirstName' => 'John',
        'LastName' => 'Smith',
        'CompanyName' => 'Demo Shop 123',
        'JobDescription' => 'Developer',
        'Street1' => 'Level 5',
        'Street2' => '369 Queen Street',
        'City' => 'Sydney',
        'State' => 'NSW',
        'PostalCode' => '2000',
        'Country' => 'au',
        'Phone' => '09 889 0986',
        'Email' => 'demo@example.org',
        'CardDetails' => [
            'Name' => 'John Smith',
            'Number' => '4444333322221111',
            'ExpiryMonth' => '12',
            'ExpiryYear' => '25',
            'CVN' => '123',
        ]
    ],
    'Payment' => [
        'TotalAmount' => 1000,
    ],
    'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
];

$response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction);
$tokencustomerid = $response->Customer->TokenCustomerID;
echo $tokencustomerid;
print_r($response);*/