获取 4 位信用卡号 Authorize.net
Get 4 digit credit card number Authorize.net
您好,我找到了一个示例代码,它要求传递 ApiLoginID、ApiTransactionKey 和 transactionId。
我能够获得 ApiLoginID 和 ApiTransactionKey,但是我如何获得测试 transactionID 作为测试模式 authorize.net 始终将 transactionid 设置为 0
下面是我需要检索信用卡号的代码。请建议这是检索信用卡详细信息的真实代码吗?
public class GetTransactionDetails
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string transactionId)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Console.WriteLine("Get transaction details sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
var request = new getTransactionDetailsRequest();
request.transId = transactionId;
// instantiate the controller that will call the service
var controller = new getTransactionDetailsController(request);
controller.Execute();
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transaction == null)
return response;
Console.WriteLine("Transaction Id: {0}", response.transaction.transId);
Console.WriteLine("Transaction type: {0}", response.transaction.transactionType);
Console.WriteLine("Transaction status: {0}", response.transaction.transactionStatus);
Console.WriteLine("Transaction auth amount: {0}", response.transaction.authAmount);
Console.WriteLine("Transaction settle amount: {0}", response.transaction.settleAmount);
}
else if (response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
return response;
}
}
}
在示例代码中,我传递了以下凭据
const string apiLoginId = "5KP3u95bQpv";
const string transactionKey = "346HZ32z3fP4hTG2";
const string transactionId = "2249735976";
我正在检索数据,如下图所示,但无法获取信用卡详细信息
我只想检索信用卡详细信息以进行授权。任何帮助
在我的代码中,我还添加了如下代码,但我收到错误消息
var obj = (creditCardMaskedType)response.transaction.payment.Item;
Console.WriteLine("Creditcard settle cardnumber: {0}", obj.cardNumber);
错误
附加信息:无法将类型 'AuthorizeNet.Api.Contracts.V1.bankAccountMaskedType' 的对象转换为类型 'AuthorizeNet.Api.Contracts.V1.creditCardMaskedType'。
信用卡的最后四位数字位于响应的 transaction > payment > creditcard > cardnumber
部分。您应该可以使用 response.transaction.payment.creditCard.cardNumber
.
访问
以下是来自 getTransactionDetails
API 电话的示例响应,供您参考。这应该向您展示结构并更好地理解如何获取您想要的数据。
{
"transaction":{
"transId":"2162566217",
"submitTimeUTC":"2011-09-01T16:30:49.39Z",
"submitTimeLocal":"2011-09-01T10:30:49.39",
"transactionType":"authCaptureTransaction",
"transactionStatus":"settledSuccessfully",
"responseCode":1,
"responseReasonCode":1,
"responseReasonDescription":"Approval",
"authCode":"JPG9DJ",
"AVSResponse":"Y",
"batch":{
"batchId":"1221577",
"settlementTimeUTC":"2011-09-01T16:38:54.52Z",
"settlementTimeUTCSpecified":true,
"settlementTimeLocal":"2011-09-01T10:38:54.52",
"settlementTimeLocalSpecified":true,
"settlementState":"settledSuccessfully"
},
"order":{
"invoiceNumber":"60",
"description":"Auto-charge for Invoice #60"
},
"requestedAmountSpecified":false,
"authAmount":1018.88,
"settleAmount":1018.88,
"prepaidBalanceRemainingSpecified":false,
"taxExempt":false,
"taxExemptSpecified":true,
"payment":{
"creditCard":{
"cardNumber":"XXXX4444",
"expirationDate":"XXXX",
"cardType":"MasterCard"
}
},
"customer":{
"typeSpecified":false,
"id":"4"
},
"billTo":{
"phoneNumber":"(619) 274-0494",
"firstName":"Matteo",
"lastName":"Bignotti",
"address":"625 Broadway\nSuite 1025",
"city":"San Diego",
"state":"CA",
"zip":"92101",
"country":"United States"
},
"recurringBilling":false,
"recurringBillingSpecified":true,
"product":"Card Not Present",
"marketType":"eCommerce"
},
"messages":{
"resultCode":"Ok",
"message":[
{
"code":"I00001",
"text":"Successful."
}
]
}
}
您好,我找到了一个示例代码,它要求传递 ApiLoginID、ApiTransactionKey 和 transactionId。
我能够获得 ApiLoginID 和 ApiTransactionKey,但是我如何获得测试 transactionID 作为测试模式 authorize.net 始终将 transactionid 设置为 0
下面是我需要检索信用卡号的代码。请建议这是检索信用卡详细信息的真实代码吗?
public class GetTransactionDetails
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string transactionId)
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Console.WriteLine("Get transaction details sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
var request = new getTransactionDetailsRequest();
request.transId = transactionId;
// instantiate the controller that will call the service
var controller = new getTransactionDetailsController(request);
controller.Execute();
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transaction == null)
return response;
Console.WriteLine("Transaction Id: {0}", response.transaction.transId);
Console.WriteLine("Transaction type: {0}", response.transaction.transactionType);
Console.WriteLine("Transaction status: {0}", response.transaction.transactionStatus);
Console.WriteLine("Transaction auth amount: {0}", response.transaction.authAmount);
Console.WriteLine("Transaction settle amount: {0}", response.transaction.settleAmount);
}
else if (response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}
return response;
}
}
}
在示例代码中,我传递了以下凭据
const string apiLoginId = "5KP3u95bQpv";
const string transactionKey = "346HZ32z3fP4hTG2";
const string transactionId = "2249735976";
我正在检索数据,如下图所示,但无法获取信用卡详细信息
我只想检索信用卡详细信息以进行授权。任何帮助
在我的代码中,我还添加了如下代码,但我收到错误消息
var obj = (creditCardMaskedType)response.transaction.payment.Item;
Console.WriteLine("Creditcard settle cardnumber: {0}", obj.cardNumber);
错误
附加信息:无法将类型 'AuthorizeNet.Api.Contracts.V1.bankAccountMaskedType' 的对象转换为类型 'AuthorizeNet.Api.Contracts.V1.creditCardMaskedType'。
信用卡的最后四位数字位于响应的 transaction > payment > creditcard > cardnumber
部分。您应该可以使用 response.transaction.payment.creditCard.cardNumber
.
以下是来自 getTransactionDetails
API 电话的示例响应,供您参考。这应该向您展示结构并更好地理解如何获取您想要的数据。
{
"transaction":{
"transId":"2162566217",
"submitTimeUTC":"2011-09-01T16:30:49.39Z",
"submitTimeLocal":"2011-09-01T10:30:49.39",
"transactionType":"authCaptureTransaction",
"transactionStatus":"settledSuccessfully",
"responseCode":1,
"responseReasonCode":1,
"responseReasonDescription":"Approval",
"authCode":"JPG9DJ",
"AVSResponse":"Y",
"batch":{
"batchId":"1221577",
"settlementTimeUTC":"2011-09-01T16:38:54.52Z",
"settlementTimeUTCSpecified":true,
"settlementTimeLocal":"2011-09-01T10:38:54.52",
"settlementTimeLocalSpecified":true,
"settlementState":"settledSuccessfully"
},
"order":{
"invoiceNumber":"60",
"description":"Auto-charge for Invoice #60"
},
"requestedAmountSpecified":false,
"authAmount":1018.88,
"settleAmount":1018.88,
"prepaidBalanceRemainingSpecified":false,
"taxExempt":false,
"taxExemptSpecified":true,
"payment":{
"creditCard":{
"cardNumber":"XXXX4444",
"expirationDate":"XXXX",
"cardType":"MasterCard"
}
},
"customer":{
"typeSpecified":false,
"id":"4"
},
"billTo":{
"phoneNumber":"(619) 274-0494",
"firstName":"Matteo",
"lastName":"Bignotti",
"address":"625 Broadway\nSuite 1025",
"city":"San Diego",
"state":"CA",
"zip":"92101",
"country":"United States"
},
"recurringBilling":false,
"recurringBillingSpecified":true,
"product":"Card Not Present",
"marketType":"eCommerce"
},
"messages":{
"resultCode":"Ok",
"message":[
{
"code":"I00001",
"text":"Successful."
}
]
}
}