AnthonyH
AnthonyH

Reputation: 11

What is the callback URL after calling repeat.vsp when using Form Integration?

I'm trying to do repeat payments with Form Integration in Sagepay (now Opayo).

From an earlier problem posted on here, I get that the securitykey is needed but is not returned in the Form call, so an additional call needs to be made to the getTransactionDetails command.

I have the securitykey and can now make a call to https://test.sagepay.com/gateway/service/repeat.vsp to initiate the repeat payment. However, the documentation does not say where the response to that call goes. I assume therefore, that it would go to the NotificationURL that is set up with a payment when using the Server or Direct integrations. Since I'm using Form, this is not set.

The question is, is there any way of capturing the response to the https://test.sagepay.com/gateway/service/repeat.vsp call if the initial payment was created using Form integration?

I suppose the second question is, has anybody successfully made repeat payments work with Sagepay Form integration?

Upvotes: 1

Views: 259

Answers (1)

ubik404
ubik404

Reputation: 621

Not sure if this helps you and we didn't do repeat payments; but we are looking at releasing deferred payments and I think it is a similar approach.

How do you make the call to 'https://test.sagepay.com/gateway/service/repeat.vsp'?

Could you use a 'HttpWebRequest' to make the call then capture the direct response in 'HttpWebResponse'?

EG:

private static void DeferredSharedApiCall(Dictionary<string, string> data, string type, string url)
{
    string postData = string.Join("&", data.Select(x => $"{x.Key}={HttpUtility.UrlEncode(x.Value)}"));

    HttpWebRequest request = WebRequest.CreateHttp(url);
    request.Method = "POST";
    request.ContentType = "application/x-www-form-urlencoded";

    using (TextWriter tw = new StreamWriter(request.GetRequestStream()))
    {
        tw.Write(postData);
    }

    HttpWebResponse response = null;
    try
    {
        response = request.GetResponse() as HttpWebResponse;
    }
    catch (WebException ex)
    {
        //log.Error($"{type} Error, data: {postData}", ex);
    }
    catch (Exception ex)
    {
        //log.Error($"{type} Error, data: {postData}", ex); 
    }

    if (response != null)
    {
        using (TextReader tr = new StreamReader(response.GetResponseStream()))
        {
            string result = tr.ReadToEnd();
            //log.Info($"{type} Response: {Environment.NewLine}{result}");
        }
    }
}   

Upvotes: 0

Related Questions