- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
when you run debug, what is in "response"?
โ05-25-2016 04:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
not really, but you got the source code, so you could look at those.
โ05-25-2016 07:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks so much! Will give this a try.
โ06-02-2016 05:22 AM