Search code examples
iphoneiosios5checkoutuiweb

iOS checkout for website


I'm building an iPhone app version of a website that sells tickets online. I'm trying to re-implement the checkout process on iOS without using a UIWebView, passing around some variables (# of tickets, date, etc...) and just doing the final HTTP request to handle payment.

The problem is that I don't know the structure of the request that makes the final purchase. What should I do to reverse engineer this?

More importantly, is there a better way to modify a web checkout process for the iPhone screen?


Solution

  • Visit this ticket-selling website's website and go all the way to the final screen before the payment is actually made. Then, take a look at all of the inputs in the HTML that are there and send a request with that data. If jQuery is on their webpage, it is really easy. Open the developer tools, go to the console where you can type commands, and just type $('input, textarea') and it will show you a list of all of them.

    For example, if the page has a form like this.

    <form method="post" action="makepayment.php">
        <input name="numTickets" />
        <input name="date" />
    </form>
    

    Then, you'll need to POST the numTickets and date to the makepayment.php page.

    This is the data that you need to send in the HTTP request. There is a nice library that you can read up on here: http://allseeing-i.com/ASIHTTPRequest/. It lets you do something like this:

    NSURL *url = [NSURL URLWithString:@"https://ticketsellers.com/makepayment.php"];
    ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
    [request setPostValue:@"2" forKey:@"numTickets"];
    [request setPostValue:@"12/31/2012" forKey:@"date"];
    [request startSynchronous];