- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Communicating Responses in DPM
So I'm using DPM in an ASP.NET Web Forms C# website. I can successfully make a transaction from payment.aspx, pass in a x_relay_url (response.aspx) and can see the response printed. However the response object is available in response.aspx, but I don't know how to access it in the original payment.aspx.cs file. Therefore I can't see how I'm supposed to redirect or otherwise make decisions based on transaction approval.
Code snippet from payment.aspx. I can get a WebResponse object, but not a SIMResponse object.
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("https://secure.authorize.net/gateway/transact.dll"); // note this authorize.net's test site webRequest.Method = "POST"; webRequest.CookieContainer = new System.Net.CookieContainer(); webRequest.ContentLength = vPostData.Length; webRequest.ContentType = "application/x-www-form-urlencoded"; Stream webRequestStream = webRequest.GetRequestStream(); webRequestStream.Write(vPostData, 0, vPostData.Length); webRequestStream.Close(); WebResponse webResponse = webRequest.GetResponse();
I can get a populated SIMResponse in my response URL with:
response = new SIMResponse(Request.Form);
But performing this in the payment.aspx.cs file results in an unpopulated SIMResponse object. Any help or direction would be greatly appreciated.
โ08-27-2014 01:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are doing a webrequest in code, you are doing AIM, not DPM, the point of using DPM is not having the customer credit card info touch your server.
DPM is similar to SIM, download the sample code for C# SIM under "DOWNLOADS"
โ08-27-2014 04:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, that's handy to know! Thanks. So I tried switching to the Quick Start for AIM code,
class Program { static void Main(string[] args) { // Step 1 - Create the request var request = new AuthorizationRequest("4111111111111111", "1216", 10.00M, "Test Transaction"); // Step 2 - Create the gateway, sending in your credentials var gate = new Gateway("YOUR_API_LOGIN_ID", "YOUR_TRANSACTION_KEY"); // Step 3 - Send the request to the gateway var response = gate.Send(request); Console.WriteLine("{0}: {1}", response.ResponseCode, response.Message); Console.Read(); } }
But the response is still empty, and approved is false. Now, the test transaction actually went through and I received an email. But yet that darn response object is still empty. Suggestions?
โ08-27-2014 11:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Console.WriteLine("{0}: {1}", response.ResponseCode, response.Message); Console.Read();
You mean the console show blank?
or where are you checking the response?
โ08-27-2014 11:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I modified this code to run in C# code behind the ASPX page:
protected var responseStr;
static void Submit_Click(Object sender, EventArgs e) { // Step 1 - Create the request var request = new AuthorizationRequest("4111111111111111", "1216", 10.00M, "Test Transaction"); // Step 2 - Create the gateway, sending in your credentials var gate = new Gateway("YOUR_API_LOGIN_ID", "YOUR_TRANSACTION_KEY"); // Step 3 - Send the request to the gateway var response = gate.Send(request);
responseStr = "Approved: " + response.Approved;
responseStr = "TransactionID: " + response.TransactionID; }
And on the ASPX page itself, I of course have:
<%= responseStr =%> <asp:Button runat="server" id="Submit" Text="Place Order" OnClick="Submit_Click" />
โ08-27-2014 01:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you debug it and breakpoint after the gate.Send
Is response null? blank?
โ08-27-2014 01:54 PM