//Create Customer Profile and Customer Payment Profile, returning their IDs. private Boolean createProfile(out String customerProfileId, out String paymentProfileId) { ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = TestEnvironment; var rnd = new AnetRandom(DateTime.Now.Millisecond); string custIndx = rnd.Next(99999).ToString(); var creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0622" }; var paymentType = new paymentType { Item = creditCard }; var paymentProfile = new customerPaymentProfileType { payment = paymentType }; var createRequest = new createCustomerProfileRequest { profile = new customerProfileType { merchantCustomerId = "TSTCSTER" + custIndx, paymentProfiles = new customerPaymentProfileType[] { paymentProfile } } }; //create profiles and get response var createController = new createCustomerProfileController(createRequest); var createResponse = createController.ExecuteWithApiResponse(); //validate response if (messageTypeEnum.Ok != createResponse.messages.resultCode) { customerProfileId = "0"; paymentProfileId = "0"; return(false); } else { Assert.NotNull(createResponse.customerProfileId); Assert.NotNull(createResponse.customerPaymentProfileIdList); Assert.AreNotEqual(0, createResponse.customerPaymentProfileIdList.Length); customerProfileId = createResponse.customerProfileId; paymentProfileId = createResponse.customerPaymentProfileIdList[0]; return(true); } }
public void GetCustomerPaymentProfileListSampleTest() { LogHelper.info(Logger, "Sample getCustomerPaymentProfileList"); ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = TestEnvironment; CustomerProfileType.paymentProfiles = new customerPaymentProfileType[] { getCustomerPaymentProfileObject() }; var createRequest = new createCustomerProfileRequest { refId = RefId, profile = CustomerProfileType }; //create a customer profile var createController = new createCustomerProfileController(createRequest); var createResponse = createController.ExecuteWithApiResponse(); Assert.NotNull(createResponse); LogHelper.info(Logger, "Created Customer profile : {0}", createResponse.customerProfileId); var getProfileListRequest = new getCustomerPaymentProfileListRequest { refId = RefId, searchType = CustomerPaymentProfileSearchTypeEnum.cardsExpiringInMonth, month = "2032-10" }; bool found = false; //setup retry loop to allow for delays in replication for (int counter = 0; counter < 5; counter++) { //get customer profile list var getProfileController = new getCustomerPaymentProfileListController(getProfileListRequest); var getProfileListResponse = getProfileController.ExecuteWithApiResponse(); for (int profile = 0; profile < getProfileListResponse.paymentProfiles.Length; profile++) { var profileId = Convert.ToString(getProfileListResponse.paymentProfiles[profile].customerPaymentProfileId); if (profileId.Equals(createResponse.customerPaymentProfileIdList[0])) { found = true; break; } } if (found) { break; } System.Threading.Thread.Sleep(10000); } Assert.IsTrue(found); //delete the created customer profile var deleteRequest = new deleteCustomerProfileRequest { refId = RefId, customerProfileId = createResponse.customerProfileId }; var deleteController = new deleteCustomerProfileController(deleteRequest); var deleteResponse = deleteController.ExecuteWithApiResponse(); Assert.IsNotNull(deleteResponse); }
//Create Customer Profile and Customer Payment Profile, returning their IDs. private Boolean createProfile(out String customerProfileId, out String paymentProfileId) { ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment; var rnd = new AnetRandom(DateTime.Now.Millisecond); string custIndx = rnd.Next(99999).ToString(); var creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0622" }; var paymentType = new paymentType {Item = creditCard}; var paymentProfile = new customerPaymentProfileType{ payment = paymentType }; var createRequest = new createCustomerProfileRequest { profile = new customerProfileType{ merchantCustomerId = "TSTCSTER"+custIndx, paymentProfiles = new customerPaymentProfileType[]{ paymentProfile } } }; //create profiles and get response var createController = new createCustomerProfileController(createRequest); var createResponse = createController.ExecuteWithApiResponse(); //validate response if (messageTypeEnum.Ok != createResponse.messages.resultCode) { customerProfileId = "0"; paymentProfileId = "0"; return false; } else { Assert.NotNull(createResponse.customerProfileId); Assert.NotNull(createResponse.customerPaymentProfileIdList); Assert.AreNotEqual(0, createResponse.customerPaymentProfileIdList.Length); customerProfileId = createResponse.customerProfileId; paymentProfileId = createResponse.customerPaymentProfileIdList[0]; return true; } }
public void GetCustomerPaymentProfileListSampleTest() { LogHelper.info(Logger, "Sample getCustomerPaymentProfileList"); ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment; CustomerProfileType.paymentProfiles = new customerPaymentProfileType[] { getCustomerPaymentProfileObject() }; var createRequest = new createCustomerProfileRequest { refId = RefId, profile = CustomerProfileType }; //create a customer profile var createController = new createCustomerProfileController(createRequest); var createResponse = createController.ExecuteWithApiResponse(); Assert.NotNull(createResponse); LogHelper.info(Logger, "Created Customer profile : {0}", createResponse.customerProfileId); var getProfileListRequest = new getCustomerPaymentProfileListRequest { refId = RefId, searchType = CustomerPaymentProfileSearchTypeEnum.cardsExpiringInMonth, month = "2032-10" }; bool found = false; //setup retry loop to allow for delays in replication for (int counter = 0; counter < 5; counter++) { //get customer profile list var getProfileController = new getCustomerPaymentProfileListController(getProfileListRequest); var getProfileListResponse = getProfileController.ExecuteWithApiResponse(); for (int profile = 0; profile < getProfileListResponse.paymentProfiles.Length; profile++) { var profileId = Convert.ToString(getProfileListResponse.paymentProfiles[profile].customerPaymentProfileId); if (profileId.Equals(createResponse.customerPaymentProfileIdList[0])) { found = true; break; } } if (found) break; System.Threading.Thread.Sleep(10000); } Assert.IsTrue(found); //delete the created customer profile var deleteRequest = new deleteCustomerProfileRequest { refId = RefId, customerProfileId = createResponse.customerProfileId }; var deleteController = new deleteCustomerProfileController(deleteRequest); var deleteResponse = deleteController.ExecuteWithApiResponse(); Assert.IsNotNull(deleteResponse); }