Fatal error: Class 'HttpClient' not found
jacobcovenas opened this issue · 1 comments
hi, please kindly help. I am trying to set up a safety pasarela using http_request2
(https://documenter.getpostman.com/view/10111708/TVmLCykr)
Use composer
/usr/local/bin/composer info
guzzlehttp/guzzle 7.2.0 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.4.0 Guzzle promises library
guzzlehttp/psr7 1.7.0 PSR-7 message implementation that also provides common utility methods
pear/http_request2 v2.4.2 Provides an easy way to perform HTTP requests.
pear/net_url2 v2.2.2 Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.
pear/pear_exception v1.0.1 The PEAR Exception base class.
transfer class for PHP
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-message 1.0.1 Common interface for HTTP messages
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
I verified that I have pear installed
pear run-tests -r Running 0 tests TOTAL TIME: 00:00 0 PASSED TESTS 0 SKIPPED TESTS
my file:
<?php
require_once DIR . '/vendor/autoload.php';
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://sandbox-mws.safetypay.com/mpi/api/v1/online-payment-requests');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
"sales_amount": {
"value": 50,
"currency_code": "USD"
},
"shopper": {
"phone": {
"phone_type": "Mobile",
"phone_country_code": "51",
"phone_number": "9999999999",
"is_sms_enabled": false
},
"shopper_type": "Person",
"first_name": "Joe",
"last_names": "Doe"
},
"payment_ok_url": "https://www.safetypay.com/success.com",
"payment_error_url": "https://www.safetypay.com/error.com",
"filter_payment_by": "Channel(OL)",
"merchant_set_pay_amount": false,
"expiration_time_minutes": 120,
"language_code": "EN",
"custom_merchant_name": "M_TEST",
"merchant_sales_id": "FirstTest",
"requested_payment_type": "StandardorBoleto",
"application_id": "1",
"transaction_email": "jdoe@test.com",
"send_email_shopper": false,
"request_datetime": "2020-09-16T21:06:16.61"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'X-Api-Key' => '5edd536ed98449692ef24e6883ebb95d',
'X-Version' => '20200803'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
But I keep getting the error:
[php7:error] [pid 2653] [client 190.x.105.x:54x7] PHP Fatal error: Uncaught Error: Class 'http\\Client' not found in /var/www/html/safetyPay.php:3\nStack trace:\n#0 {main}\n thrown in /var/www/html/safetyPay.php on line 3
please help me
There is no http\Client
and / or http\Client\Request
class in HTTP_Request2 package. See the docs for proper usage: https://pear.php.net/manual/en/package.http.http-request2.php