private void MakePayment(OffAmazonPaymentsServiceAutomaticPaymentsSimpleCheckout automaticPayments,
            string totalAmount, int indicator, bool captureNow)
        {
            lblNotification.Text += "<br>-----Making payment with indicator " + indicator.ToString() + "<br>";

            /************************************************************************
             * Invoke Authorize on Billing Agreement Action
             ***********************************************************************/
            AuthorizeOnBillingAgreementResponse authResponse = automaticPayments.AuthorizeOnBillingAgreement(totalAmount, indicator, captureNow);
            if (authResponse == null)
                throw new OffAmazonPaymentsServiceException("The response from AuthorizeOnBillingAgreement request is null");

            /************************************************************************
             * Wait for the notification from ipn.aspx page in a loop, then print the corresponding information
             ***********************************************************************/
            lblNotification.Text += formatStringForDisplay(WaitAndGetNotificationDetails(authResponse.AuthorizeOnBillingAgreementResult.AuthorizationDetails.AmazonAuthorizationId + "_Authorize"));
            GetAuthorizationDetailsResponse response = automaticPayments.CheckAuthorizationStatus(authResponse);

            /************************************************************************
             * On an IPN callback, call GetAuthorizationDetails to retreive additional
             * information about the authorization - this is done as part of the
             * previous call to check the status.
             ***********************************************************************/
            StringWriter stringWriter = new StringWriter();
            GetAuthorizationDetailsSample.printGetAuthorizationDetailsResponseToBuffer(response, stringWriter);
            lblNotification.Text += formatStringForDisplay(stringWriter.ToString());

            if (!captureNow)
            {
                /************************************************************************
                 * Invoke Capture Action
                 ***********************************************************************/
                CaptureResponse captureResponse = automaticPayments.Capture(authResponse, totalAmount, indicator);
                if (captureResponse == null)
                    throw new OffAmazonPaymentsServiceException("The response from Capture request is null");

                /************************************************************************
                 * Wait for the notification from ipn.aspx page in a loop, then print the corresponding information
                 ***********************************************************************/
                lblNotification.Text += formatStringForDisplay(WaitAndGetNotificationDetails(captureResponse.CaptureResult.CaptureDetails.AmazonCaptureId + "_Capture"));

                /************************************************************************
                 * Invoke Get Capture Details Action
                 ***********************************************************************/
                if (automaticPayments.GetCaptureDetail(captureResponse) == null)
                    throw new OffAmazonPaymentsServiceException("The response from GetCaptureDetail request is null");
            }

            lblNotification.Text += "-----Payment with indicator " + indicator.ToString() + " is complete<br><br>";
        }
        private static void MakePayment(OffAmazonPaymentsServiceAutomaticPaymentsSimpleCheckout automaticPayments,
            string totalAmount, int indicator, bool captureNow)
        {
            Console.WriteLine("Making payment with indicator " + indicator.ToString());
            Console.WriteLine("=============================================================================");

            /************************************************************************
             * Invoke Authorize on Billing Agreement Action
             ***********************************************************************/
            AuthorizeOnBillingAgreementResponse authResponse = automaticPayments.AuthorizeOnBillingAgreement(totalAmount, indicator, captureNow);
            if (authResponse == null)
                throw new OffAmazonPaymentsServiceException("The response from AuthorizeOnBillingAgreement request is null");
            Console.WriteLine("=============================================================================");

            /************************************************************************
             * Check the authorization status unitl it is not "PENDING" any more
             * GetAuthorizationDetails is contained in this method
             ***********************************************************************/
            automaticPayments.CheckAuthorizationStatus(authResponse);

            if (!captureNow)
            {
                /************************************************************************
                 * Invoke Capture Action
                 ***********************************************************************/
                CaptureResponse captureResponse = automaticPayments.Capture(authResponse, totalAmount, indicator);
                if (captureResponse == null)
                    throw new OffAmazonPaymentsServiceException("The response from Capture request is null");
                Console.WriteLine("=============================================================================");

                /************************************************************************
                 * Invoke Get Capture Details Action
                 ***********************************************************************/
                if (automaticPayments.GetCaptureDetail(captureResponse) == null)
                    throw new OffAmazonPaymentsServiceException("The response from GetCaptureDetail request is null");
                Console.WriteLine("=============================================================================");
            }

            Console.WriteLine("Payment with indicator " + indicator.ToString() + " is complete");
            Console.WriteLine("=============================================================================");
        }