cancel
Showing results for 
Search instead for 
Did you mean: 

How to send billing info? (Using DPM, C#, and ASP.Net)

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

 

 

rockon77
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

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?

Don't need customer profile for that. Just the customerAddressType 
 
 

View solution in original post

4 REPLIES 4

1)If the form post back to your server, you are not using DPM, but AIM.

2)https://github.com/AuthorizeNet/sdk-dotnet/blob/9ede631d820841ba6f5c0f6ef26147c7080be242/AuthorizeNE...

is the billTo

RaynorC1emen7
Expert

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?

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?

Don't need customer profile for that. Just the customerAddressType 
 
 

Great, thank you so much!