I've incorporated Payfast via their custom integration. I'm on the last step to validate the request with Payfast by making a request to the url: https://sandbox.payfast.co.za/eng/query/validate
.
string concat = "pf_payment_id=185322&payment_status=COMPLETE&item_name=ON_123&amount_gross=261.50&merchant_id=00030878...etc";
using (var httpClient = new HttpClient())
{
string jsonString = JsonConvert.SerializeObject(concat);
HttpContent content = new StringContent(jsonString, Encoding.UTF8, "application/json");
var url = _configuration["Payment:Payfast:ValidateUrl"];
using (var response = await httpClient.PostAsync(url, content))
{
}
}
Response:
{StatusCode: 405, ReasonPhrase: 'Method Not Allowed', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Server: nginx/1.19.6
Date: Thu, 21 Sep 2023 18:52:08 GMT
Cache-Control: no-cache, private
Via: 1.1 google
Strict-Transport-Security: max-age=63072000 ; includeSubDomains
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Content-Type: text/html; charset=UTF-8
Content-Length: 630
Allow: GET, HEAD
}}
According to their documentation the method is POST. What am I doing wrong?
First add
httpclient
services to your projectNext use dependency injection
And send data like this :
Update
If you must send json can use this code :
Any where is unclear call me.