public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string subscriptionId)
        {
            Console.WriteLine("Get Subscription Sample");

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
            {
                name = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item = ApiTransactionKey
            };

            var request = new ARBGetSubscriptionRequest { subscriptionId = subscriptionId };

            var controller = new ARBGetSubscriptionController(request);          // instantiate the contoller that will call the service
            controller.Execute();

            ARBGetSubscriptionResponse response = controller.GetApiResponse();   // get the response from the service (errors contained if any)

            //validate
            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response.subscription != null)
                {
                    Console.WriteLine("Subscription returned : " + response.subscription.name);
                }
            }
            else if (response != null)
            {
                if (response.messages.message.Length > 0)
                {
                    Console.WriteLine("Error: " + response.messages.message[0].code + "  " +
                                      response.messages.message[0].text);
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                }
            }

            return response;
        }
 public static void ARBGetSubscriptionRequest(ARBGetSubscriptionRequest argument)
 {
     if (null != argument)
     {
     }
 }
	    public void MockARBGetSubscriptionTest()
	    {
		    //define all mocked objects as final
            var mockController = GetMockController<ARBGetSubscriptionRequest, ARBGetSubscriptionResponse>();
            var mockRequest = new ARBGetSubscriptionRequest
                {
                    merchantAuthentication = new merchantAuthenticationType() {name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey},
                    subscriptionId = "1234"
                };

            var customerPaymentProfileMaskedType = new customerPaymentProfileMaskedType
                {
                    customerPaymentProfileId = "1234",
                };

            Random rnd = new Random(DateTime.Now.Millisecond);
            var SubscriptionMaskedType = new ARBSubscriptionMaskedType()
            {
                name = "Test",
                paymentSchedule = new paymentScheduleType
                {
                    interval = new paymentScheduleTypeInterval
                    {
                        length = 1,
                        unit = ARBSubscriptionUnitEnum.months,
                    },
                    startDate = DateTime.UtcNow,
                    totalOccurrences = 12
                },
                amount = 9.99M,
                amountSpecified = true,
                trialAmount = 100,
                trialAmountSpecified = true,
                status = ARBSubscriptionStatusEnum.active,
                statusSpecified = true,
                profile = new subscriptionCustomerProfileType()
                {
                    paymentProfile = customerPaymentProfileMaskedType,

                },
                order = new orderType { description = string.Format("member monthly {0}", rnd.Next(99999)) }               
            };

            var mockResponse = new ARBGetSubscriptionResponse
                {
                    refId = "1234",
                    sessionToken = "sessiontoken",
                    subscription = SubscriptionMaskedType
                };

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

            SetMockControllerExpectations<ARBGetSubscriptionRequest, ARBGetSubscriptionResponse, ARBGetSubscriptionController>(
                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.subscription);
            LogHelper.info(Logger, "ARBGetSubscription: Details:{0}", controllerResponse.subscription);
	    }
        public void ARBGetSubscriptionSampleTest()
        {
            LogHelper.info(Logger, "Sample GetSubscriptionList");

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = TestEnvironment;

            //create a subscription
            var createRequest = new ARBCreateSubscriptionRequest
            {
                refId = RefId,
                subscription = ArbSubscriptionOne,
            };

            var createController = new ARBCreateSubscriptionController(createRequest);
            createController.Execute();
            var createResponse = createController.GetApiResponse();
            Assert.IsNotNull(createResponse.subscriptionId);
            LogHelper.info(Logger, "Created Subscription: {0}", createResponse.subscriptionId);
            var subscriptionId = createResponse.subscriptionId;

            //get subscription details
            var getRequest = new ARBGetSubscriptionRequest
            {
                refId = RefId,
                subscriptionId = subscriptionId
            };
            var getController = new ARBGetSubscriptionController(getRequest);
            var getResponse = getController.ExecuteWithApiResponse();
            Assert.IsNotNull(getResponse.subscription);
            Logger.info(String.Format("Subscription Name : {0}", getResponse.subscription.name));
            Assert.AreEqual(ArbSubscriptionOne.name, getResponse.subscription.name);
            Assert.AreEqual(ArbSubscriptionOne.amountSpecified, getResponse.subscription.amountSpecified);

            //cancel subscription
            var cancelRequest = new ARBCancelSubscriptionRequest
            {
                merchantAuthentication = CustomMerchantAuthenticationType,
                refId = RefId,
                subscriptionId = subscriptionId
            };
            var cancelController = new ARBCancelSubscriptionController(cancelRequest);
            var cancelResponse = cancelController.ExecuteWithApiResponse(TestEnvironment);
            Assert.IsNotNull(cancelResponse.messages);
            Logger.info(String.Format("Subscription Cancelled: {0}", subscriptionId));
        }