Why i am getting the following
error
Warning: SoapClient::__doRequest(): Unable to find the wrapper "https"
- did you forget to enable it when you configured PHP
What is my mistake?
My code is following
$config = parse_ini_file('ebay.ini', true);
$site = $config['settings']['site'];
$compatibilityLevel = $config['settings']['compatibilityLevel'];
$dev = $config[$site]['devId'];
$app = $config[$site]['appId'];
$cert = $config[$site]['cert'];
$token = $config[$site]['authToken'];
$location = $config[$site]['gatewaySOAP'];
// Create and configure session
$session = new eBaySession($dev, $app, $cert);
$session->token = $token;
$session->site = 203; // 0 = US;
$session->location = $location;
// Make an AddItem API call and print Listing Fee and ItemID
try {
$client = new eBaySOAP($session);
$PrimaryCategory = array('CategoryID' => 357);
$Item = array('ListingType' => 'Chinese',
'Currency' => 'INR',
'Country' => 'US',
'PaymentMethods' => 'PaymentSeeDescription',
'RegionID' => 0,
'ListingDuration' => 'Days_3',
'Title' => 'The new item',
'Description' => "It's a great new item",
'Location' => "San Jose, CA",
'Quantity' => 1,
'StartPrice' => 24.99,
'PrimaryCategory' => $PrimaryCategory,
);
$params = array('Version' => $compatibilityLevel, 'Item' => $Item);
$results = $client->AddItem($params);
// The $results->Fees['ListingFee'] syntax is a result of SOAP classmapping
print "Listing fee is: " . $results->Fees['ListingFee'] . " <br> \n";
print "Listed Item ID: " . $results->ItemID . " <br> \n";
print "Item was listed for the user associated with the auth token code herer>\n";`enter code here`
} catch (SOAPFault $f) {
print $f; // error handling
}
Thanks in advance
Murali
You have to add (or uncomment it) extension=php_openssl.dll; to your php.ini file.
Related
Hi Stackoverflow community,
I am attempting to implement the "convertPaymentMethodToToken" method from USAePay soap api documentations. For the function to work, it is required to fetch the customer number from the UsaEpay acct, and it generates a Method ID through a "getCustomer" request, that will be used for the conversion. However, the implementation works only for a single customer and fails when I try to process multiple customers at once. The error message I receive is: "An error occurred while fetching details of customer 'customer1': 40030: Customer Not Found......".
I have a large customer database of over 20,000 customers, and my goal is to convert each of their payment methods to tokens efficiently, without having to perform individual conversions for each customer. The USAePay documentation only provides information on how to implement the feature for a single customer.
here is my code by getting Method ID for a single customer
<?php
$wsdl = "https://secure.usaepay.com/soap/gate/INBGTWZC/usaepay.wsdl";
$sourceKey = "your soruce key";
$pin = "1234";
function getClient($wsdl) {
return new SoapClient($wsdl, array(
'trace' => 1,
'exceptions' => 1,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
)
)
));
}
function getToken($sourceKey, $pin) {
$seed = time() . rand();
return array(
'SourceKey' => $sourceKey,
'PinHash' => array(
'Type' => 'sha1',
'Seed' => $seed,
'HashValue' => sha1($sourceKey . $seed . $pin)
),
'ClientIP' => $_SERVER['REMOTE_ADDR']
);
}
$client = getClient($wsdl);
$token = getToken($sourceKey, $pin);
try {
$custnum='customer number';
print_r($client->getCustomer($token,$custnum));
} catch (Exception $e) {
// Code to handle the exception
echo "An error occurred: " . $e->getMessage();
}
?>
and here the successful response I get back (with the Method ID included)
Successful response.
here Is the code I'm trying it to do with multiple customers
<?php
$wsdl = "https://sandbox.usaepay.com/soap/gate/43R1QPKU/usaepay.wsdl";
$sourceKey = "your api key";
$pin = "1234";
function getClient($wsdl) {
return new SoapClient($wsdl, array(
'trace' => 1,
'exceptions' => 1,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
)
)
));
}
function getToken($sourceKey, $pin) {
$seed = time() . rand();
return array(
'SourceKey' => $sourceKey,
'PinHash' => array(
'Type' => 'sha1',
'Seed' => $seed,
'HashValue' => sha1($sourceKey . $seed . $pin)
),
'ClientIP' => $_SERVER['REMOTE_ADDR']
);
}
$client = getClient($wsdl);
$token = getToken($sourceKey, $pin);
$custnums = array();
for ($i = 1; $i <= 3; $i++) {
$custnums[] = 'customer' . $i;
}
$methodIDs = array();
foreach ($custnums as $custnum) {
try {
$result = $client->getCustomer($token, $custnum);
$methodID = $result[0]->MethodID;
$methodIDs[] = $methodID;
error_log("Method ID for customer $custnum: $methodID");
} catch (Exception $e) {
echo " An error occurred: " . $e->getMessage();
}
}
?>
I've already been working on it all day,
Can anyone help me with this?
Thanks in advance
I am trying to create a test pickup request using Estes web services. This particular service requires Basic Authentication using my login credentials. However, I can't seem to figure out how to perform the authentication using PHP and SoapClient. I keep getting the following error:
PHP Fatal error: Uncaught SoapFault exception: [soapenv:Client] [ISS.0088.9164] Access to WSDescriptor estesrtpickup.base.ws.provider.soapws:pickupRequestSSL denied.
My last attempt I tried to pass the credentials into WSDL address, but to no avail. Like so:
$client_pickup = new SoapClient('https://USERNAME:PASSWORD#apitest.estes-express.com/tools/pickup/request/v1.0?wsdl');
Here is my current block of PHP code for the Pickup Webservice:
public static function estesFreightPickupRequest($option) {
self::$ShipToCity = preg_replace("/[^a-zA-Z0-9\s]/", "", $option->ShipToCity);
self::$ShipToStateProvinceCode = preg_replace("/[^a-zA-Z0-9\s]/", "", $option->ShipToStateProvinceCode);
self::$ShipToPostalCode = (string)$option->ShipToPostalCode;
self::$ShipToPostalCode = substr(trim(self::$ShipToPostalCode), 0, 5);
self::$ShipToPostalCode = str_pad(self::$ShipToPostalCode, 5, "0", STR_PAD_LEFT);
self::$ShipToAddressLine = preg_replace("/[^a-zA-Z0-9\s]/", "", $option->ShipToAddressLine);
$Weight = $option->weight;
$d = strtotime("tomorrow");
$request_date = date("Y-m-d", $d);
$path_to_wsdl_pickup = "https://apitest.estes-express.com/tools/pickup/request/v1.0?wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client_pickup = new SoapClient('https://USERNAME:PASSWORD#apitest.estes-express.com/tools/pickup/request/v1.0?wsdl');
ini_set("soap.wsdl_cache_enabled", "0");
$header_pickup = new SoapHeader('http://www.estes-express.com/tools/pickup');
$client_pickup->__setSoapHeaders($header_pickup);
//Enter the body data for WSDL
$request_pickup = array(
'requestNumber' => date("Y-m-d"),
'shipper' => array(
'shipperName' => 'COMPANY NAME',
'accountCode' => 'ACCOUNT CODE',
'shipperAddress' => array(
'addressInfo' => array(
'addressLine1' => '1620 TEST CT',
'city' => 'SOMETOWN',
'stateProvince' => 'MO',
'postalCode' => '65222',
'countryAbbrev' => 'US'
)
)
),
'requestAction' => 'LL',
'pickupDate'=> date("Y-m-d"),
'pickupStartTime' => '1200',
'pickupEndTime' => '1500',
'totalPieces' => '1',
'totalWeight' => '100',
'totalHandlingUnits' => '1',
'whoRequested' => 'S'
);
try {
$response_pickup = $client_pickup->createPickupRequestWS($request_pickup);
//Error log the request and response
error_log($client->__getLastRequest());
error_log($client->__getLastResponse());
//$rateReply = $response->quoteInfo->quote->pricing->totalPrice;
//Get the response data
$result_array = array();
$result_array['totalPrice'] = $estes_total_rate_amount;
return $result_array;
} catch (SoapFault $exception) {
error_log('ERROR LOG::' . $exception, $client);
}
}
I have been attempting to get this to work for a while. I am hoping someone familiar with it happens to run across the question and can explain WHY this isnt working and what is wrong with the code. Estes has been useless in helping thus far. They have provided me a bunch of information but none of it works.
The code below is returning this error
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR:
Encoding: object has no 'requestID' property in
/home/xxxxxxxxxx/public_html/inc/estes/estesapi.php:41 Stack trace: #0
/home/xxxxxxxxxx/public_html/inc/estes/estesapi.php(41):
SoapClient->__call('getQuote', Array) #1 {main} thrown in
/home/xxxxxxxxxx/public_html/inc/estes/estesapi.php on line 41
$client = new SoapClient("https://www.estes-express.com/tools/rating/ratequote/v3.0/services/RateQuoteService?wsdl");
$request_object = array(
"header"=>array(
"auth"=>array(
"user"=>"xxxxxxxxx",
"password"=>"xxxx",
)
),
"rateRequest"=>array(
"requestID"=>"abc",
"account"=>"############",
"originPoint"=>array(
"countryCode"=>"US",
"postalCode"=>"28366",
"city"=>"Newton Grove",
"stateProvince"=>"NC",
),
"destinationPoint"=>array(
"countryCode"=>"US",
"postalCode"=>"28334",
),
"payor"=> "S",
"terms"=> "P",
"stackable"=> "N",
"baseCommodities"=>array(
"commodity"=>array(
"class"=>"50",
"weight"=>"1200",
)
)
)
);
$result = $client->getQuote($request_object);
var_dump($result);
print_r($result);
I cant figure out why RequestID isnt being passed into the soap request.
This is our Estes Soap call. See if you see anything in it that helps:
// define transaction arrays
$url = "http://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl";
$username = 'xxxxxxxx';
$password = 'xxxxxxxx';
// setting a connection timeout of five seconds
$client = new SoapClient($url, array("trace" => true,
"exceptions" => true,
"connection_timeout" => 5,
"features" => SOAP_WAIT_ONE_WAY_CALLS,
"cache_wsdl" => WSDL_CACHE_NONE));
$old = ini_get('default_socket_timeout');
ini_set('default_socket_timeout', 5);
//Prepare SoapHeader parameters
$cred = array(
'user' => $username,
'password' => $password
);
$header = new SoapHeader('http://ws.estesexpress.com/ratequote', 'auth', $cred);
$client->__setSoapHeaders($header);
$params = array(
"requestID" => "xxxxxxxx",
"account" => "xxxxxxxx",
"originPoint" => array('countryCode' => 'US', 'postalCode' => $fromzip),
"destinationPoint" => array('countryCode' => 'US', 'postalCode' => $shipzip),
"payor" => 'T',
"terms" => 'PPD',
"stackable" => 'N',
"baseCommodities" => array('commodity' => $comArray ),
"accessorials" => array('accessorialCode' => $accArray)
);
// remove accessorials entry if no accessorial codes
if(count($accArray) == 0){
$params = array_slice($params, 0, 8); // remove accesorials entry
}
// call Estes API and catch any errors
try {
$reply = $client->getQuote($params);
}
catch(SoapFault $e){
// handle issues returned by the web service
//echo "Estes soap fault<br>" . $e . "<br>";
$edit_error_msg = "Estes quote API timed out or failed to return a quote";
return "0.00";
}
catch(Exception $e){
// handle PHP issues with the request
//echo "PHP soap exception<br>" . $e . "<br>";
$edit_error_msg = "Estes quote API timed out or failed to return a quote";
return "0.00";
}
unset($client);
ini_set('default_socket_timeout', $old);
// print_r($reply);
In my wp project, I am using Assently for e-signature implementation. Though I have an account and created a pdf form file to be filled by the user I just am not able to proceed a bit. I am finding documentation not clear.
Also, I am not clear about what needs to be done so that the user will be shown form to process the transaction.
So, any help/suggestions to proceed forward is appreciated.
I have tried the following based on assently-laravel. But it's asking me to login. What is an error here?
Code:
define('ASSENTLY_DEBUG', true);
define('ASSENTLY_KEY', 'key');
define('ASSENTLY_SECRET', 'secret-generated');
include_once('assently/Assently.php');
$assently = new Assently();
$assently->authenticate(ASSENTLY_KEY, ASSENTLY_SECRET);
$url = 'https://test.assently.com/api/v2/createcasefromtemplate';
$default = array(
'Id' => '5a0e0869-' . rand(1111, 9999) . '-4b79-' . rand(1111, 9999) . '-466ea5cca5ce'
);
$data = array(
'auth' => $assently->auth(),
'templateId' => '0e004e2b-b192-4ce2-8f47-d7a4576d7df6',
'newCaseId' => '5a0e0869-' . rand(1111, 9999) . '-4b79-' . rand(1111, 9999) . '-466ea5cca5ce',
'agentUsername' => ''
);
$data = array(
'json' => $data
);
$options = array(
'http' => array(
'header' => "Content-type: application/json; charset=utf-8\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo '<pre>';
print_r($result);
die;
create this class inside assently folder
use Assently\AssentlyCase;
use Exception;
class CustomAssentlyCase extends AssentlyCase
{
public function createFromTemplate($data)
{
$default = [
'newCaseId' => '5a0e0869-'.rand(1111, 9999).'-4b79-'.rand(1111, 9999).'-466ea5cca5ce'
];
$json = array_merge($default, $data);
try{
$response = $this->client->post($this->url('createcasefromtemplate'), [
'auth' => $this->assently->auth(),
'json' => $json
]);
}catch(Exception $e){
print_r($e->getMessage());
}
return $response;
}
}
Use
define('ASSENTLY_DEBUG', true);
define('ASSENTLY_KEY', 'key');
define('ASSENTLY_SECRET', 'secret-generated');
include_once('assently/Assently.php');
include_once('assently/CustomAssentlyCase.php');
$assently = new Assently();
$assently->authenticate(ASSENTLY_KEY, ASSENTLY_SECRET);
$data = array(
'templateId' => '0e004e2b-b192-4ce2-8f47-d7a4576d7df6',
'newCaseId' => '5a0e0869-'.rand(1111, 9999).'-4b79-'.rand(1111, 9999).'-466ea5cca5ce',
'agentUsername' => 'agentUsername' // PUT your agent username here it is required
);
$customAssentlyCase = new CustomAssentlyCase($assently);
$result = $customAssentlyCase->createFromTemplate($data);
print_r($result);
Try this, though not tested but should work. Good luck.
My friends, I would like to know what I am doing wrong in my code in which it continues giving error of deserilization. When I set all parameters correctly it shows a class error (stdClass). Here is a wsdl print in SOAP UI and PHP code. I left the comment the options I have already tried.
<pre>
$soapParams = array('login' => 'master',
'password' => 'master',
'authentication' => SOAP_AUTHENTICATION_BASIC,
'trace' => 1,
'exceptions' => 0 );
$client = new SoapClient("http://189.60.63.128:8061/wsDataServe/MEX?wsdl",$soapParams);
//$result = $client->__soapCall("ReadView",$params);
//$result = $client->__soapCall("ReadView",array('DataServerName' => 'EduAlunoData', 'Filtro'=>'?', 'Contexto'=>'?'));
//$result=$client->__call("ReadView", ['ReadView' => ['DataServerName' => 'EduAlunoData', 'Filtro' => '1=1','Contexto'=>'?']]);
$result=$client->__soapCall("ReadView", ['DataServerName' => "EduAlunoData", 'Filtro' => '1=1','Contexto'=>'?']);
print $result;
</pre>
Image of the WSDL from SOAP UI
I solved the Problem:
<?php
$soapParams = array('login' => 'master',
'password' => 'master',
'authentication' => SOAP_AUTHENTICATION_BASIC,
'trace' => 1,
'exceptions' => 0
);
$params = array();
$client = new SoapClient("http://200.30.20.120:8051/wsDataServer/MEX?wsdl", $soapParams);
echo "Connected";
$params = array('DataServerName' => 'EduAlunoData', 'Filtro'=>'1=1', 'Contexto'=>'?');
var_dump($params);
$result = $client->ReadView($params);
echo "Response:\n" . $client->__getLastResponse() . "<br><br>";
//echo "<br>";
//echo "REQUEST:\n" . $client->__getLastRequest() . "<br><br>";
//echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "<br><br>";
//echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "<br><br>";
//var_dump($client->__getTypes());
//var_dump($client->__getFunctions());
//print $result;
?>