0
votes

I'm trying to implement the Sagepay payment gateway, but i'm having an issue with the notification url. This is how i'm generating it:

request.NotificationUrl = string.Format(
    "{0}Notification.aspx?orderid={1}&vendortxcode={2}&amount={3}",
    SagePaySettings.SiteFqdn,
    Request.QueryString["orderid"],
    request.VendorTxCode,
    txtOnlineDepositAmount.Text.Trim()
);

When I submit a payment, within their my sagepay portal it reports the notification url as:

Callback URL: https://www.****.uk/Notification.aspx?orderid={3a35f950-5b7c-e311-8437-12d0d8a96a66} 

It's missing all the parameters after orderid.

I submitted a ticket and they said:

"Your Notification URL should only respond with a Status, RedirectURL and optionally a StatusDetail field. No other HTML, headers, comments or text should be included either before or after these fields. Sage Pay will treat all such text as an error and fail the transaction. To answer your question ampersands can not be used as they do not conform to RFC1738 URL Encoding. Please note we are not developers here at Sage Pay however we will try to assist you in troubleshooting your issues. Here's a link to our Server Protocol Guide along with a link to StackOverflow a professional web developers forum"

I may have misunderstood, but I thought by using

& 

for the ampersands that would be correct.

Has anyone come across this?

I can probably get around it by having a single parameter and seperating the parameters with a pipe or something. But it would be nice to do it properly with individual parameters.

1

1 Answers

1
votes

You should be using URL encoding instead of entity character encoding.

Its being stripped of everything after & because the & character in & amp; separates parameters in the registration post body. If you want your parameter to contain & character you should replace it with %26, or just use a library that will perform the conversion for you.

Difference between Url Encode and HTML encode

Regards, Adam