Hello, I have tried many attempts at trying to send data from my form that includes billing info like first name, last name, address, etc.
I need to add something like this but any of my attempts haven't worked:
x_first_name = FirstName.Text;
This is my C# code for my form's submit button:
protected void Button1_Click(object sender, EventArgs e)
{
String ApiLoginID = "HIDDEN_FOR_PRIVACY";
String ApiTransactionKey = "HIDDEN_FOR_PRIVACY";
String cardNumber1 = TextBoxCardNum.Text;
String expirationDate1 = TextBoxExp.Text;
String cardCode1 = TextBoxCCV.Text;
String status = LblStatus.Text;
Console.WriteLine("Charge Credit Card 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 creditCard = new creditCardType
{
cardNumber = cardNumber1,
expirationDate = expirationDate1,
cardCode = cardCode1
};
//standard api call to retrieve response
var paymentType = new paymentType { Item = creditCard };
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // charge the card
amount = 175.00m,
payment = paymentType,
};
transactionRequest = FirstName.Text;
var request = new createTransactionRequest { transactionRequest = transactionRequest };
// instantiate the contoller that will call the service
var controller = new createTransactionController(request);
controller.Execute();
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transactionResponse != null)
{
status = "Success, Auth Code : " + response.transactionResponse.authCode;
}
}
else
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
if (response.transactionResponse != null)
{
status = "Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText;
}
}
}
Solved! Go to Solution.
01-06-2016 11:07 AM - edited 01-06-2016 11:09 AM
Thank you for your response. Are you saying the code I posted is actually AIM? I got it from the Hello World sample and just made a few edits.
Yes, the API use AIM. If you want to use DPM. Read the SIM doc
http://www.authorize.net/content/dam/authorize/documents/SIM_guide.pdf
Okay I see the billTo section. I guess I'd have to create a customer profile in order to send the user's billing address to Authorize.net?
01-06-2016 12:39 PM
1)If the form post back to your server, you are not using DPM, but AIM.
is the billTo
01-06-2016 12:09 PM
Thank you for your response. Are you saying the code I posted is actually AIM? I got it from the Hello World sample and just made a few edits.
Okay I see the billTo section. I guess I'd have to create a customer profile in order to send the user's billing address to Authorize.net?
01-06-2016 12:21 PM
Thank you for your response. Are you saying the code I posted is actually AIM? I got it from the Hello World sample and just made a few edits.
Yes, the API use AIM. If you want to use DPM. Read the SIM doc
http://www.authorize.net/content/dam/authorize/documents/SIM_guide.pdf
Okay I see the billTo section. I guess I'd have to create a customer profile in order to send the user's billing address to Authorize.net?
01-06-2016 12:39 PM
Great, thank you so much!
01-06-2016 01:04 PM