cancel
Showing results for 
Search instead for 
Did you mean: 

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.

kallinan
Member
5 REPLIES 5

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"

RaynorC1emen7
Expert

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?

Console.WriteLine("{0}: {1}", response.ResponseCode, response.Message);
          Console.Read();

 

You mean the console show blank?

or where are you checking the response?

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" /> 

 

When you debug it and breakpoint after the gate.Send

Is response null? blank?