1

我正在尝试使用 http_request2 ( https://documenter.getpostman.com/view/10111708/TVmlCykr ) 设置安全 pasarela 使用 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.

我确认我已经安装了 pear pear run-tests -r Running 0 tests TOTAL TIME: 00:00 0 PASSED TESTS 0 SKIPPED TESTS 我的文件:

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();

但我不断收到错误:

[php7:error] [pid 2653] [client 190.x.105.x:54x7] PHP 致命错误:未捕获的错误:在 /var/www/html/safetyPay.php:3\ 中找不到类“http\Client” nStack 跟踪:\n#0 {main}\n 在第 3 行的 /var/www/html/safetyPay.php 中抛出

4

0 回答 0