public void MockcreateCustomerPaymentProfileTest()
	    {
		    //define all mocked objects as final
            var mockController = GetMockController<createCustomerPaymentProfileRequest, createCustomerPaymentProfileResponse>();
            var mockRequest = new createCustomerPaymentProfileRequest
                {
                    merchantAuthentication = new merchantAuthenticationType {name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey},
                };
            var mockResponse = new createCustomerPaymentProfileResponse
                {
                    refId = "1234",
                    sessionToken = "sessiontoken",
                    customerPaymentProfileId = "1234",
                    validationDirectResponse = "mockValidation",
                };

		    var errorResponse = new ANetApiResponse();
		    var results = new List<String>();
            const messageTypeEnum messageTypeOk = messageTypeEnum.Ok;

            SetMockControllerExpectations<createCustomerPaymentProfileRequest, createCustomerPaymentProfileResponse, createCustomerPaymentProfileController>(
                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.customerPaymentProfileId);
            LogHelper.info(Logger, "createCustomerPaymentProfile: Details:{0}", controllerResponse.customerPaymentProfileId);
	    }
コード例 #2
0
        public static void Run(String ApiLoginID, String ApiTransactionKey)
        {
            Console.WriteLine("CreateCustomerPaymentProfile Sample");
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = ApiTransactionKey,
            };

            var bankAccount = new bankAccountType
            {
                accountNumber = "01245524321",
                routingNumber = "000000204",
                accountType = bankAccountTypeEnum.checking,
                echeckType = echeckTypeEnum.WEB,
                nameOnAccount = "test",
                bankName = "Bank Of America"
            };

            paymentType echeck = new paymentType {Item = bankAccount};

            customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();
            echeckPaymentProfile.payment = echeck;

            var request = new createCustomerPaymentProfileRequest
            {
                customerProfileId = "35772885",
                paymentProfile = echeckPaymentProfile,
                validationMode = validationModeEnum.none
            };

            //Prepare Request
            var controller = new createCustomerPaymentProfileController(request);
            controller.Execute();

             //Send Request to EndPoint
            createCustomerPaymentProfileResponse response = controller.GetApiResponse(); 
            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response != null && response.messages.message != null)
                {
                    Console.WriteLine("Success, createCustomerPaymentProfileID : " + response.customerPaymentProfileId);
                }
            }
            else
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                if (response.messages.message[0].code == "E00039")
                {
                    Console.WriteLine("Duplicate ID: " + response.customerPaymentProfileId);
                }
            }

        }
コード例 #3
0
        private TokenizedRequest CreateDetokenizeRequest(string customerProfileId, string token, int expMonth, int expYear)
        {
            var endpoint       = TransactionRequest.TestMode ? HttpXmlUtility.TEST_URL : HttpXmlUtility.URL;
            var paymentProfile = new customerPaymentProfileType
            {
                payment = new paymentType
                {
                    Item = new creditCardType
                    {
                        cardNumber     = FormatToken(token),
                        cardCode       = FormatCVV,
                        expirationDate = $"{expYear:D2}{expMonth:D2}"
                    }
                }
            };

            var transactionRequest = new createCustomerPaymentProfileRequest
            {
                merchantAuthentication = GetMerchantAuthenticationType(),
                customerProfileId      = customerProfileId,
                paymentProfile         = paymentProfile
            };

            var serializer = new XmlSerializer(typeof(createCustomerPaymentProfileRequest));

            using (var content = new StringWriter())
            {
                using (var writer = XmlWriter.Create(content))
                {
                    serializer.Serialize(writer, transactionRequest);
                    return(new TokenizedRequest()
                    {
                        Data = content.ToString(),
                        DataFormat = "text/xml",
                        Endpoint = endpoint
                    });
                }
            }
        }
コード例 #4
0
 public static void createCustomerPaymentProfileRequest(createCustomerPaymentProfileRequest argument)
 {
     if (null != argument)
     {
         customerPaymentProfileType(argument.paymentProfile);
         if (0 <= argument.validationMode) { argument.validationModeSpecified = true; }
     }
 }
コード例 #5
0
 public static void createCustomerPaymentProfileRequest ( createCustomerPaymentProfileRequest request) 
 {
     if (null != request)
     {
         if (0 <= (int)request.validationMode) { request.validationModeSpecified = true; }
     }
 }