客户端错误:405 方法不允许将 remita 与 Laravel 和 livewire 集成

问题描述 投票:0回答:1

请我需要帮助,我不知道我做错了什么。 通过邮递员可以访问 API,但在我的 laravel 应用程序中不起作用。

//...........
Client error: `POST https://remitademo.net/remita/exapp/api/v1/send/api/echannelsvc/merchant/api/paymentinit` resulted in a `405 Method Not Allowed` response:

{"responseData":"{\"status\":null,\"responseCode\":\"405\",\"responseMsg\":\"Request method \u0027GET\u0027 not supporte (truncated...)
//.................

$client = new Client();
        $headers = [
            'Content-Type' => 'application/json',
            'Authorization' => "remitaConsumerKey={$merchantId},remitaConsumerToken={$hash}"
        ];

    $body = [
              "serviceTypeId"=>$serviceTypeId,
              "amount"=>$amount,
              "orderId"=>$orderId,
              "payerName"=> Auth::user()->surname.' '.Auth::user()->firstname,
              "payerEmail"=> Auth::user()->email,
              "payerPhone"=>Auth::user()->phone,
              "description"=>"Payment for Septmeber Fees"
            ];
    
    $request = new Request('POST', 'https://remitademo.net/remita/exapp/api/v1/send/api/echannelsvc/merchant/api/paymentinit', $headers, json_encode($body));
    
    $res = $client->sendAsync($request
);
php laravel payment-gateway laravel-livewire
1个回答
0
投票

根据 Remita API

official-docs
,API 的响应应收集为(因为它是异步请求)。

$res = $client->sendAsync($request)->wait();
echo $res->getBody();

或者,您也可以按照 Guzzle Documentation 使用此方法。

// Send an asynchronous request.
$res= $client->sendAsync($request)->then(function ($response) {
    echo 'I completed! ' . $response->getBody();
});
$res->wait();

N:B :- 另请注意,apiHash 是连接

SHA-512
+
merchantId
+
serviceTypeId
+
orderId
+
totalAmount
apiKey
加密。

尝试一下并告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.