Hi there...Upgrading to the new ASP.NET code using the ChargeCreditCard AuthNet API. Everything works except I need to display the response message to the user, especially if the transaction fails. The API code only writes the message to the console. How can I display the response message to the user?
Note: from my page code behind, I call ChargeCreditCard.Run(strAuthNetLogin, strAuthNetTransKey, CartTotal);
The sample code includes "return response;" but I cannot seem to get the proper syntax to access that info outside of the call.
Thanks for the help.
Solved! Go to Solution.
05-25-2016 03:14 AM
r is the transaction response
public ANetApiResponse TestAuthorizeCreditCard() { var response = (createTransactionResponse)AuthorizeCreditCard.Run(apiLoginId, transactionKey, GetAmount()); return response; }
try it as a createtransactionresponse
05-25-2016 03:07 PM - edited 05-25-2016 03:08 PM
when you run debug, what is in "response"?
05-25-2016 04:51 AM
hi there...
"AuthorizeNet.Api.Contracts.V1.ChargeCreditCardResponse"
Here is the sample code: https://github.com/AuthorizeNet/sample-code-csharp/blob/master/PaymentTransactions/ChargeCreditCard....
I can call the process with var r = ChargeCreditCard.Run(.....) and then display r.messages.message[0].code + " " + r.messages.message[0].text. There is additional info in the response that I am unable to get to.
Is there a more complete example beyond what is on Github?
Thanks!
05-25-2016 05:07 AM
not really, but you got the source code, so you could look at those.
05-25-2016 07:08 AM
So what is the best way to get at the complete response info? I would like to also retrieve response.transactionResponse.transId.
When calling the controller like this:
var r = ChargeCreditCard.Run(strAuthNetLogin, strAuthNetTransKey, CartTotal);
I can only retrieve response info such as r.messages.message[0].text
If I try to retrieve r.transactionResponse.transId I get the error: "ANetAPIResponse does not contain a definition for 'transactionResponse'..."
Thanks for your help!
05-25-2016 07:14 AM
r is the transaction response
public ANetApiResponse TestAuthorizeCreditCard() { var response = (createTransactionResponse)AuthorizeCreditCard.Run(apiLoginId, transactionKey, GetAmount()); return response; }
try it as a createtransactionresponse
05-25-2016 03:07 PM - edited 05-25-2016 03:08 PM
Thanks so much! Will give this a try.
06-02-2016 05:22 AM