Not sure where to look for this problem, Trying to get the C# sample code working but the responce is alwasy E00013 Unexpected character encountered while parsing value: h. Path '', line 0, position 0."
public static string GetCheckoutPage(String ApiLoginID, String ApiTransactionKey, decimal amount) { Console.WriteLine("GetAnAcceptPaymentPage Sample"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType() { name = ApiLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = ApiTransactionKey, }; settingType[] settings = new settingType[3]; settings[0] = new settingType(); settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString(); settings[0].settingValue = "{\"text\": \"Pay\"}"; settings[1] = new settingType(); settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString(); settings[1].settingValue = "{\"show\": false}"; settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString(); settings[2].settingValue = "https://localhost:44397/WebPort/IframeCommunicator.aspx"; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // authorize capture only amount = 200.00m //amount }; var request = new getHostedPaymentPageRequest(); request.transactionRequest = transactionRequest; request.hostedPaymentSettings = settings; // instantiate the contoller that will call the service var controller = new getHostedPaymentPageController(request); controller.Execute(); // get the response from the service (errors contained if any) var response = controller.GetApiResponse(); string token = string.Empty; if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { token = response.token; } else if (response == null) { token = "Unable to connect to Authorize.net Please refresh the page and try again."; return token; } return token;
Solved! Go to Solution.
08-16-2017 02:21 PM
settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString(); settings[2].settingValue = "{\"url\": \"https://YOUR_FANCY_WEBSITE.com/icommunicator.aspx\"}";
Test token: https://nexwebsites.com/authorizenet/token-tester.html
By the way, the input name for the token needs to be "token".
name="token"
08-16-2017 03:17 PM - edited 08-16-2017 03:26 PM
Correction:
settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString(); settings[2].settingValue = "https://localhost:44397/WebPort/IframeCommunicator.aspx";
was causing the issue, I forgot to escape the ". I now get back a token.
<form id="formAuthorizeNetPayPopup" method="post" action="" name="formAuthorizeNetPopup" target="iframeAuthorizeNet" style="display: none;"> <input id="PayToken" name="PayToken" value="Z/+2jJUVqLkjdMgSfByqqBd5dY5lHUw25DikVUL6pQTui17IQRbPsNOD05UO2QoPXdb4lQBX4/Hak/8Nbyar05bV2CnsHITsbi6A6bc6WiSRg3RB1X+uAAHOkW+PgRtWECrCSB8SHQ8T9Hn+CkI0sKIFOWsecWLusjOnnTivhD7ytcUhBg9JgCcnIAnrr9okyVvElQRi6wg/h50CsVEEXc+xEHpNksnXDd0haZNUQqLsxcq8pLdMb8hBg8acc3HV1rv8bmcr2BcT4AzcyRrqGzEl/fc6BRqHjOas8+wWARe0vdVDruUfNJihOgtGxdbmEBcbJOiARoAdnwF9s0+Naavz7gL5q2it4rcyBSC9J8JoEKqSt1FOKzySPLswGHtbsS2efC0bLvYvs6pQ5W5PHJol8HOWB5o5lidTNvIfHP2/ZMpnN9/ZuI+/Q//9HuoRtRb4WHvFtbgyKS/gkMatvibgMiRG8PTLNHaze7P/+RtRZfrww2NpQqfThKYZeZHsBdNfIWT3xfJciisH/CBsaf+qpYFibVZCaR/zsDdsOaowayf/8FVUTGC5h7hT/HAKQnn+puDEi66SIOXalBEu/hgfag5blrxfbJ/+ExdIVItoUoVkp9zoctWRPFNe/olcz83zI/EHqRRMqLKL1L5+KX2f9cL2NwfntDzTvqOyfADL+4AynI2BjkOy8N1uOuLMMBsAmiGNnFPCNCTnZDCleHK2kEu2bxm2rYlRs/LzsoUmMgboc5RDrYOxh2Dfl9FLjfrYb74oh7WhqYnPsT1RuRpgrrcE5zRtsXCtTAG/PzeacAGcrE4d58bGiA63Kw35Gu8ZiT2/1Z3v93C2iNZWT8tr2X3S2eUqjFFwRRpFPSY=.6p68gFBha" type="hidden"> </form>
But the pop up says Missing or invalid token. Is there a way to validate a Token?
08-16-2017 02:36 PM
settings[2] = new settingType(); settings[2].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString(); settings[2].settingValue = "{\"url\": \"https://YOUR_FANCY_WEBSITE.com/icommunicator.aspx\"}";
Test token: https://nexwebsites.com/authorizenet/token-tester.html
By the way, the input name for the token needs to be "token".
name="token"
08-16-2017 03:17 PM - edited 08-16-2017 03:26 PM