0

I have an ASP.NET site and need to post some hidden form fields to SagePay so that my customers can pay for goods. I am using the following method to do this:

<input type="hidden" name="VPSProtocol" value="2.23" />
<input type="hidden" name="Currency" value="gbp" />
<input type="hidden" name="TxType" value="PAYMENT" />
<input type="hidden" name="Vendor" value="myvendorname" />
<input type="hidden" runat="server" id="crypt" name="Crypt" value="@<encrypted string>" />

<asp:Button ID="Button1" runat="server" Text="Pay Now" PostBackUrl="https://live.sagepay.com/gateway/service/vspform-register.vsp"/>

Now, If I use this code in a standard ASP.NET form, this works fine - SagePay accepts the posted information and continues with the payment process. However, if I use the same code inside a content page with a master page, Sagepay displays the following error screen:

5030 : We could not process your message, please check your integration settings or contact the support team.

It seems as if the hidden fields are losing their value because of the master page.

Could anyone tell me what could be happening here and if there is anything I can do to rectify the situation. I need to use the SagePay Form method and I need to use a masterpage.

John P
  • 339
  • 1
  • 4
  • 19
  • I haven't used webforms for a while but from memory by default it changes the names of your elements based on their container to allow navigation and identification server side: http://msdn.microsoft.com/en-us/library/1d04y8ss%28VS.100%29.aspx - if you view source on your form, is this happening? – Carl Nov 15 '14 at 08:43
  • Hi @Carl. Many, many thanks. You are absolutely right! I used Fiddler to view what was being passed through and spotted that the 'crypt' field name was being renamed with a 'CT' type prefix. If you want to add that as an answer I will mark it accordingly. – John P Nov 17 '14 at 09:28
  • Hi John, glad to be of help. Have made my comment an answer. Thanks – Carl Nov 17 '14 at 10:09

1 Answers1

2

I haven't used webforms for a while but from memory by default it changes the names of your elements based on their container to allow navigation and identification server side: MSDN documentation here.

This means that your posted values are not under the name you expect them to be.

Carl
  • 2,285
  • 1
  • 16
  • 31
  • To get around this problem, I simply removed the runat='server' attribute of the 'Crypt' field and then pulled the value I needed from a property set in the code behind. An example of this can be seen here http://stackoverflow.com/a/2325645/213667 – John P Nov 17 '14 at 11:06