首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Authorize.NET用test.authorize.net创建客户配置文件?

Authorize.NET用test.authorize.net创建客户配置文件?
EN

Stack Overflow用户
提问于 2015-10-08 05:13:53
回答 1查看 1.5K关注 0票数 0

在authorize.net中,是否可以使用https://test.authorize.net/gateway/transact.dll页面(测试模式)创建客户配置文件+客户支付配置文件?我需要返回客户简介和付款概况,以进行离线付款。

在使用客户支付配置文件创建客户配置文件并调用C#之后,我可以使用API ( 收费客户简介 )来完成这一任务。但是我不希望用户在我的网站中输入卡的细节,需要使用Authorize.NET用户界面并得到响应。

这有可能做到吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-08 06:55:46

是的,可以用Authorize.NET进行令牌API信用卡交易。详细信息可以找到在本CIM指南中文档(第4章)。

  • 步骤1-使用API创建客户配置文件。(只是基本的客户信息)
  • 步骤2-获取配置文件(getHostedProfilePageRequest)的标记*。这就是我陷入困境的地方,“神秘API调用”,我正在分享下面的代码。
  • 步骤3-创建如下所示的表单并创建一个帖子。(这将指示客户到宿主表单以添加/编辑付款方法或发货地址)
  • 步骤4-尝试查询客户支付配置文件,您将找到添加的支付配置文件。

表格的格式,

代码语言:javascript
复制
    <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>

下面是我为神秘的对"getHostedProfilePageRequest“的API调用找到的代码,这在Github的C# SDK中是不可用的。它可以在soap客户机中使用,但这段代码只需通过http发送XML请求(听起来非常类似于web服务)。

代码语言:javascript
复制
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;
        }
    }

找到这个代码这里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33007143

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档