簡體   English   中英

Authorize.NET使用test.authorize.net創建客戶資料嗎?

[英]Authorize.NET create customer profile with test.authorize.net?

在authorize.net中,是否可以使用https://test.authorize.net/gateway/transact.dll頁面(測試模式)創建客戶資料+客戶付款資料? 我需要返回客戶profileid和paymentprofileid以進行離線付款。

在創建具有客戶付款資料的客戶資料並致電收費客戶資料后,我可以使用API​​(C#)進行此操作。 但是我不希望用戶在我的網站上輸入卡的詳細信息,需要使用Authorize.NET UI進行操作並獲取響應。

這可能嗎?

是的,可以通過Authorize.NET進行令牌API信用卡交易。 有關詳細信息,請參見本CIM指南文檔(第4章)。

  • 第1步-使用API​​創建客戶資料。 (只是基本的客戶詳細信息)
  • 第2步-獲取配置文件的令牌*(getHostedProfilePageRequest)。 這就是我卡住的“神秘API調用”,我在下面共享代碼。
  • 第3步-如下創建表格並發布信息。 (這會將客戶定向到托管表單,以添加/修改付款方式或送貨地址)
  • 步驟4-嘗試查詢客戶的客戶付款資料,您將找到添加的付款資料。

表格格式

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

這是我為神秘的API調用“ getHostedProfilePageRequest”找到的代碼,該代碼在Github的C#SDK中不可用。 它在soap客戶端中可用,但是此代碼只是通過http發送XML請求(聲音與Web服務非常相似)。

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;
        }
    }

在這里找到此代碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM