{"action":"created","issue":{"url":"https://api.github.com/repos/AuthorizeNet/sdk-dotnet/issues/71","labels_url":"https://api.github.com/repos/AuthorizeNet/sdk-dotnet/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/AuthorizeNet/sdk-dotnet/issues/71/comments","events_url":"https://api.github.com/repos/AuthorizeNet/sdk-dotnet/issues/71/events","html_url":"https://github.com/AuthorizeNet/sdk-dotnet/issues/71","id":58179768,"number":71,"title":"Error response codes are not available with Subscription requests.","user":{"login":"gorgi","id":2641926,"avatar_url":"https://avatars.githubusercontent.com/u/2641926?v=3","gravatar_id":"","url":"https://api.github.com/users/gorgi","html_url":"https://github.com/gorgi","followers_url":"https://api.github.com/users/gorgi/followers","following_url":"https://api.github.com/users/gorgi/following{/other_user}","gists_url":"https://api.github.com/users/gorgi/gists{/gist_id}","starred_url":"https://api.github.com/users/gorgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gorgi/subscriptions","organizations_url":"https://api.github.com/users/gorgi/orgs","repos_url":"https://api.github.com/users/gorgi/repos","events_url":"https://api.github.com/users/gorgi/events{/privacy}","received_events_url":"https://api.github.com/users/gorgi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-19T08:28:31Z","updated_at":"2015-02-20T19:56:33Z","closed_at":null,"body":"Currently, if there is an error, an Invalid Operation Exception is being thrown, with message like: Error processing request: E00013 - Credit Card Number is invalid.\r\n\r\nThe error codes are not available in a strongly typed manner. The above message is not really user friendly and I would have to parse it to get the error code, which is error prone. \r\n\r\nCan you add a strongly typed response for Subscription request instead of throwing an Exception? Our web site is multilanguage, so we need to translate the error codes.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/AuthorizeNet/sdk-dotnet/issues/comments/75308143","html_url":"https://github.com/AuthorizeNet/sdk-dotnet/issues/71#issuecomment-75308143","issue_url":"https://api.github.com/repos/AuthorizeNet/sdk-dotnet/issues/71","id":75308143,"user":{"login":"Dthurman","id":9486338,"avatar_url":"https://avatars.githubusercontent.com/u/9486338?v=3","gravatar_id":"","url":"https://api.github.com/users/Dthurman","html_url":"https://github.com/Dthurman","followers_url":"https://api.github.com/users/Dthurman/followers","following_url":"https://api.github.com/users/Dthurman/following{/other_user}","gists_url":"https://api.github.com/users/Dthurman/gists{/gist_id}","starred_url":"https://api.github.com/users/Dthurman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dthurman/subscriptions","organizations_url":"https://api.github.com/users/Dthurman/orgs","repos_url":"https://api.github.com/users/Dthurman/repos","events_url":"https://api.github.com/users/Dthurman/events{/privacy}","received_events_url":"https://api.github.com/users/Dthurman/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T19:56:33Z","updated_at":"2015-02-20T19:56:33Z","body":"I have reproed the issue, and you are right, error handling is not ideal for the gateway model.\r\nWe are looking at how to handle the issue.\r\n\r\nGoing forward, the best approach would be to use the new \"Controller\" model.\r\nUsing the new model, your sample would look like this:\r\n\r\n        [Test]\r\n        public void TestSubscription_ExpiredCC()\r\n        {\r\n            Random rnd = new Random(DateTime.Now.Millisecond);\r\n            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;\r\n            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;\r\n            //create a subscription\r\n            var subscriptionDef = new ARBSubscriptionType\r\n            {\r\n\r\n\r\n                paymentSchedule = new paymentScheduleType\r\n                {\r\n                    interval = new paymentScheduleTypeInterval\r\n                    {\r\n                        length = 7,\r\n                        unit = ARBSubscriptionUnitEnum.days\r\n                    },\r\n                    startDate = DateTime.UtcNow,\r\n                    totalOccurrences = 2,\r\n                },\r\n\r\n\r\n                amount = 9.99M,\r\n                billTo = new nameAndAddressType\r\n                {\r\n                    address = \"1234 Elm St NE\",\r\n                    city = \"Bellevue\",\r\n                    state = \"WA\",\r\n                    zip = \"98007\",\r\n                    firstName = \"First\",\r\n                    lastName = \"Last\"\r\n                },\r\n\r\n                payment = new paymentType\r\n                {\r\n                    Item = new creditCardType\r\n                                 {\r\n                                     cardCode = \"655\",\r\n                                     cardNumber = \"4007000\",\r\n                                     expirationDate = \"122013\",\r\n                                 }\r\n                },\r\n\r\n                customer = new customerType { email = \"somecustomer@test.org\", id = \"5\", },\r\n\r\n                order = new orderType { description = string.Format(\"member monthly {0}\", rnd.Next(99999)) },\r\n            };\r\n\r\n            var arbRequest = new ARBCreateSubscriptionRequest { subscription = subscriptionDef };\r\n            var arbController = new ARBCreateSubscriptionController(arbRequest);\r\n            arbController.Execute();\r\n\r\n            var arbCreateResponse = arbController.GetApiResponse();\r\n\r\n            //If request responds with an error, walk the messages and get code and text for each message.\r\n            if (arbController.GetResultCode() == messageTypeEnum.Error)\r\n            {\r\n                foreach(var msg in arbCreateResponse.messages.message)\r\n                {\r\n                    Console.WriteLine(\"Error Num = {0}, Message = {1}\", msg.code, msg.text);\r\n                }\r\n            }\r\n        }"}}