SagePay Form - Classic ASP - Currency Field is missing using rijndael.asp - encryption

I am trying to add the Form Intergration SagePay payment gateway in Classic ASP. I have a working PHP version that I sourced from SO. I have translated it into VBSCRIPT, everything seems to be working fine but the encryption.
I am using all the same inputs as the PHP script so that the Cryptstring is exactly the same as the PHP Cryptstring before it is encrypted.
I've downloaded and using the Rijndael.asp & includes.asp files found here: Encrypting Crypt field using Classic ASP for SagePay Form Integration
But I continue to receive the following error:
Status: MALFORMED
Status Detail: 3045 : The Currency field is missing.
Cryptstring: VendorTxCode=542534345&ReferrerID=&Amount=200.00&Currency=GBP
&Description=Lorem ipsum&SuccessURL=http://www.testserver.co.uk/sagepaytest/success.php
&FailureURL=https://www.yoururl.org/fail.php&CustomerName=&CustomerEMail=&VendorEMail=
&SendEMail=&eMailMessage=&BillingSurname=Mustermann&BillingFirstnames=Max
&BillingAddress1=Bahnhofstr. 1&BillingAddress2=&BillingCity=Cologne&BillingPostCode=50650
&BillingCountry=DE&BillingState=&BillingPhone=&DeliverySurname=Mustermann
&DeliveryFirstnames=Max&DeliveryAddress1=Bahnhofstr. 1&DeliveryAddress2=
&DeliveryCity=Cologne&DeliveryPostCode=50650&DeliveryCountry=DE&DeliveryState=
&DeliveryPhone=&Basket=&AllowGiftAid=&ApplyAVSCV2=&Apply3DSecure=&BillingAgreement=
&BasketXML=&CustomerXML=&SurchargeXML=&VendorData=&ReferrerID=&Language=&Website=
I've tried manually adding certain fields into the crypt string, I've tried GET to anther page without the encryption to view the full output.
My encryption password is correct, I've double and triple checked it. Its entered in the includes.php file.
index.asp
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file="classes/includes.asp" -->
<!-- #include file="classes/sagepay.asp" -->
<% Set objSagePay=new SagePay %>
<% objSagePay.setCurrency("GBP") %>
<% objSagePay.setAmount(200) %>
<% objSagePay.setDescription("Lorem ipsum") %>
<% objSagePay.setBillingSurname("Mustermann") %>
<% objSagePay.setBillingFirstnames("Max") %>
<% objSagePay.setBillingCity("Cologne") %>
<% objSagePay.setBillingPostCode("50650") %>
<% objSagePay.setBillingAddress1("Bahnhofstr. 1") %>
<% objSagePay.setBillingCountry("de") %>
<% objSagePay.setDeliverySameAsBilling() %>
<% objSagePay.setSuccessURL("http://www.testserver.co.uk/sagepaytest/success.php") %>
<% objSagePay.setFailureURL("https://www.yoururl.org/fail.php") %>
<% Crypt=objSagePay.getCrypt() %>
<%= Crypt %>
<div id="content">
<form method="POST" id="SagePayForm" action="https://test.sagepay.com/gateway/service/vspform-register.vsp">
<input type="hidden" name="VPSProtocol" value= "3.00">
<input type="hidden" name="TxType" value= "PAYMENT">
<input type="hidden" name="Vendor" value= "vendorname">
<input type="hidden" name="Crypt" value= "<%= objSagePay.getCrypt() %>">
<input type="submit" value="continue to SagePay">
</form>
Any guidance would be appreciated.

I'm in the same boat. I can encrypt and decrypt perfectly with exactly the same results but when it is passed to Sagepay I get the error - Currency field is missing.
Update: I have managed to solve this error. Make sure in the 'includes.asp' that you change the existing line:
strEncryptionPassword="mcAX65PTadrrsKQ3"
to include the password that is in your original Sagepay 'includes.asp' file. Do not use the default password that comes with the download link in your post.

Related

Rails 4 button_to using helper improper redirection

I am building an index for one of my models. Instead of the usual table, I want to have two combo-boxes: one for selecting the object, the other for selecting the method (either edit or destroy). Upon clicking the submit button, I should be redirected to the appropriate method reference (e.g. admin_users/1/edit or admin_users/17/destroy). I have written a helper that constructs the url reference, but for some reason it does not work. when I use button_to I get redirected to the create method, when I use button_tag nothing works. Any ideas?
view code:
<%= form_tag do %>
<p id="notice"><%= flash[:notice] %></p>
<h1>Listing admin_users</h1>
<p><strong>select admin user</strong></p>
<%= select_tag(#req_id, options_from_collection_for_select(#admin_users, :id, :login)) %>
<br/>
<p><strong>select action</strong></p>
<%= select_tag(#oper, options_for_select([['edit'],['destroy']])) %>
<br/>
<%=button_tag 'go go!', get_path(#req_id,#oper) %>
<% end %>
helper code:
module AdminUsersHelper
def get_path(req_id,oper)
a=[req_id, oper].join("/")
["admin_users", a].join("/")
end
end
The default method for a form submit is POST. You'll need to change the method accordingly.
<%= form_tag( '/users/confirm', method: :get ) %>
May I suggest submitting with Javascript? You'll have a more dynamic control over the method of the submission. Take a look Here
so, eventually I went on the javascript solution, just as #Hassanin Ahmed suggested. Thanks for Helping!
<%= form_tag('/admin_users', id: "admin_users_menu") do %>
[...]
<font size=4>
<u>select user:</u>
</font>
<br>
<br>
<select id="admin_user_id" name="admin_user[id]">
<%= options_for_select #admin_users.collect{|user| [user.login, user.id]} %>
</select>
<br>
<br>
<font size=4> <u>select option:</u></font><br><br>
<input type="radio" checked name="select_op" value= "edit" > edit
<br>
<br>
<input type="radio" name="select_op" value= "delete" > delete
<br>
<br>
<%= submit_tag "go" %>
<br>
<br>
<% end %>
<script>
$(function (){
$("#admin_users_menu").submit(function() {return direct_me() })
})
function direct_me(){
//getting the admin_user id
var au_id=$('select').val()
//getting the desired method
var op=$('input[name=select_op]:radio:checked').val()
//making the default url
var u="admin_users/"+au_id
var f=$("form")
if(op=='edit'){
u=u+"/edit"
f.attr("method","GET")
}
else if(op=='delete'){
f.attr("method","POST")
f.append("<input type='hidden' name='_method' value='delete'>");
}
f.attr("action",u)
if(op=='delete') return confirm("Are you sure?")
}
</script>

asp #include, and error console for asp?

I'm trying to understand ASP but #include doesn't seem to work for some reason. I'm using IIS 7.5 (included with Win 7).
I have two .asp files in .../wwwroot/MyWeb/. I'm trying to #include FiboRecursive.asp in a file called test.asp. Both files work separately if I remove the #include. I have tried both virtual and file includes.
This is test.asp:
<%# language="javascript" %>
<html>
<body>
<p>
<% //Response.Write(Request.ServerVariables("http_user_agent"));%>
</p>
<p>
<%
var remoteAddr = Request.ServerVariables("REMOTE_ADDR");
remoteAddr += "";
if ((remoteAddr.length > 5) && (remoteAddr.substr(0,7)=="140.114") ) {
Response.Write("Hello there Tsingda student!");
}
else {
Response.Write("You're not a Tsingda student!");
}
%>
</p>
<form action="./FiboRecursive.asp" method="post">
<input type="submit" value="Calculate Fibonacci numbers!" />
</form>
<!--#INCLUDE FILE="fiborecursive.asp" -->
</body>
</html>
This is the code in FiboRecursive.asp:
<%# language="javascript" %>
<%
Response.Write("Let's calculate some Fibonacci numbers!");
%>
Edit: Another thing: I always use web developer tools (error console) in Firefox to check for errors in my code, but obviously that doesn't work too well when doing server side stuff. Any way to get some hints as to what's wrong from a console or similar?
You should not have the # command within your include file as this will (in ISS version 5.1 at least) result in the following error:
Error Type:
Active Server Pages, ASP 0141 (0x80004005)
The # command can only be used once within the Active Server Page.

Cannot call other action

I'm studying ASP MVC, and developping SportsStore (Create/Edit feature). When Create a product, Create action will view a Edit view, but when press Sudmit, it call action Create (Post), althrough I will set it call Edit action:
<% using (Html.BeginForm("Edit", "Admin", FormMethod.Post, new { enctype="multipart/form-data" }))
{%>
<%--<%= Html.ValidationSummary() %>--%>
<%--<%= Html.Hidden("ProductID") %>--%>
<p>Name: <%= Html.TextBox("Name")%>
<div><%= Html.ValidationMessage("Name")%></div>
</p>
<p>Description: <%= Html.TextArea("Description", null, 4, 20, null)%>
<div><%= Html.ValidationMessage("Description")%></div>
</p>
<p>Price: <%= Html.TextBox("Price")%>
<div><%= Html.ValidationMessage("Price")%></div>
</p>
<p>Category: <%= Html.TextBox("Category")%>
<div><%= Html.ValidationMessage("Category")%></div>
</p>
<p>
Image:
<% if (Model.ImageData == null)
{ %>
None
<% }
else
{ %>
<img src= "<%= Url.Action("GetImage", "Products", new {Model.ProductID}) %>" />
<% } %>
<div>Upload new image: <input type="file" name="file" id="file" /></div>
</p>
<input type="submit" value="Save" />
<%= Html.ActionLink("Cancel and return to list", "Index")%>
<% } %>
Please help me fix it
The code you have seems reasonable if you want it to post back to the Edit action. Your question is a bit confusing, but I'm going to assume that you want to reuse the view and have it post back to Create when rendered from Create and Edit when rendered from Edit. The easiest way is to simply omit the parameters from the BeginForm call. This will cause the form action to be set to the current controller and action, which would give you what you seem to want. An alternative would be to develop templates (display/editor) for the model but have separate views for Create/Edit that simply render the template Html.EditorFor( m => m, "ProductTemplate" ). This would allow you to customize the view -- perhaps the Create view requires you to upload an image? -- yet still reuse most of the code.

What is the difference between <% %> and <%= %>?

I tried to find the difference on Google.
BUT
I 'm not able to search with '<% %>' , maybe the reason is <% is a HTML TAG
Now i'm thinking there's no diffrence betwwen <% and <%= .
<% %> executes the code between the 2 brackets.
<%= %> returns the value between the 2 brackets.
Example:
<% Response.Write("Hello.") %>
vs
<%= "Hello" %>
<% %> and <%= %> are normally server side scripts, the difference is first one does not print out the value to the page, unless you explicitly use print function, but second one will do automatically
Are you talking about the ASP ? If yes then <% %> is to hold the server side code and this is <%= %> equivalent to the Response.Write().
They're generally referred to as beestings. These particular ones are used by ASP.Net or ASP Classic. <% %> signifies server side code and <%=<Something%> is shorthand for <% Response.Write(<Something>) %>
If you want to show current date in a page you can do either of the following to write the date to the document. In the first sample using <% %> you have to explicitly use Response.Write.
<% Response.Write(DateTime.Now.ToString()) %>
and in the following one no need to explicitly write Response.Write
<%= DateTime.Now.ToString() %>

Classic asp include

I am trying to separate some asp logic out into a separate page.
For now, I am trying to call a simple function.
Here is the simple index page that I am using
<html>
<head>
<title>Calling a webservice from classic ASP</title>
</head>
<body>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
%>
<!--#include file="aspFunctions.asp"-->
<%
doStuff()
End If
%>
<FORM method=POST name="form1" ID="Form1">
ID:
<INPUT type="text" name="corpId" ID="id" value="050893">
<BR><BR>
<INPUT type="submit" value="GO" name="submit1" ID="Submit1" >
</form>
</body>
</html>
Here is aspfunctions.asp
sub doStuff()
Response.Write("In Do Stuff")
end sub
When i hit the submit button on my form i get the below
sub doStuff() Response.Write("In Do Stuff") end sub
Microsoft VBScript runtime error '800a000d'
Does anyone have any idea what i could be doing wrong?
Any help is greatly appreciated
Thanks
Damien
Type mismatch: 'doStuff'
/uat/damien/index.asp, line 15
You must have the asp functions inside the <% %> tag.
aspfunctions.asp should be inside tags so the asp is "executed", e.g.
aspfunctions.asp file:
<%
sub doStuff()
Response.Write("In Do Stuff")
end sub
%>
Otherwise the asp in aspfunctions.asp is just seen as plain-text, so as far as the server is concerned, doStuff has never been defined.
You're including the other file within an if statement. This does not mean that it's dynamically included, it's not. It will always be included.
To see this in action try this sample:
<%
If 1=0 Then
'We never get here
%>
<!--#include file="aspFunctions.asp"-->
<%
dostuff()
End If
dostuff()
%>
If I remember correctly, you need no brackets for calls without a return value (untested solution):
doStuff
Make changes in two places:
In aspfunctions.asp write "sub doStuff" instead of sub doStuff()
Call the function as doStuff not doStuff()

Resources