title: Https 403 Forbidden Error In Flutter Dart API Integration PayFAST
body: <p>I am trying to integrate Payfast api with my app. In WebView I can pass requested data to given https address properly but when ıt came to https request side errors occur. Simply I passed the same data to same path. What is the problem, your help is really appreciated. Thanks for now</p>
  <p><a href="https://developers.payfast.co.za/docs#quickstart" rel="nofollow noreferrer">payfast</a></p>
  <p>Below code when I press the submit button it redirects proper payment page;</p>
  <pre><code>                  WebView(
  
                          initialUrl:  new Uri.dataFromString('''   &lt;!DOCTYPE html&gt; &lt;html&gt;
                          &lt;style&gt; 
                          input[type=button], input[type=submit], input[type=reset] {
    background-color: #FF0000;
    border: none;
    color: white;
    padding: 16px 32px;
    text-decoration: none;
    margin: 8px 4px;
    cursor: pointer;
  }
  &lt;/style&gt;
    &lt;body style=&quot;background-color:#ffffff;&quot;&gt;
      
  
  
   &lt;form action=&quot;https://sandbox.payfast.co.za/eng/process&quot; method=&quot;post&quot;&gt;
     &lt;input type=&quot;hidden&quot; name=&quot;merchant_id&quot; value=&quot;10022814&quot;&gt;
     &lt;input type=&quot;hidden&quot; name=&quot;merchant_key&quot; value=&quot;aemfu0aapxale&quot;&gt;
     &lt;input type=&quot;hidden&quot; name=&quot;amount&quot; value=&quot;$miktar&quot;&gt;
     &lt;input type=&quot;hidden&quot; name=&quot;item_name&quot; value=&quot;Test Product&quot;&gt;
     &lt;input type=&quot;submit&quot; value=&quot;PAY NOW&quot;&gt;
  &lt;/form&gt;
  
    &lt;/body&gt;
  
  
  
    &lt;/html&gt;
                            ''',
                              mimeType: 'text/html').toString(),
                          javascriptMode: JavascriptMode.unrestricted,
                          gestureNavigationEnabled: true,
             
                      ),
  </code></pre>
  <p>But 403 error Occur when http request is made.</p>
  <pre><code>    HttpClient httpClient = new HttpClient();
      HttpClientRequest request = await httpClient.postUrl(Uri.parse( &quot;https://sandbox.payfast.co.za/onsite/process&quot;));
      request.headers.set('accept' ,  'application/json');
      request.headers.set('merchant-id' ,  '10022814');
      request.headers.set('merchant_key' , 'aemfu0aapxale');
  
  
  
  
  
  //sbtu01@payfast.co.za
  //headers
  //request.headers.set('Accept' ,  'application/json');
      Map body = { 'merchant_id' : '10022814',
        'merchant_key' : 'aemfu0aapxale',
        'amount' : '100.00',
        'item_name' : '#000001'} ;
  
  //body
      request.add(utf8.encode(json.encode(body)));
  
  
  //response cevap
      HttpClientResponse response = await request.close();
      print(response.statusCode); // baglanti yapildi mi yapilmadi mi 200 ise yapildi
      String reply = await response.transform(utf8.decoder).join();
    
      httpClient.close();
      print(&quot;payfast ici odeme&quot;);
      print(reply);
  </code></pre>