Make php post to service rest c #

0

Good afternoon, I hope someone can guide me.

I am doing a payment integration. For the application I am using angular and javascript. As for my services, use rest c #, get json. The external page that I do not have control of, uses php.

From my page I submit (a) to an external page where I fill the data such as card number, security code, etc. When I finish, I click on pay and in turn, that page verifies the data of the card and in theory, I should redirect to my page, indicating whether the payment was accepted or not (sending me transaction parameters).

The submit of which I spoke previously uses a form with post, in which it sent a "MerchantResponseURL" (Webhook where the parameters of the transaction will be reported).

When the redirect to my page starts, a php post is done to my MerchantResponseURL (which is currently a web service rest in c #). That post that I I do not have control, it is also done with a submit like this link: link . The problem is that when I receive the post, the web service can not accept the type of data that comes in that post. I have requested that the post I receive have a content type json, but they refuse to include it. What could I do about it?

Thank you for your attention, I hope you can help me.

    
asked by Blanca 17.08.2017 в 19:23
source

1 answer

0

A web api has no problem working with a form, the test that you did was the following:

HTML form:

<form action="/api/MerchantResponseURL" method="post">
  First name:<br>
  <input type="text" name="firstname" value="Mickey">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse">
  <br><br>
  <input type="submit" value="Submit">
</form>

When you submit your post, it is similar to:

  

POST link HTTP / 1.1   Content-Type: application / x-www-form-urlencoded Accept:   text / html, application / xhtml + xml, application / xml; q = 0.9, image / webp, image / apng, / ; q = 0.8   Referer:    link   Accept-Encoding: gzip, deflate, br Accept-Language:   is, in, q = 0.8, fr; q = 0.6, en-US; q = 0.4 Cookie:   __gads = ID = 5c38ba44426c9aeb: T = 1479934000: S = ALNI_MYIippZvxSX1zRedEMC9x4aRPxJMA;   ezouid_34890 = 1263373480; __qca = P0-402894760-1491317446847;   ezosuigeneris = 2c5eceef407b0d5880b5a3aa6656efb0;   __utma = 119627022.1866741841.1421853006.1492528048.1492817010.14; __utmz = 119627022.1492817010.14.13.utmcsr = google | utmccn = (organic) | utmcmd = organic | utmctr = (not% 20provided);   _ga = GA1.2.1866741841.1421853006 Host: localhost: 61789 Content-Length: 31

     

firstname = Mickey & lastname = Mouse

and the definition of the API driver is:

public class MerchantResponseURLController : ApiController
{
    [HttpPost]
    public HttpResponseMessage Post([FromBody]Elemento x)
    {
        HttpResponseMessage response = 
        Request.CreateResponse(HttpStatusCode.OK);

        return response;
    }

}

The element class:

public class Elemento
{
    public string firstname { set; get; }
    public string lastname { set; get; }

}
    
answered by 18.08.2017 в 20:00