Jump to content

Credit Card Processing C#.net Visual Studio 2010


robode

Recommended Posts

I know this question is probably posted somewhere, but to be honest, I do not have the time to go searching through a bunch of forums to find the answer or a hint related to the answer. I have an order-form on a page where you can enter in customer's information(name, credit card type, number, expiration date and name on card. Once I hit the submit button it sends the information to some kind of credit card processing API/gateway on a site the merchant I'm selling for uses. That site then gives a "Transaction Declined/Approved" response, normally taking me off of my form page to another page with just that reply on it. My question is, how can I make it to where instead of taking me to another page to see the reply, it gets sent to a label on the same page as my order form ? If you need to see my code let me know and I will post code making the form and then also the .aspx.cs coded page. I am using Visual Studio 2010 Professional C#.

Link to comment
Share on other sites

You'll need to check the API capabilities, it sounds like you're submitting the form to them or you're telling them where to redirect to on your site. If you don't want to leave or refresh the page at all then the form will need to use ajax to submit to your server, and you'll need to exchange data with the remote server and send the response back to the page. You may also just want to have it redirect to the same page with a variable in the URL to say what the message to show is.

Link to comment
Share on other sites

I believe I understand what you are saying. Sadly, I don't know anything about AJAX. I am submitting the credit info to ebizcharge.com, Im guessing they are an API company or something, it's just what the merchant uses. But they give out a Transaction Declined/Approved message. Like how i have been testing so far with a fake name street, credit card number, etc. and then it sends me to a secured page with an ebizcharge url and all it says on the page is "Transaction Declined" (of course that is because I'm using a fake name and everything). What I was it to do is send that response to a label on my page so I dont get sent to a page by them. Here is my .aspx code so far: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserInfo.aspx.cs" Inherits="Default2" Debug="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Credit Card Processing Test</title></head><body><form runat="server" method="post" id="Form" name="Form"><input type="hidden" name="UMkey" value="Your_source_key_here" /><input type="hidden" name="UMredirApproved" value="http://www.mycompany.com/orderapproved.html" /><input type="hidden" name="UMinvoice" value="123456" /><input type="hidden" name="UMamount" value="1.00" /><input type="hidden" name="UMcommand" value="authonly" />Full Name: <br /> <asp:textbox runat="server" ID="FullName"></asp:textbox><br />Address:<br /><asp:textbox runat="server" ID="Address"></asp:textbox><br /><br /><b><i>Card Info</i></b><br />Card Type<br /><asp:DropDownList ID="ddlCardType" runat="server"><asp:ListItem>Visa</asp:ListItem><asp:ListItem>Mastercard</asp:ListItem><asp:ListItem>AmEx</asp:ListItem></asp:DropDownList><br />Card Number<br /> <asp:textbox runat="server" ID="ccNumber"></asp:textbox><br />Card Expiration Date<br /> <asp:textbox runat="server" ID="txtCardExpir" ></asp:textbox><br />Name On Card<br /> <asp:textbox runat="server" ID="txtNameCard" ></asp:textbox><br /><br /><asp:Button ID="Submit" runat="server" Text="Submit" onclick="Button1_Click1" /><br /><asp:label runat="server" ID="transResult"></asp:label></form></body></html> At first, within the opening form tag, I had "action="https://secure.ebizcharge.com/secure/gate""'>https://secure.ebizcharge.com/secure/gate"" but that is what made it send me to another page to get the response, so I took it out, so now my code is like it is above. Here is my .aspx.cs code:public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { transResult.Text = ("https://secure.ebizcharge.com/secure/gate"); var txtFullName = FullName.Text; var txtAddress = Address.Text; var txtCreditCard = ccNumber.Text; var lblTransResult = transResult.Text; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; Stream xmlFile = new FileStream(@"C:\users\Robert\Desktop\Website2\ccStorage.xml", FileMode.Append, FileAccess.Write); XmlTextWriter writer = new XmlTextWriter(xmlFile, System.Text.Encoding.Default); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(true); writer.WriteStartElement("Table"); writer.WriteStartElement("Order"); writer.WriteStartAttribute("FullName"); writer.WriteValue(FullName.Text); writer.WriteEndAttribute(); writer.WriteStartAttribute("Address"); writer.WriteValue(Address.Text); writer.WriteEndAttribute(); writer.WriteStartAttribute("ccNumber"); writer.WriteValue(ccNumber.Text); writer.WriteEndAttribute(); writer.WriteStartAttribute("transResult"); writer.WriteValue(transResult.Text); writer.WriteEndAttribute(); writer.WriteEndElement(); writer.WriteEndElement(); }} When I took out the action line from my opening form tag, I put that same url in the above code attached the label. Now whenever I hit my submit button, inside the label it just shows that url instead of showing "Transaction Declined/Approved" I think, like you said, I need to save the reply in a variable and then load that variable into the label. The is where I'm having trouble, it has been so long since I have done something like that I can't really remember exactly how to do it. I feel like I am just missing a few lines of code, but I have no idea what they are or where to put them.

Link to comment
Share on other sites

I don't have experience using ajax in ASP.net, but I assume there are built-in components to do that. They probably aren't named "ajax" though, they probably have a name that one of the developers at Microsoft thought of in the bathroom. If you want to go that route, do some research for how ASP.net handles ajax requests. It looks like the site you're connecting to has information about a SOAP API on its site, so that would be another option. There should be several resources online for using SOAP services in ASP.net.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...