private void RunSample(OffAmazonPaymentsServiceAutomaticPaymentsSimpleCheckout automaticPayments,
            string billingAgreementId, string paymentAmount, int shippingOption)
        {
            /************************************************************************
             * Invoke Get Billing Agreement Details Action
             ***********************************************************************/
            GetBillingAgreementDetailsResponse getDetailsResponse = automaticPayments.GetBillingAgreementDetails();
            if (getDetailsResponse == null)
                throw new OffAmazonPaymentsServiceException("The response from GetBillingAgreementDetails request is null");

            /************************************************************************
             * Add the tax and shipping rates here
             * Get the rates by using the CountryCode and the StateOrRegionCode from the billingAgreementDetails
             ***********************************************************************/
            Destination destination = getDetailsResponse.GetBillingAgreementDetailsResult.BillingAgreementDetails.Destination;
            TaxAndShippingRates rates = new TaxAndShippingRates(destination);
            string totalAmount = rates.getTotalAmountWithTaxAndShipping(Convert.ToDouble(paymentAmount), shippingOption).ToString("0.##");

            Address address = destination.PhysicalDestination;
            lblShipping.Text = "The shipping address is: <br>" + address.City + "<br>" + address.StateOrRegion + "<br>" + address.PostalCode + "<br>"
                + "The total amount with tax and shipping is: " + totalAmount + "<br>";

            /************************************************************************
             * Invoke Set Billing Agreement Details Action
             ***********************************************************************/
            if (automaticPayments.SetBillingAgreementDetails() == null)
                throw new OffAmazonPaymentsServiceException("The response from SetBillingAgreementDetails request is null");

            /************************************************************************
             * Invoke Confirm Billing Agreement Action
             ***********************************************************************/
            if (automaticPayments.ConfirmBillingAgreement() == null)
                throw new OffAmazonPaymentsServiceException("The response from ConfirmBillingAgreement request is null");

            /************************************************************************
             * Invoke Validate Billing Agreement Action (Optional)
             ***********************************************************************/
            if (automaticPayments.ValidateBillingAgreement() == null)
                throw new OffAmazonPaymentsServiceException("The response from ValidateBillingAgreement request is null");

            /************************************************************************
             * Make the first payment
             ***********************************************************************/
            MakePayment(automaticPayments, totalAmount, 1, false);

            /************************************************************************
             * Make the second payment
             ***********************************************************************/
            MakePayment(automaticPayments, totalAmount, 2, false);

            /************************************************************************
             * Make the third payment with capture now
             ***********************************************************************/
            MakePayment(automaticPayments, totalAmount, 3, true);

            /************************************************************************
             * Invoke Close Billing Agreement Action
             ***********************************************************************/
            if (automaticPayments.CloseBillingAgreement() == null)
                throw new OffAmazonPaymentsServiceException("The response from CloseBillingAgreement request is null");

            /************************************************************************
             * Wait for the notification from ipn.aspx page in a loop, then print the corresponding information
             ***********************************************************************/
            lblNotification.Text += formatStringForDisplay(WaitAndGetNotificationDetails(billingAgreementId + "_BillingAgreement"));
        }
        private static void RunSample(OffAmazonPaymentsServiceAutomaticPaymentsSimpleCheckout automaticPayments,
            string billingAgreementId, double paymentAmount, int shippingOption)
        {
            /************************************************************************
             * Invoke Get Billing Agreement Details Action
             ***********************************************************************/
            GetBillingAgreementDetailsResponse getDetailsResponse = automaticPayments.GetBillingAgreementDetails();
            if (getDetailsResponse == null)
                throw new OffAmazonPaymentsServiceException("The response from GetBillingAgreementDetails request is null");

            /************************************************************************
             * Add the tax and shipping rates here
             * Get the rates by using the CountryCode and the StateOrRegionCode from the billingAgreementDetails
             ***********************************************************************/
            Destination destination = getDetailsResponse.GetBillingAgreementDetailsResult.BillingAgreementDetails.Destination;
            TaxAndShippingRates rates = new TaxAndShippingRates(destination);
            string totalAmount = rates.getTotalAmountWithTaxAndShipping(paymentAmount, shippingOption).ToString("0.##");

            Console.WriteLine("=========================Tax and Shipping Calculation========================");
            Console.WriteLine("The tax and shipping rate will be calculated based on the CountryCode: " + destination.PhysicalDestination.CountryCode
                + " and the StateOrRegionCode: " + destination.PhysicalDestination.StateOrRegion);
            Console.WriteLine("The total amount is " + totalAmount);
            Console.WriteLine("=============================================================================");

            /************************************************************************
             * Invoke Set Billing Agreement Details Action
             ***********************************************************************/
            if (automaticPayments.SetBillingAgreementDetails() == null)
                throw new OffAmazonPaymentsServiceException("The response from SetBillingAgreementDetails request is null");
            Console.WriteLine("=============================================================================");

            /************************************************************************
             * Invoke Confirm Billing Agreement Action
             ***********************************************************************/
            if (automaticPayments.ConfirmBillingAgreement() == null)
                throw new OffAmazonPaymentsServiceException("The response from ConfirmBillingAgreement request is null");
            Console.WriteLine("=============================================================================");

            /************************************************************************
             * Invoke Validate Billing Agreement Action (Optional)
             ***********************************************************************/
            if (automaticPayments.ValidateBillingAgreement() == null)
                throw new OffAmazonPaymentsServiceException("The response from ValidateBillingAgreement request is null");
            Console.WriteLine("=============================================================================");

            /************************************************************************
             * Make the first payment
             ***********************************************************************/
            MakePayment(automaticPayments, totalAmount, 1, false);

            /************************************************************************
             * Make the second payment
             ***********************************************************************/
            MakePayment(automaticPayments, totalAmount, 2, false);

            /************************************************************************
             * Make the third payment with capture now
             ***********************************************************************/
            MakePayment(automaticPayments, totalAmount, 3, true);

            /************************************************************************
             * Invoke Close Billing Agreement Action
             ***********************************************************************/
            if (automaticPayments.CloseBillingAgreement() == null)
                throw new OffAmazonPaymentsServiceException("The response from CloseBillingAgreement request is null");
        }