在authorize.net中,是否可以使用https://test.authorize.net/gateway/transact.dll页面(测试模式)创建客户资料+客户付款资料? 我需要返回客户profileid和paymentprofileid以进行离线付款。
在使用客户付款资料创建客户资料并致电charge customer profile后,我可以使用API(C#)执行此操作。但我不希望用户在我的网站上输入卡片详细信息,需要使用Authorize.NET UI来获取响应。
这可能吗?
答案 0 :(得分:0)
是的,可以使用Authorize.NET进行令牌API信用卡交易。 详细信息可以在in this CIM guide文档中找到(第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调用&#34; getHostedProfilePageRequest&#34;这在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;
}
}
找到此代码here