+ Start a Discussion
Amol ChAmol Ch 

VF page to get the data posted by external webservice

I've a force.com website, Now I'm integrating 2checkout(www.2checkout.com) payment gateway with my website.

As per this documentation I'm able to send the correct data to 2checkoout API. 2checkout is processing my payment on their  side. As per this I've mentioned the my VF page redirect URL on 2checkout , so i can redirect to back to my website after transaction complete.

After completing transaction on 2checkout, it will redirecting to my website at same time they sending the transaction parameter.

Now I've to get that transaction paramenter to my VF page. So I can store it in salesforce. How to get the parameter in VF page.

I've try to implement the below: 
VF page
<apex:page controller="paymentstatuscontr" action="{!SearchEvent}">
   <apex:outputText value="{!response}"/> <br/>
Contoller :
public class paymentstatuscontr {
public string a  {get; set;}
public string b  {get; set;}
public string response { get; set;}
public HttpResponse op { get; set;}

public void  SearchEvent() {
    System.debug(' ------ ');
    a='test data';
    // Instantiate a new http object
    Http h = new Http();
    // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
    HttpRequest req = new HttpRequest();
    req.setHeader('Content-Type', 'application/json');
    HttpResponse res = h.send(req);
    System.debug(' ------ '+res);
    System.debug(' ------ '+res.getbody());
    /// tryied this but getting error System.CalloutException: no protocol Error    Salesforce call     out 

    if (res.getStatusCode() == 302) {
    res = new Http().send(req);
    response =res.getbody();
    response =res.getbody();
    op = res;
https://sandbox.2checkout.com/checkout/purchase  This is the URL for 2 Checkout  where I'm redirecting from 2chekout to my website. Please check below website. 
User-added image

Below is the output of VF page:
User-added image

It's showing me 302 Found.
Is I'm going by correct way or in wrong way.

Please Suggest the solution.

I've created the PHP page as putted that php page as redirect page, in this case I'm getting the all parameter on PHP page. But got stuck by using VF Page.
NagendraNagendra (Salesforce Developers) 
Hi Amol,

May I suggest you please check with below link from the forums community which will point you further in the right direction with the above requirement. Please let us know if this helps.

Mark this as solved if it's resolved.