0

I am implementing a new payment system. This new payment system is a 3rd party that requires a POST request sent a long with some information that will then open a payment screen provided by the third party. After the payment is made they will send a Post-Back so we can know that user made a payment. As of now I am more worried about getting a POST and re-direct to go through.

Basically I need to redirect the user using a POST request that also contains some information. This action needs to happen after a button click.

I have tried using .redirect() however this is a GET request so the payment site doesn't expect it.

I found this on Stack Overflow and have implemented A, B, and C and there was no luck. The page will refresh like it's trying to do something but never re-directs the user.

As of now this is how it's trying to handle the action:

string SomeServer = "serverWeAreGoingTo";

var values = new Dictionary<string, string>
{
  { "param1", "00" },
  { "param2", "01" }
};

newTestMethod(SomeServer, values);
public async void newTestMethod(string helper, Dictionary<string, string> data)
{
   var content = new FormUrlEncodedContent(data);

   var response = await client.PostAsync(helper, content);

   var responseString = await response.Content.ReadAsStringAsync();
}
Tr3s3
  • 11
  • 2

1 Answers1

0

Create a HTML form with third-party URL in action and add the other data as hidden form fields.

<form action="<url_to_pg>" method="POST">
  <div>
    <label for="say">What greeting do you want to say?</label>
    <input name="say" id="say" value="Hi" />
  </div>
  <div>
    <label for="to">Who do you want to say it to?</label>
    <input name="to" id="to" value="Mom" />
  </div>
  <div>
    <button>Send my greetings</button>
  </div>
</form>
Mata Prasad Chauhan
  • 554
  • 2
  • 6
  • 15