0
votes

In authorize.net, is it possible to create a customer profile + customer payment profile with the https://test.authorize.net/gateway/transact.dll page (test mode)? I need to return the customer profileid and paymentprofileid(s) to make offline payments.

I could do this with the API (C#) after creating a customer profile with customer payment profile and calling charge customer profile. But I don't want the user to enter card details in my website, need to do it with a Authorize.NET UI and get the response.

Is this possible to do?

1
Updated documentation for creating customer profiles: developer.authorize.net/api/reference/features/… - Chloe

1 Answers

0
votes

Yes, it's possible to do token API credit card transactions with Authorize.NET. Details can be found in this CIM guide document (chapter 4).

  • Step 1 - Create a customer profile with the API. (just basic customer details)
  • Step 2 - Get the token* for the profile (getHostedProfilePageRequest). This is where I got stuck, "mystery API call", I am sharing the code below.
  • Step 3 - Create a form as below and make a post. (this will direct the customer to a hosted form to add/edit payment methods or shipping addresses)
  • Step 4 - Try to query customer payment profiles for the customer, you will find the added payment profile.

Format of the form,

    <form method="post" action="https://test.authorize.net/
     profile/manage">
      <input type="hidden" name="token"
         value="pfGaUNntoTxZYeqqYDjGCQ4qyCHcsXGXLJ2i7MPCEiH6CH5n5qKqcl8EB
            iTClxu01BSeH5eZg7LVUVVzw5kJKVMitQ3pyMB5UZCduMWd6Ku9aT2gyFm69EKMG
            fyWPmI4p+Bb4XXXXXXXXXXXXWlM6f2xd7aRu1XBn0WXoPxK1j9FMGX2CNCoCB
            p3cOXB7"/>
      <input type="submit" value="Manage payment and shipping
      information"/>
     </form>

Here is the code I found for the mystery API call to "getHostedProfilePageRequest" which was not available in the C# SDK in Github. It's available in the soap client, but this code simply send the XML request over http (sounds pretty similar to web service).

public static string GetHostedSessionKey(UInt32 customerProfileID, Uri callingPage)
    {
        try
        {
            //build a path to IframeCommunicator from the calling page
            string communicatorPath = String.Format("{0}://{1}:{2}", callingPage.Scheme, callingPage.Host, callingPage.Port);
            string[] segments = callingPage.Segments;
            //replace the very last entry with contentx/IframeCommunicator.html
            segments[segments.GetUpperBound(0)] = "/contentx/IframeCommunicator.html";
            foreach (string s in segments)
                communicatorPath += s;

            string requestXML = String.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                "<getHostedProfilePageRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" +
                                                    "<merchantAuthentication>" +
                                                        "<name>{0}</name>" +
                                                        "<transactionKey>{1}</transactionKey>" +
                                                    "</merchantAuthentication>" +
                                                    "<customerProfileId>{2}</customerProfileId>" +
                                                    "<hostedProfileSettings>" +
                                                        "<setting>" +
                                                            "<settingName>hostedProfilePageBorderVisible</settingName>" +
                                                            "<settingValue>false</settingValue>" +
                                                        "</setting>" +
                                                        "<setting>" +
                                                            "<settingName>hostedProfileIFrameCommunicatorUrl</settingName>" +
                                                            "<settingValue>{3}</settingValue>" +
                                                        "</setting>" +
                                                    "</hostedProfileSettings>" +
                                                "</getHostedProfilePageRequest>",
                                            {your merchant login ID},
                                            {your merchant transaction key},
                                            customerProfileID,
                                            communicatorPath);
         string XMLURL = "https://apitest.authorize.net/xml/v1/request.api";
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(XMLURL);
            req.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
            req.KeepAlive = false;
            req.Timeout = 30000; //30 seconds
            req.Method = "POST";
            byte[] byte1 = null;
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            byte1 = encoding.GetBytes(requestXML);
            req.ContentType = "text/xml";
            req.ContentLength = byte1.Length;
            System.IO.Stream reqStream = req.GetRequestStream();
            reqStream.Write(byte1, 0, byte1.Length);
            reqStream.Close();

            System.Net.WebResponse resp = req.GetResponse();
            System.IO.Stream read = resp.GetResponseStream();
            System.IO.StreamReader io = new System.IO.StreamReader(read, new         System.Text.ASCIIEncoding());
            string data = io.ReadToEnd();
            resp.Close();

            //parse out value
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(data);
            XmlNodeList token = doc.GetElementsByTagName("token");
            return token[0].InnerText;
        }
        catch (System.Exception ex)
        {
            Utility.NotifyOnException(ex, String.Format("profID={0}", customerProfileID));
            return null;
        }
    }

Found this code here