public void MockgetHostedProfilePageTest() { //define all mocked objects as final var mockController = GetMockController<getHostedProfilePageRequest, getHostedProfilePageResponse>(); var mockRequest = new getHostedProfilePageRequest { merchantAuthentication = new merchantAuthenticationType {name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey}, }; var mockResponse = new getHostedProfilePageResponse { refId = "1234", sessionToken = "sessiontoken", token = "token1234", }; var errorResponse = new ANetApiResponse(); var results = new List<String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations<getHostedProfilePageRequest, getHostedProfilePageResponse, getHostedProfilePageController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.token); LogHelper.info(Logger, "getHostedProfilePage: Details:{0}", controllerResponse.token); }
public static void Run(string ApiLoginId, string ApiTransactionKey) { Console.WriteLine("Get Hosted Profile Page 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 customerProfileId = "36152116"; settingType[] settings = new settingType[]{ new settingType() // More settings can be added here as and when required }; settings[0] = new settingType(); settings[0].settingName = settingNameEnum.hostedProfileReturnUrl.ToString(); settings[0].settingValue = "https://returnurl.com/return/"; var request = new getHostedProfilePageRequest(); request.customerProfileId = customerProfileId; request.hostedProfileSettings = settings; var controller = new getHostedProfilePageController(request); controller.Execute(); var response = controller.GetApiResponse(); if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { Console.WriteLine(response.messages.message[0].code); Console.WriteLine(response.messages.message[0].text); Console.WriteLine("Token: " + response.token.ToString()); } else { Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); } }
public static void getHostedProfilePageRequest(getHostedProfilePageRequest argument) { if (null != argument) { if (null != argument.hostedProfileSettings) { foreach (var value in argument.hostedProfileSettings) { settingType(value); } } } }
public static void getHostedProfilePageRequest(getHostedProfilePageRequest request) { }