Skip to content

Instantly share code, notes, and snippets.

@rubenCodeforges
Created February 11, 2016 14:51
Show Gist options
  • Save rubenCodeforges/0e97c8d1027dc0e2115f to your computer and use it in GitHub Desktop.
Save rubenCodeforges/0e97c8d1027dc0e2115f to your computer and use it in GitHub Desktop.
<?php
namespace Codeforges\PlaygroundBundle\Controller;
use MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\stdClass;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class SoapController extends Controller{
function indexAction () {
// $wsdl = 'https://test.achprocessing.com/api/ServiceTransaction.svc?wsdl';
// $apikey = "68ad3155-5900-4623-8be7-01b34caf86a2";
// $password = "SpyEscape2016!";
// $username = "APISpyEscape";
// $amount = 200;
// /* Initialize parameters */
// $payload = array(
// 'achAuthentication' => array(
// 'ApiKey' => $apikey,
// 'Password' => $password,
// 'UserName' => $username,
// ),
// 'transactionGroup' => array(
// 'ActionType' => 'Debit',
// 'EffectiveDate' => '2016-02-02T12:00:00',
// 'EntryDescription' => 'Rent Payment',
// 'SecCode' => 'CCD',
// 'TransactionDataMember' => array(
// 'AccountName' => 'Joe First',
// 'AccountNumber' => '465785469',
// 'AccountType' => 'Checking',
// 'Amount' => '3.25',
// 'CheckSerialNumber' => '123456789876543',
// // 'EmailId' => 'test@testcompany.com',
// 'IndividualIdentificationNumber' => '12345678997681',
// // 'PaymentRelatedInformation' => '12345678987654321',
// 'RoutingNumber' => '111906271',
// // 'SeriesOption' => '12345678987654321',
// 'TransactionCost' => '0.00',
// 'UserData' => 'LN45634',
// )
// )
//
// );
// '<transactionGroup>
// <ach:ActionType>Debit</ach:ActionType>
// <ach:EffectiveDate>2014-10-08T12:00:00</ach:EffectiveDate>
// <ach:EntryDescription>RentPymnt</ach:EntryDescription>
// <ach:SecCode>CCD</ach:SecCode>
// <ach:TransactionDataMember>
// <ach:AccountName>Joe First</ach:AccountName>
// <ach:AccountNumber>465785469</ach:AccountNumber>
// <ach:AccountType>Checking</ach:AccountType>
// <ach:Amount>3.25</ach:Amount>
// <ach:CheckSerialNumber>123456789876543</ach:CheckSerialNumber>
// <ach:EmailId>test@testcompany.com</ach:EmailId>
// <ach:FromDate>2014-10-08T12:00:00</ach:FromDate>
// <ach:IndividualIdentificationNumber>12345678997681</ach:IndividualIdentificationNumber>
// <ach:PaymentRelatedInformation>12345678987654321</ach:PaymentRelatedInformation>
// <ach:RoutingNumber>111906271</ach:RoutingNumber>
// <ach:SeriesOption>12345678987654321</ach:SeriesOption>
// <ach:ToDate>2015-05-15T12:00:00</ach:ToDate>
// <ach:TransactionCost>0.00</ach:TransactionCost>
// <ach:UserData>LN45634</ach:UserData>
// </ach:TransactionDataMember>
// </ach:TransactionDataMembers>
// <ach:UserData>BatchJan012015</ach:UserData>
// </transactionGroup>';
// $client = new \nusoap_client($wsdl, true);
// $client->http_encoding='utf-8';
// $client->soap_defencoding='utf-8';
//
// dump($client->request);
// $res = $client->call('CreateTransaction', $payload);
//
// dump($client->request);
// dump($client->error_str);
// dump($res);
$wsdl = new \wsdl("https://test.achprocessing.com/api/ServiceTransaction.svc?wsdl");
$apikey = "68ad3155-5900-4623-8be7-01b34caf86a2";
$password = "SpyEscape2016!";
$username = "APISpyEscape";
$amount = 200;
$params = array ( 'achAuthentication' => array(
'ApiKey' => $apikey,
'Password' => $password,
'UserName' => $username,
));
$obj = new \stdClass();
$obj->achAuthentication = array(
'ApiKey' => $apikey,
'Password' => $password,
'UserName' => $username,
);
$obj->transactionGroup = array(
'ActionType' => 'Debit',
'EffectiveDate' => '2016-02-02T12:00:00',
'EntryDescription' => 'Rent Payment',
'SecCode' => 'CCD',
'TransactionDataMember' => array(
'AccountName' => 'Joe First',
'AccountNumber' => '465785469',
'AccountType' => 'Checking',
'Amount' => '3.25',
'CheckSerialNumber' => '123456789876543',
// 'EmailId' => 'test@testcompany.com',
'IndividualIdentificationNumber' => '12345678997681',
// 'PaymentRelatedInformation' => '12345678987654321',
'RoutingNumber' => '111906271',
// 'SeriesOption' => '12345678987654321',
'TransactionCost' => '0.00'
)
);
$obj->userData = 'LN45634';
$payload = array(
'achAuthentication' => array(
'ApiKey' => $apikey,
'Password' => $password,
'UserName' => $username,
),
// 'transactionGroup' => array(
// 'TransactionGroupMember'=> array(
// 'ActionType' => 'Debit',
// 'EffectiveDate' => '2016-02-02T12:00:00',
// 'EntryDescription' => 'Rent Payment',
// 'SecCode' => 'CCD',
// 'TransactionDataMembers' => array(
// 'TransactionDataMember'=> array (
// 'AccountName' => 'Joe First',
// 'AccountNumber' => '465785469',
// 'AccountType' => 'Checking',
// 'Amount' => '3.25',
// 'PaymentRelatedInformation' => '02',
// 'RoutingNumber' => '111906271',
// 'UserData' => 'Test 02',
// 'EmailId' => 'mabusaad@achprocessing.com'
// )
// )
// )
// )
);
$context = array(
'http'=>array(
'protocol_version' => 1.1,
'header' => 'SOAPAction: "http://tempuri.org/IServiceTransaction/CreateTransaction"',
"Connection: close"
)
);
$wsdl = 'https://test.achprocessing.com/api/ServiceTransaction.svc?wsdl';
$options = array(
'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
'soap_version'=>SOAP_1_2,
'connection_timeout'=>15,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=> false,
//'stream_context' => stream_context_create($context)
);
$soap = new \SoapClient($wsdl, $options);
$nusoap = new \nusoap_client($wsdl,true);
$nusoap->soap_defencoding = 'UTF-8';
$nusoap->getHeader();
$nusoap->call('CreateTransaction',$payload);
dump ( $nusoap->request );
dump ( $nusoap->getHeader() );
dump ( $nusoap->response );
dump ( $nusoap->getError() );
// $res = $soap->CreateTransaction($payload);
// dump($soap->__getLastRequestHeaders());
// dump($soap->__getLastRequest());
// dump($soap->__getLastResponse());
// dump($res);
// $url = "https://test.achprocessing.com/api/ServiceTransaction.svc?wsdl";
// $body = '<ns2:CreateTransaction>
// <ns2:achAuthentication>
// <ns1:ApiKey>68ad3155-5900-4623-8be7-01b34caf86a2</ns1:ApiKey>
// <ns1:Password>SpyEscape2016!</ns1:Password>
// <ns1:UserName>APISpyEscape</ns1:UserName>
// </ns2:achAuthentication>
// </ns2:CreateTransaction>'; /// Your SOAP XML needs to be in this variable
//
// $headers = array(
// 'Content-Type: "application/soap+xml"; charset="utf-8"',
// 'Content-Length: '.strlen($body),
// 'SOAPAction: "http://tempuri.org/IServiceTransaction/CreateTransaction"'
// );
//
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_TIMEOUT, 60);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch, CURLOPT_USERAGENT, "PHP-SOAP/5.5.9-1ubuntu4.14");
//
//// Stuff I have added
// curl_setopt($ch, CURLOPT_POST, true);
// curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
//
// $data = curl_exec($ch);
// dump($data);
// dump(curl_error($ch));
// dump($ch);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment