Skip to content

Instantly share code, notes, and snippets.

@utsavsomaiya
Created May 11, 2024 19:48
Show Gist options
  • Save utsavsomaiya/24f15091e580f4e94f8b060d043ee657 to your computer and use it in GitHub Desktop.
Save utsavsomaiya/24f15091e580f4e94f8b060d043ee657 to your computer and use it in GitHub Desktop.
test route
<?php
Route::get('/test', function () {
$client = new SoapClient(
'https://sandbox.usaepay.com/soap/gate/15E7FB61/usaepay.wsdl'
);
$transactionKey = '_V87Qtb513Cd3vabM7RC0TbtJWeSo8p7';
$transactionPin = '123456';
$seed = time() . rand();
$token = [
'SourceKey' => $transactionKey,
'PinHash' => [
'Type' => 'sha1',
'Seed' => $seed,
'HashValue' => sha1($transactionKey . $seed . $transactionPin),
],
'ClientIP' => request()->ip(),
];
try {
$CustomerData = [
'BillingAddress' => [
'FirstName' => 'John',
'LastName' => 'Doe',
'Company' => 'Acme Corp',
'Street' => '1234 main st',
'Street2' => 'Suite #123',
'City' => 'Los Angeles',
'State' => 'CA',
'Zip' => '12345',
'Country' => 'US',
'Email' => '[email protected]',
'Phone' => '333-333-3333',
'Fax' => '333-333-3334'],
'PaymentMethods' => [
[
'CardNumber' => '4444555566667779',
'CardExpiration' => '0237',
'CardType' => '', 'CardCode' => '', 'AvsStreet' => '',
'AvsZip' => '',
'MethodName' => 'My Visa',
'SecondarySort' => 1],
],
'CustomData' => base64_encode(serialize(['mydata' => 'We could put anything in here!'])),
'CustomFields' => [
['Field' => 'Foo', 'Value' => 'Testing'],
['Field' => 'Bar', 'Value' => 'Tested'],
],
'CustomerID' => 123123 + rand(),
'Description' => 'Weekly Bill',
'Enabled' => false,
'Amount' => '44.93',
'Tax' => '0',
'Next' => '2012-01-21',
'Notes' => 'Testing the soap addCustomer Function',
'NumLeft' => '50',
'OrderID' => rand(),
'ReceiptNote' => 'addCustomer test Created Charge',
'Schedule' => 'weekly',
'SendReceipt' => true,
'Source' => 'Recurring',
'User' => '',
];
$Result = $client->addCustomer($token, $CustomerData);
dd($Result);
} catch (SoapFault $e) {
echo 'SoapFault: ' . $e->getMessage();
print_r($e);
echo "\n\nRequest: " . $e->__getLastRequest();
echo "\n\nResponse: " . $e->__getLastResponse();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment