On requests, you must set the currencyID attribute to one of the three-character currency codes for any of the supported PayPal currencies. Limitations: Must not exceed $10,000 USD in any currency. No currency symbol. Decimal separator must be a period (.), and the thousands separator must be a comma (,).
        protected void Search_Submit(object sender, EventArgs e)
        {
            // Create request object
            TransactionSearchRequestType request = new TransactionSearchRequestType();
            if (transactionID.Value != "")
            {
                request.TransactionID = transactionID.Value;
            }
            if (startDate != null && startDate.Text != null)
            {
                request.StartDate = startDate.Text;
            }
            if (endDate != null && endDate.Text != null)
            {
                request.EndDate = endDate.Text;
            }
            if (payer.Value != "")
            {
                request.Payer = payer.Value;
            }
            if (receiver.Value != "")
            {
                request.Receiver = receiver.Value;
            }
            if (receiptId.Value != "")
            {
                request.ReceiptID = receiptId.Value;
            }
            if (profileId.Value != "")
            {
                request.ProfileID = profileId.Value;
            }
            if (auctionItemNumber.Value != "")
            {
                request.AuctionItemNumber = auctionItemNumber.Value;
            }
            if (invoiceID.Value != "")
            {
                request.InvoiceID = invoiceID.Value;
            }
            if (cardNumber.Value != "")
            {
                request.CardNumber = cardNumber.Value;
            }
            if (transactionClass.SelectedIndex != 0)
            {
                request.TransactionClass = (PaymentTransactionClassCodeType)
                    Enum.Parse(typeof(PaymentTransactionClassCodeType), transactionClass.SelectedValue);
            }
            if (amount.Value != "" && currencyCode.SelectedIndex != 0)
            {
                request.CurrencyCode = (CurrencyCodeType)
                    Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
                BasicAmountType searchAmount = new BasicAmountType(request.CurrencyCode, amount.Value);
                request.Amount = searchAmount;

            }
            if (transactionStatus.SelectedIndex != 0)
            {
                request.Status = (PaymentTransactionStatusCodeType)
                    Enum.Parse(typeof(PaymentTransactionStatusCodeType), transactionStatus.SelectedValue);
            }

            // Invoke the API
            TransactionSearchReq wrapper = new TransactionSearchReq();
            wrapper.TransactionSearchRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            TransactionSearchResponseType transactionDetails = service.TransactionSearch(wrapper);

            // Check for API return status
            processResponse(service, transactionDetails);
        }
        // <summary>
        /// Handles DoAuthorization
        /// </summary>
        /// <param name="contextHttp"></param>
        private void DoAuthorization(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<String, String> configurationMap = Configuration.GetAcctAndConfig();

            // Creating service wrapper object to make an API call by loading configuration map.
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            DoAuthorizationReq req = new DoAuthorizationReq();

            // 'Amount' which takes mandatory params:
            // * 'currencyCode'
            // * 'amount'
            BasicAmountType amount = new BasicAmountType(((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"])), parameters["amt"]);

            // 'DoAuthorizationRequest' which takes mandatory params:
            // * 'Transaction ID' - Value of the order's transaction identification
            // number returned by PayPal.
            // * 'Amount' - Amount to authorize.
            DoAuthorizationRequestType reqType = new DoAuthorizationRequestType(parameters["authID"], amount);

            req.DoAuthorizationRequest = reqType;
            DoAuthorizationResponseType response = null;
            try
            {
                response = service.DoAuthorization(req);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.StackTrace);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;

            if (!response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
            {
                responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());
                responseValues.Add("TransactionId", response.TransactionID);
            }
            else
            {
                responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());
            }

            Display(contextHttp, "DoAuthorization", "DoAuthorization", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public SetMobileCheckoutRequestDetailsType(BasicAmountType itemAmount, string itemName, string returnURL)
 {
     this.ItemAmount = itemAmount;
     this.ItemName = itemName;
     this.ReturnURL = returnURL;
 }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public ActivationDetailsType(BasicAmountType initialAmount)
 {
     this.InitialAmount = initialAmount;
 }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public DoReauthorizationRequestType(string authorizationID, BasicAmountType amount)
 {
     this.AuthorizationID = authorizationID;
     this.Amount = amount;
 }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public DoAuthorizationRequestType(string transactionID, BasicAmountType amount)
 {
     this.TransactionID = transactionID;
     this.Amount = amount;
 }
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            DoDirectPaymentRequestType request = new DoDirectPaymentRequestType();
            DoDirectPaymentRequestDetailsType requestDetails = new DoDirectPaymentRequestDetailsType();
            request.DoDirectPaymentRequestDetails = requestDetails;

            // (Optional) How you want to obtain payment. It is one of the following values:
            // * Authorization – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture.
            // * Sale – This is a final sale for which you are requesting payment (default).
            // Note: Order is not allowed for Direct Payment.
            requestDetails.PaymentAction = (PaymentActionCodeType)
                Enum.Parse(typeof(PaymentActionCodeType), paymentType.SelectedValue);

            // (Required) Information about the credit card to be charged.
            CreditCardDetailsType creditCard = new CreditCardDetailsType();
            requestDetails.CreditCard = creditCard;
            PayerInfoType payer = new PayerInfoType();
            // (Optional) First and last name of buyer.
            PersonNameType name = new PersonNameType();
            name.FirstName = firstName.Value;
            name.LastName = lastName.Value;
            payer.PayerName = name;
            // (Required) Details about the owner of the credit card.
            creditCard.CardOwner = payer;

            // (Required) Credit card number.
            creditCard.CreditCardNumber = creditCardNumber.Value;
            // (Optional) Type of credit card. For UK, only Maestro, MasterCard, Discover, and Visa are allowable. For Canada, only MasterCard and Visa are allowable and Interac debit cards are not supported. It is one of the following values:
            // * Visa
            // * MasterCard
            // * Discover
            // * Amex
            // * Maestro: See note.
            // Note: If the credit card type is Maestro, you must set currencyId to GBP. In addition, you must specify either StartMonth and StartYear or IssueNumber.
            creditCard.CreditCardType = (CreditCardTypeType)
                Enum.Parse(typeof(CreditCardTypeType), creditCardType.SelectedValue);
            // Card Verification Value, version 2. Your Merchant Account settings determine whether this field is required. To comply with credit card processing regulations, you must not store this value after a transaction has been completed.
            // Character length and limitations: For Visa, MasterCard, and Discover, the value is exactly 3 digits. For American Express, the value is exactly 4 digits.
            creditCard.CVV2 = cvv2Number.Value;
            string[] cardExpiryDetails = cardExpiryDate.Text.Split(new char[] { '/' });
            if (cardExpiryDetails.Length == 2)
            {
                // (Required) Credit card expiration month.
                creditCard.ExpMonth = Convert.ToInt32(cardExpiryDetails[0]);
                // (Required) Credit card expiration year.
                creditCard.ExpYear = Convert.ToInt32(cardExpiryDetails[1]);
            }

            requestDetails.PaymentDetails = new PaymentDetailsType();
            // (Optional) Your URL for receiving Instant Payment Notification (IPN) about this transaction. If you do not specify this value in the request, the notification URL from your Merchant Profile is used, if one exists.
            // Important: The notify URL applies only to DoExpressCheckoutPayment. This value is ignored when set in SetExpressCheckout or GetExpressCheckoutDetails.
            requestDetails.PaymentDetails.NotifyURL = ipnNotificationUrl.Value.Trim();

            // (Optional) Buyer's shipping address information.
            AddressType billingAddr = new AddressType();
            if (firstName.Value != string.Empty && lastName.Value != string.Empty
                && street1.Value != string.Empty && country.Value != string.Empty)
            {
                billingAddr.Name = payerName.Value;
                // (Required) First street address.
                billingAddr.Street1 = street1.Value;
                // (Optional) Second street address.
                billingAddr.Street2 = street2.Value;
                // (Required) Name of city.
                billingAddr.CityName = city.Value;
                // (Required) State or province.
                billingAddr.StateOrProvince = state.Value;
                // (Required) Country code.
                billingAddr.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.Value);
                // (Required) U.S. ZIP code or other country-specific postal code.
                billingAddr.PostalCode = postalCode.Value;

                // (Optional) Phone number.
                billingAddr.Phone = phone.Value;

                payer.Address = billingAddr;
            }

            // (Required) The total cost of the transaction to the buyer. If shipping cost and tax charges are known, include them in this value. If not, this value should be the current subtotal of the order. If the transaction includes one or more one-time purchases, this field must be equal to the sum of the purchases. This field must be set to a value greater than 0.
            // Note: You must set the currencyID attribute to one of the 3-character currency codes for any of the supported PayPal currencies.
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
            BasicAmountType paymentAmount = new BasicAmountType(currency, amount.Value);
            requestDetails.PaymentDetails.OrderTotal = paymentAmount;

            // Invoke the API
            DoDirectPaymentReq wrapper = new DoDirectPaymentReq();
            wrapper.DoDirectPaymentRequest = request;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // # API call
            // Invoke the DoDirectPayment method in service wrapper object
            DoDirectPaymentResponseType response = service.DoDirectPayment(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, response);
        }
        // # DoExpressCheckoutPayment API Operation
        // The DoExpressCheckoutPayment API operation completes an Express Checkout transaction.
        // If you set up a billing agreement in your SetExpressCheckout API call,
        // the billing agreement is created when you call the DoExpressCheckoutPayment API operation.
        public DoExpressCheckoutPaymentResponseType DoExpressCheckoutPayment(string token, string payerId, string payment)
        {
            // Create the DoExpressCheckoutPaymentResponseType object
            DoExpressCheckoutPaymentResponseType responseDoExpressCheckoutPaymentResponseType = new DoExpressCheckoutPaymentResponseType();

            try
            {
                // Create the DoExpressCheckoutPaymentReq object
                DoExpressCheckoutPaymentReq doExpressCheckoutPayment = new DoExpressCheckoutPaymentReq();

                DoExpressCheckoutPaymentRequestDetailsType doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();

                // The timestamped token value that was returned in the
                // `SetExpressCheckout` response and passed in the
                // `GetExpressCheckoutDetails` request.
                doExpressCheckoutPaymentRequestDetails.Token = token;

                // Unique paypal buyer account identification number as returned in
                // `GetExpressCheckoutDetails` Response
                doExpressCheckoutPaymentRequestDetails.PayerID = payerId;

                // # Payment Information
                // list of information about the payment
                List<PaymentDetailsType> paymentDetailsList = new List<PaymentDetailsType>();

                // information about the first payment
                PaymentDetailsType paymentDetails1 = new PaymentDetailsType();

                // Total cost of the transaction to the buyer. If shipping cost and tax
                // charges are known, include them in this value. If not, this value
                // should be the current sub-total of the order.
                //
                // If the transaction includes one or more one-time purchases, this field must be equal to
                // the sum of the purchases. Set this field to 0 if the transaction does
                // not include a one-time purchase such as when you set up a billing
                // agreement for a recurring payment that is not immediately charged.
                // When the field is set to 0, purchase-specific fields are ignored.
                //
                // * `Currency Code` - You must set the currencyID attribute to one of the
                // 3-character currency codes for any of the supported PayPal
                // currencies.
                // * `Amount`
                BasicAmountType orderTotal1 = new BasicAmountType(CurrencyCodeType.USD, payment);
                paymentDetails1.OrderTotal = orderTotal1;
                paymentDetails1.OrderDescription = System.Web.Configuration.WebConfigurationManager.AppSettings["PaypalDescription"];

                // How you want to obtain payment. When implementing parallel payments,
                // this field is required and must be set to `Order`. When implementing
                // digital goods, this field is required and must be set to `Sale`. If the
                // transaction does not include a one-time purchase, this field is
                // ignored. It is one of the following values:
                //
                // * `Sale` - This is a final sale for which you are requesting payment
                // (default).
                // * `Authorization` - This payment is a basic authorization subject to
                // settlement with PayPal Authorization and Capture.
                // * `Order` - This payment is an order authorization subject to
                // settlement with PayPal Authorization and Capture.
                // Note:
                // You cannot set this field to Sale in SetExpressCheckout request and
                // then change the value to Authorization or Order in the
                // DoExpressCheckoutPayment request. If you set the field to
                // Authorization or Order in SetExpressCheckout, you may set the field
                // to Sale.
                paymentDetails1.PaymentAction = PaymentActionCodeType.SALE;

                // Unique identifier for the merchant. For parallel payments, this field
                // is required and must contain the Payer Id or the email address of the
                // merchant.
                SellerDetailsType sellerDetails1 = new SellerDetailsType();
                sellerDetails1.PayPalAccountID = System.Web.Configuration.WebConfigurationManager.AppSettings["PayPalAccountID"];
                paymentDetails1.SellerDetails = sellerDetails1;

                // A unique identifier of the specific payment request, which is
                // required for parallel payments.
                paymentDetails1.PaymentRequestID = "PaymentRequest1";

                // A unique identifier of the specific payment request, which is
                // required for parallel payments.
                paymentDetailsList.Add(paymentDetails1);
                doExpressCheckoutPaymentRequestDetails.PaymentDetails = paymentDetailsList;

                DoExpressCheckoutPaymentRequestType doExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType(doExpressCheckoutPaymentRequestDetails);
                doExpressCheckoutPayment.DoExpressCheckoutPaymentRequest = doExpressCheckoutPaymentRequest;

                // Create the service wrapper object to make the API call
                PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

                // # API call
                // Invoke the DoExpressCheckoutPayment method in service wrapper object
                responseDoExpressCheckoutPaymentResponseType = service.DoExpressCheckoutPayment(doExpressCheckoutPayment);

                return responseDoExpressCheckoutPaymentResponseType;
            }
            // # Exception log
            catch (System.Exception ex)
            {
                // Log the exception message
                levent.Level = LogLevel.Error;
                levent.Message = "Logon failed for PaypalExpressCheckout: " + ex.Message;
                log.Log(levent);
            }
            return responseDoExpressCheckoutPaymentResponseType;
        }
    // # DoDirectPaymentAPIOperation
    // The MassPay API operation makes a payment to one or more PayPal account holders.
    public DoDirectPaymentResponseType DoDirectPaymentAPIOperation()
    {
        // Create the DoDirectPaymentResponseType object
        DoDirectPaymentResponseType responseDoDirectPaymentResponseType = new DoDirectPaymentResponseType();

        try
        {
            // Create the DoDirectPaymentReq object
            DoDirectPaymentReq doDirectPayment = new DoDirectPaymentReq();
            DoDirectPaymentRequestDetailsType doDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();

            // Information about the credit card to be charged.
            CreditCardDetailsType creditCard = new CreditCardDetailsType();

            // Type of credit card. For UK, only Maestro, MasterCard, Discover, and
            // Visa are allowable. For Canada, only MasterCard and Visa are
            // allowable and Interac debit cards are not supported. It is one of the
            // following values:
            //
            // * Visa
            // * MasterCard
            // * Discover
            // * Amex
            // * Solo
            // * Switch
            // * Maestro: See note.
            // `Note:
            // If the credit card type is Maestro, you must set currencyId to GBP.
            // In addition, you must specify either StartMonth and StartYear or
            // IssueNumber.`
            creditCard.CreditCardType = CreditCardTypeType.VISA;

            // Credit Card number
            creditCard.CreditCardNumber = "4770461107194023";

            // ExpiryMonth of credit card
            creditCard.ExpMonth = Convert.ToInt32("12");

            // Expiry Year of credit card
            creditCard.ExpYear = Convert.ToInt32("2021");

            //Details about the owner of the credit card.
            PayerInfoType cardOwner = new PayerInfoType();

            // Email address of buyer.
            cardOwner.Payer = "*****@*****.**";
            creditCard.CardOwner = cardOwner;

            doDirectPaymentRequestDetails.CreditCard = creditCard;

            // Information about the payment
            PaymentDetailsType paymentDetails = new PaymentDetailsType();

            // IPN URL
            // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed        
            // * The transaction related IPN variables will be received on the call back URL specified in the request       
            // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"     
            // * PayPal would continuously resend IPN if a wrong IPN is sent        
            paymentDetails.NotifyURL = "http://IPNhost";

            // Total cost of the transaction to the buyer. If shipping cost and tax
            // charges are known, include them in this value. If not, this value
            // should be the current sub-total of the order.
            //
            // If the transaction includes one or more one-time purchases, this field must be equal to
            // the sum of the purchases. Set this field to 0 if the transaction does
            // not include a one-time purchase such as when you set up a billing
            // agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            //
            // * `Currency Code` - You must set the currencyID attribute to one of the
            // 3-character currency codes for any of the supported PayPal
            // currencies.
            // * `Amount`
            BasicAmountType orderTotal = new BasicAmountType(CurrencyCodeType.USD, "4.00");
            paymentDetails.OrderTotal = orderTotal;
            doDirectPaymentRequestDetails.PaymentDetails = paymentDetails;

            // IP address of the buyer's browser.
            // `Note:
            // PayPal records this IP addresses as a means to detect possible fraud.`
            doDirectPaymentRequestDetails.IPAddress = "127.0.0.1";

            DoDirectPaymentRequestType doDirectPaymentRequest = new DoDirectPaymentRequestType(doDirectPaymentRequestDetails);
            doDirectPayment.DoDirectPaymentRequest = doDirectPaymentRequest;

            // Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

            // # API call
            // Invoke the DoDirectPayment method in service wrapper object
            responseDoDirectPaymentResponseType = service.DoDirectPayment(doDirectPayment);

            if (responseDoDirectPaymentResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "DoDirectPayment API Operation - ";
                acknowledgement += responseDoDirectPaymentResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseDoDirectPaymentResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Unique identifier of the transaction
                    logger.Info("Transaction ID : " + responseDoDirectPaymentResponseType.TransactionID + "\n");
                    Console.WriteLine("Transaction ID : " + responseDoDirectPaymentResponseType.TransactionID + "\n");

                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoDirectPaymentResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseDoDirectPaymentResponseType;
    }
        private void populateRequest(CreateRecurringPaymentsProfileRequestType request)
        {
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), "USD");

            // Set EC-Token or Credit card requestDetails
            CreateRecurringPaymentsProfileRequestDetailsType profileDetails = new CreateRecurringPaymentsProfileRequestDetailsType();
            request.CreateRecurringPaymentsProfileRequestDetails = profileDetails;
            // A timestamped token, the value of which was returned in the response to the first call to SetExpressCheckout. You can also use the token returned in the SetCustomerBillingAgreement response. Either this token or a credit card number is required. If you include both token and credit card number, the token is used and credit card number is ignored Call CreateRecurringPaymentsProfile once for each billing agreement included in SetExpressCheckout request and use the same token for each call. Each CreateRecurringPaymentsProfile request creates a single recurring payments profile.
            // Note: Tokens expire after approximately 3 hours.
            if(token.Value != string.Empty)
            {
                profileDetails.Token = token.Value;
            }
            // Credit card information for recurring payments using direct payments. Either a token or a credit card number is required. If you include both token and credit card number, the token is used and credit card number is ignored.
            else if (creditCardNumber.Value != string.Empty && cvv.Value != string.Empty)
            {
                CreditCardDetailsType cc = new CreditCardDetailsType();
                // (Required) Credit card number.
                cc.CreditCardNumber = creditCardNumber.Value;
                // Card Verification Value, version 2. Your Merchant Account settings determine whether this field is required. To comply with credit card processing regulations, you must not store this value after a transaction has been completed.
                cc.CVV2 = cvv.Value;
                // (Required) Credit card expiration month.
                cc.ExpMonth = Convert.ToInt32(expMonth.SelectedValue);
                // (Required) Credit card expiration year.
                cc.ExpYear = Convert.ToInt32(expYear.SelectedValue);
                profileDetails.CreditCard = cc;
            }

            // Populate Recurring Payments Profile Details
            RecurringPaymentsProfileDetailsType rpProfileDetails =
                new RecurringPaymentsProfileDetailsType(billingStartDate.Text);
            profileDetails.RecurringPaymentsProfileDetails = rpProfileDetails;
            // (Optional) Full name of the person receiving the product or service paid for by the recurring payment. If not present, the name in the buyer's PayPal account is used.
            if(subscriberName.Value != string.Empty)
            {
                rpProfileDetails.SubscriberName = subscriberName.Value;
            }

            // (Optional) The subscriber's shipping address associated with this profile, if applicable. If not specified, the ship-to address from buyer's PayPal account is used.
            if(shippingName.Value != string.Empty && shippingStreet1.Value != string.Empty && shippingCity.Value != string.Empty
                && shippingState.Value != string.Empty && shippingPostalCode.Value != string.Empty && shippingCountry.Value != string.Empty)
            {
                AddressType shippingAddr = new AddressType();
                // Person's name associated with this shipping address. It is required if using a shipping address.
                shippingAddr.Name = shippingName.Value;
                // First street address. It is required if using a shipping address.
                shippingAddr.Street1 = shippingStreet1.Value;
                // Name of city. It is required if using a shipping address.
                shippingAddr.CityName = shippingCity.Value;
                // State or province. It is required if using a shipping address.
                shippingAddr.StateOrProvince = shippingState.Value;
                // Country code. It is required if using a shipping address.
                shippingAddr.CountryName = shippingCountry.Value;
                // U.S. ZIP code or other country-specific postal code. It is required if using a U.S. shipping address; may be required for other countries.
                shippingAddr.PostalCode = shippingPostalCode.Value;

                // (Optional) Second street address.
                if(shippingStreet2.Value != string.Empty)
                {
                    shippingAddr.Street2 = shippingStreet2.Value;
                }
                // (Optional) Phone number.
                if(shippingPhone.Value != string.Empty)
                {
                    shippingAddr.Phone = shippingPhone.Value;
                }
                rpProfileDetails.SubscriberShippingAddress = shippingAddr;
            }

            // (Required) Describes the recurring payments schedule, including the regular payment period, whether there is a trial period, and the number of payments that can fail before a profile is suspended.
            ScheduleDetailsType scheduleDetails = new ScheduleDetailsType();
            // (Required) Description of the recurring payment.
            // Note: You must ensure that this field matches the corresponding billing agreement description included in the SetExpressCheckout request.
            if(profileDescription.Value != string.Empty)
            {
                scheduleDetails.Description = profileDescription.Value;
            }
            // (Optional) Number of scheduled payments that can fail before the profile is automatically suspended. An IPN message is sent to the merchant when the specified number of failed payments is reached.
            if(maxFailedPayments.Value != string.Empty)
            {
                scheduleDetails.MaxFailedPayments = Convert.ToInt32(maxFailedPayments.Value);
            }
            // (Optional) Indicates whether you would like PayPal to automatically bill the outstanding balance amount in the next billing cycle. The outstanding balance is the total amount of any previously failed scheduled payments that have yet to be successfully paid. It is one of the following values:
            // * NoAutoBill – PayPal does not automatically bill the outstanding balance.
            // * AddToNextBilling – PayPal automatically bills the outstanding balance.
            if(autoBillOutstandingAmount.SelectedIndex != 0)
            {
                scheduleDetails.AutoBillOutstandingAmount = (AutoBillType)
                    Enum.Parse(typeof(AutoBillType), autoBillOutstandingAmount.SelectedValue);
            }
            // (Optional) Information about activating a profile, such as whether there is an initial non-recurring payment amount immediately due upon profile creation and how to override a pending profile PayPal suspends when the initial payment amount fails.
            if(initialAmount.Value != string.Empty)
            {
                // (Optional) Initial non-recurring payment amount due immediately upon profile creation. Use an initial amount for enrolment or set-up fees.
                // Note: All amounts included in the request must have the same currency.
                ActivationDetailsType activationDetails =
                    new ActivationDetailsType(new BasicAmountType(currency, initialAmount.Value));
                // (Optional) Action you can specify when a payment fails. It is one of the following values:
                // * ContinueOnFailure – By default, PayPal suspends the pending profile in the event that the initial payment amount fails. You can override this default behavior by setting this field to ContinueOnFailure. Then, if the initial payment amount fails, PayPal adds the failed payment amount to the outstanding balance for this recurring payment profile.
                //   When you specify ContinueOnFailure, a success code is returned to you in the CreateRecurringPaymentsProfile response and the recurring payments profile is activated for scheduled billing immediately. You should check your IPN messages or PayPal account for updates of the payment status.
                // * CancelOnFailure – If this field is not set or you set it to CancelOnFailure, PayPal creates the recurring payment profile, but places it into a pending status until the initial payment completes. If the initial payment clears, PayPal notifies you by IPN that the pending profile has been activated. If the payment fails, PayPal notifies you by IPN that the pending profile has been canceled.
                if(failedInitialAmountAction.SelectedIndex != 0)
                {
                    activationDetails.FailedInitialAmountAction = (FailedPaymentActionType)
                        Enum.Parse(typeof(FailedPaymentActionType), failedInitialAmountAction.SelectedValue);
                }
                scheduleDetails.ActivationDetails = activationDetails;
            }
            // (Optional) Trial period for this schedule.
            if(trialBillingAmount.Value != string.Empty && trialBillingFrequency.Value != string.Empty
                    && trialBillingCycles.Value != string.Empty)
            {
                // Number of billing periods that make up one billing cycle;
                // required if you specify an optional trial period.
                // The combination of billing frequency and billing period must be
                // less than or equal to one year. For example, if the billing cycle is Month,
                // the maximum value for billing frequency is 12. Similarly,
                // if the billing cycle is Week, the maximum value for billing frequency is 52.
                // Note:
                // If the billing period is SemiMonth, the billing frequency must be 1.
                int frequency = Convert.ToInt32(trialBillingFrequency.Value);

                //Billing amount for each billing cycle during this payment period;
                //required if you specify an optional trial period.
                //This amount does not include shipping and tax amounts.
                //Note:
                //All amounts in the CreateRecurringPaymentsProfile request must have
                //the same currency.
                //Character length and limitations:
                //Value is a positive number which cannot exceed $10,000 USD in any currency.
                //It includes no currency symbol.
                //It must have 2 decimal places, the decimal separator must be a period (.),
                //and the optional thousands separator must be a comma (,).
                BasicAmountType paymentAmount = new BasicAmountType(currency, trialBillingAmount.Value);

                //Unit for billing during this subscription period;
                //required if you specify an optional trial period.
                //It is one of the following values: [Day, Week, SemiMonth, Month, Year]
                //For SemiMonth, billing is done on the 1st and 15th of each month.
                //Note:
                //The combination of BillingPeriod and BillingFrequency cannot exceed one year.
                BillingPeriodType period = (BillingPeriodType)
                    Enum.Parse(typeof(BillingPeriodType), trialBillingPeriod.SelectedValue);

                //Number of billing periods that make up one billing cycle;
                //required if you specify an optional trial period.
                //The combination of billing frequency and billing period must be
                //less than or equal to one year. For example, if the billing cycle is Month,
                //the maximum value for billing frequency is 12. Similarly,
                //if the billing cycle is Week, the maximum value for billing frequency is 52.
                //Note:
                //If the billing period is SemiMonth, the billing frequency must be 1.
                int numCycles = Convert.ToInt32(trialBillingCycles.Value);

                BillingPeriodDetailsType trialPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
                trialPeriod.TotalBillingCycles = numCycles;
                //(Optional) Shipping amount for each billing cycle during this payment period.
                //Note:
                //All amounts in the request must have the same currency.
                if(trialShippingAmount.Value != string.Empty)
                {
                    trialPeriod.ShippingAmount = new BasicAmountType(currency, trialShippingAmount.Value);
                }
                //(Optional) Tax amount for each billing cycle during this payment period.
                //Note:
                //All amounts in the request must have the same currency.
                //Character length and limitations:
                //Value is a positive number which cannot exceed $10,000 USD in any currency.
                //It includes no currency symbol. It must have 2 decimal places,
                //the decimal separator must be a period (.), and the optional
                //thousands separator must be a comma (,).
                if(trialTaxAmount.Value != string.Empty)
                {
                    trialPeriod.TaxAmount = new BasicAmountType(currency, trialTaxAmount.Value);
                }

                scheduleDetails.TrialPeriod = trialPeriod;
            }
            // (Required) Regular payment period for this schedule.
            if(billingAmount.Value != string.Empty && billingFrequency.Value != string.Empty
                    && totalBillingCycles.Value != string.Empty)
            {
                // Number of billing periods that make up one billing cycle;
                // required if you specify an optional trial period.
                // The combination of billing frequency and billing period must be
                // less than or equal to one year. For example, if the billing cycle is Month,
                // the maximum value for billing frequency is 12. Similarly,
                // if the billing cycle is Week, the maximum value for billing frequency is 52.
                // Note:
                // If the billing period is SemiMonth, the billing frequency must be 1.
                int frequency = Convert.ToInt32(billingFrequency.Value);
                //Billing amount for each billing cycle during this payment period;
                //required if you specify an optional trial period.
                //This amount does not include shipping and tax amounts.
                //Note:
                //All amounts in the CreateRecurringPaymentsProfile request must have
                //the same currency.
                //Character length and limitations:
                //Value is a positive number which cannot exceed $10,000 USD in any currency.
                //It includes no currency symbol.
                //It must have 2 decimal places, the decimal separator must be a period (.),
                //and the optional thousands separator must be a comma (,).
                BasicAmountType paymentAmount = new BasicAmountType(currency, billingAmount.Value);
                BillingPeriodType period = (BillingPeriodType)
                    Enum.Parse(typeof(BillingPeriodType), billingPeriod.SelectedValue);
                //Number of billing periods that make up one billing cycle;
                //required if you specify an optional trial period.
                //The combination of billing frequency and billing period must be
                //less than or equal to one year. For example, if the billing cycle is Month,
                //the maximum value for billing frequency is 12. Similarly,
                //if the billing cycle is Week, the maximum value for billing frequency is 52.
                //Note:
                //If the billing period is SemiMonth, the billing frequency must be 1.
                int numCycles = Convert.ToInt32(totalBillingCycles.Value);

                //Unit for billing during this subscription period;
                //required if you specify an optional trial period.
                //It is one of the following values: [Day, Week, SemiMonth, Month, Year]
                //For SemiMonth, billing is done on the 1st and 15th of each month.
                //Note:
                //The combination of BillingPeriod and BillingFrequency cannot exceed one year.
                BillingPeriodDetailsType paymentPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
                paymentPeriod.TotalBillingCycles = numCycles;
                //(Optional) Shipping amount for each billing cycle during this payment period.
                //Note:
                //All amounts in the request must have the same currency.
                if(trialShippingAmount.Value != string.Empty)
                {
                    paymentPeriod.ShippingAmount = new BasicAmountType(currency, shippingAmount.Value);
                }

                //(Optional) Tax amount for each billing cycle during this payment period.
                //Note:
                //All amounts in the request must have the same currency.
                //Character length and limitations:
                //Value is a positive number which cannot exceed $10,000 USD in any currency.
                //It includes no currency symbol. It must have 2 decimal places,
                //the decimal separator must be a period (.), and the optional
                //thousands separator must be a comma (,).
                if(trialTaxAmount.Value != string.Empty)
                {
                    paymentPeriod.TaxAmount = new BasicAmountType(currency, taxAmount.Value);
                }
                scheduleDetails.PaymentPeriod = paymentPeriod;
            }
            profileDetails.ScheduleDetails = scheduleDetails;
        }
        /// <summary>
        /// Handles Set Express Checkout For Recurring Payments
        /// </summary>
        /// <param name="contextHttp"></param>
        private void SetExpressCheckoutForRecurringPayments(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            SetExpressCheckoutRequestType setExpressCheckoutReq = new SetExpressCheckoutRequestType();
            SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();

            string requestUrl = ConfigurationManager.AppSettings["HOSTING_ENDPOINT"].ToString();

            // (Required) URL to which the buyer's browser is returned after choosing to pay with PayPal. For digital goods, you must add JavaScript to this page to close the in-context experience.
            // Note:
            // PayPal recommends that the value be the final review page on which the buyer confirms the order and payment or billing agreement.
            UriBuilder uriBuilder = new UriBuilder(requestUrl);
            uriBuilder.Path = contextHttp.Request.ApplicationPath
                + (contextHttp.Request.ApplicationPath.EndsWith("/") ? string.Empty : "/")
                + "UseCaseSamples/SetExpressCheckoutForRecurringPayments.aspx";
            string returnUrl = uriBuilder.Uri.ToString();

            // (Required) URL to which the buyer is returned if the buyer does not approve the use of PayPal to pay you. For digital goods, you must add JavaScript to this page to close the in-context experience.
            // Note:
            // PayPal recommends that the value be the original page on which the buyer chose to pay with PayPal or establish a billing agreement.
            uriBuilder = new UriBuilder(requestUrl);
            uriBuilder.Path = contextHttp.Request.ApplicationPath
                + (contextHttp.Request.ApplicationPath.EndsWith("/") ? string.Empty : "/")
                + "UseCaseSamples/SetExpressCheckoutForRecurringPayments.aspx";
            string cancelUrl = uriBuilder.Uri.ToString();

            // (Required) URL to which the buyer's browser is returned after choosing
            // to pay with PayPal. For digital goods, you must add JavaScript to this
            // page to close the in-context experience.
            // Note:
            // PayPal recommends that the value be the final review page on which the buyer
            // confirms the order and payment or billing agreement.
            // Character length and limitations: 2048 single-byte characters
            details.ReturnURL = returnUrl + "?currencyCodeType=" + parameters["currencyCode"];
            details.CancelURL = cancelUrl;

            // (Optional) Email address of the buyer as entered during checkout.
            // PayPal uses this value to pre-fill the PayPal membership sign-up portion on the PayPal pages.
            // Character length and limitations: 127 single-byte alphanumeric characters
            details.BuyerEmail = parameters["buyerMail"];

            decimal itemTotal = 0.0M;
            decimal orderTotal = 0.0M;

            // Cost of item. This field is required when you pass a value for ItemCategory.
            string amountItems = parameters["itemAmount"];

            // Item quantity. This field is required when you pass a value for ItemCategory.
            // For digital goods (ItemCategory=Digital), this field is required.
            // Character length and limitations: Any positive integer
            string qtyItems = parameters["itemQuantity"];

            // Item name. This field is required when you pass a value for ItemCategory.
            // Character length and limitations: 127 single-byte characters
            string names = parameters["itemName"];

            List<PaymentDetailsItemType> lineItems = new List<PaymentDetailsItemType>();
            PaymentDetailsItemType item = new PaymentDetailsItemType();
            BasicAmountType amt = new BasicAmountType();

            // PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables.
            amt.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);
            amt.value = amountItems;
            item.Quantity = Convert.ToInt32(qtyItems);
            item.Name = names;
            item.Amount = amt;

            // Indicates whether an item is digital or physical. For digital goods, this field is required and must be set to Digital. It is one of the following values:
            // 1. Digital
            // 2. Physical
            item.ItemCategory = (ItemCategoryType)Enum.Parse(typeof(ItemCategoryType), parameters["itemCategory"]);

            // (Optional) Item sales tax.
            // Note: You must set the currencyID attribute to one of
            // the 3-character currency codes for any of the supported PayPal currencies.
            // Character length and limitations: Value is a positive number which cannot exceed $10,000 USD in any currency.
            // It includes no currency symbol. It must have 2 decimal places, the decimal separator must be a period (.),
            // and the optional thousands separator must be a comma (,).
            if (parameters["salesTax"] != string.Empty)
            {
                item.Tax = new BasicAmountType((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]), parameters["salesTax"]);
            }

            itemTotal += Convert.ToDecimal(qtyItems) * Convert.ToDecimal(amountItems);
            orderTotal += itemTotal;

            List<PaymentDetailsType> payDetails = new List<PaymentDetailsType>();
            PaymentDetailsType paydtl = new PaymentDetailsType();

            // How you want to obtain payment. When implementing parallel payments,
            // this field is required and must be set to Order.
            // When implementing digital goods, this field is required and must be set to Sale.
            // If the transaction does not include a one-time purchase, this field is ignored.
            // It is one of the following values:
            // Sale – This is a final sale for which you are requesting payment (default).
            // Authorization – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture.
            // Order – This payment is an order authorization subject to settlement with PayPal Authorization and Capture.
            paydtl.PaymentAction = (PaymentActionCodeType)Enum.Parse(typeof(PaymentActionCodeType), parameters["paymentType"]);

            // (Optional) Total shipping costs for this order.
            // Note:
            // You must set the currencyID attribute to one of the 3-character currency codes
            // for any of the supported PayPal currencies.
            // Character length and limitations:
            // Value is a positive number which cannot exceed $10,000 USD in any currency.
            // It includes no currency symbol.
            // It must have 2 decimal places, the decimal separator must be a period (.),
            // and the optional thousands separator must be a comma (,)
            if (parameters["shippingTotal"] != string.Empty)
            {
                BasicAmountType shippingTotal = new BasicAmountType();
                shippingTotal.value = parameters["shippingTotal"];
                shippingTotal.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);
                orderTotal += Convert.ToDecimal(parameters["shippingTotal"]);
                paydtl.ShippingTotal = shippingTotal;
            }

            // (Optional) Total shipping insurance costs for this order.
            // The value must be a non-negative currency amount or null if you offer insurance options.
            // Note:
            // You must set the currencyID attribute to one of the 3-character currency
            // codes for any of the supported PayPal currencies.
            // Character length and limitations:
            // Value is a positive number which cannot exceed $10,000 USD in any currency.
            // It includes no currency symbol. It must have 2 decimal places,
            // the decimal separator must be a period (.),
            // and the optional thousands separator must be a comma (,).
            // InsuranceTotal is available since version 53.0.
            if (parameters["insuranceTotal"] != string.Empty)
            {
                paydtl.InsuranceTotal = new BasicAmountType((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]), parameters["insuranceTotal"]);
                paydtl.InsuranceOptionOffered = "true";
                orderTotal += Convert.ToDecimal(parameters["insuranceTotal"]);
            }

            // (Optional) Total handling costs for this order.
            // Note:
            // You must set the currencyID attribute to one of the 3-character currency codes
            // for any of the supported PayPal currencies.
            // Character length and limitations: Value is a positive number which
            // cannot exceed $10,000 USD in any currency.
            // It includes no currency symbol. It must have 2 decimal places,
            // the decimal separator must be a period (.), and the optional
            // thousands separator must be a comma (,).
            if (parameters["handlingTotal"] != string.Empty)
            {
                paydtl.HandlingTotal = new BasicAmountType((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]), parameters["handlingTotal"]);
                orderTotal += Convert.ToDecimal(parameters["handlingTotal"]);
            }

            // (Optional) Sum of tax for all items in this order.
            // Note:
            // You must set the currencyID attribute to one of the 3-character currency codes
            // for any of the supported PayPal currencies.
            // Character length and limitations: Value is a positive number which
            // cannot exceed $10,000 USD in any currency. It includes no currency symbol.
            // It must have 2 decimal places, the decimal separator must be a period (.),
            // and the optional thousands separator must be a comma (,).
            if (parameters["taxTotal"] != string.Empty)
            {
                paydtl.TaxTotal = new BasicAmountType((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]), parameters["taxTotal"]);
                orderTotal += Convert.ToDecimal(parameters["taxTotal"]);
            }

            // (Optional) Description of items the buyer is purchasing.
            // Note:
            // The value you specify is available only if the transaction includes a purchase.
            // This field is ignored if you set up a billing agreement for a recurring payment
            // that is not immediately charged.
            // Character length and limitations: 127 single-byte alphanumeric characters
            if (parameters["orderDescription"] != string.Empty)
            {
                paydtl.OrderDescription = parameters["orderDescription"];
            }

            BasicAmountType itemsTotal = new BasicAmountType();
            itemsTotal.value = Convert.ToString(itemTotal);

            // PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables.
            itemsTotal.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);

            paydtl.OrderTotal = new BasicAmountType((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]), Convert.ToString(orderTotal));
            paydtl.PaymentDetailsItem = lineItems;

            paydtl.ItemTotal = itemsTotal;

            // (Optional) Your URL for receiving Instant Payment Notification (IPN)
            // about this transaction. If you do not specify this value in the request,
            // the notification URL from your Merchant Profile is used, if one exists.
            // Important:
            // The notify URL applies only to DoExpressCheckoutPayment.
            // This value is ignored when set in SetExpressCheckout or GetExpressCheckoutDetails.
            // Character length and limitations: 2,048 single-byte alphanumeric characters
            paydtl.NotifyURL = parameters["notifyURL"];

            payDetails.Add(paydtl);
            details.PaymentDetails = payDetails;

            if (parameters["billingAgreementText"] != string.Empty)
            {
                // (Required) Type of billing agreement. For recurring payments,
                // this field must be set to RecurringPayments.
                // In this case, you can specify up to ten billing agreements.
                // Other defined values are not valid.
                // Type of billing agreement for reference transactions.
                // You must have permission from PayPal to use this field.
                // This field must be set to one of the following values:
                // 1. MerchantInitiatedBilling - PayPal creates a billing agreement
                // for each transaction associated with buyer.You must specify
                // version 54.0 or higher to use this option.
                // 2. MerchantInitiatedBillingSingleAgreement - PayPal creates a
                // single billing agreement for all transactions associated with buyer.
                // Use this value unless you need per-transaction billing agreements.
                // You must specify version 58.0 or higher to use this option.
                BillingAgreementDetailsType billingAgreement = new BillingAgreementDetailsType((BillingCodeType)Enum.Parse(typeof(BillingCodeType), parameters["billingType"]));

                // Description of goods or services associated with the billing agreement.
                // This field is required for each recurring payment billing agreement.
                // PayPal recommends that the description contain a brief summary of
                // the billing agreement terms and conditions. For example,
                // buyer is billed at "9.99 per month for 2 years".
                // Character length and limitations: 127 single-byte alphanumeric characters
                billingAgreement.BillingAgreementDescription = parameters["billingAgreementText"];
                List<BillingAgreementDetailsType> billList = new List<BillingAgreementDetailsType>();
                billList.Add(billingAgreement);
                details.BillingAgreementDetails = billList;
            }

            setExpressCheckoutReq.SetExpressCheckoutRequestDetails = details;
            SetExpressCheckoutReq expressCheckoutReq = new SetExpressCheckoutReq();
            expressCheckoutReq.SetExpressCheckoutRequest = setExpressCheckoutReq;

            SetExpressCheckoutResponseType response = null;
            try
            {
                response = service.SetExpressCheckout(expressCheckoutReq);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.Message);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;

            if (!response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
            {
                redirectUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"].ToString() + "_express-checkout&token=" + response.Token;
            }

            responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());

            Display(contextHttp, "SetExpressCheckoutForRecurringPayments", "SetExpressCheckout", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }
        /// <summary>
        /// Handles ParallelPayment
        /// </summary>
        /// <param name="contextHttp"></param>
        private void ParallelPayment(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            SetExpressCheckoutRequestType setExpressCheckoutReq = new SetExpressCheckoutRequestType();
            SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();

            string requestUrl = ConfigurationManager.AppSettings["HOSTING_ENDPOINT"].ToString();

            // (Required) URL to which the buyer's browser is returned after choosing to pay with PayPal. For digital goods, you must add JavaScript to this page to close the in-context experience.
            // Note:
            // PayPal recommends that the value be the final review page on which the buyer confirms the order and payment or billing agreement.
            UriBuilder uriBuilder = new UriBuilder(requestUrl);
            uriBuilder.Path = contextHttp.Request.ApplicationPath
                + (contextHttp.Request.ApplicationPath.EndsWith("/") ? string.Empty : "/")
                + "UseCaseSamples/DoExpressCheckoutForParallelPayment.aspx";
            string returnUrl = uriBuilder.Uri.ToString();

            // (Required) URL to which the buyer is returned if the buyer does not approve the use of PayPal to pay you. For digital goods, you must add JavaScript to this page to close the in-context experience.
            // Note:
            // PayPal recommends that the value be the original page on which the buyer chose to pay with PayPal or establish a billing agreement.
            uriBuilder = new UriBuilder(requestUrl);
            uriBuilder.Path = contextHttp.Request.ApplicationPath
                + (contextHttp.Request.ApplicationPath.EndsWith("/") ? string.Empty : "/")
                + "UseCaseSamples/DoExpressCheckout.aspx";
            string cancelUrl = uriBuilder.Uri.ToString();

            // (Required) URL to which the buyer's browser is returned after choosing
            // to pay with PayPal. For digital goods, you must add JavaScript to this
            // page to close the in-context experience.
            // Note:
            // PayPal recommends that the value be the final review page on which the buyer
            // confirms the order and payment or billing agreement.
            // Character length and limitations: 2048 single-byte characters
            details.ReturnURL = returnUrl + "?currencyCodeType=" + parameters["currencyCode"];
            details.CancelURL = cancelUrl;

            // (Optional) Email address of the buyer as entered during checkout.
            // PayPal uses this value to pre-fill the PayPal membership sign-up portion on the PayPal pages.
            // Character length and limitations: 127 single-byte alphanumeric characters
            details.BuyerEmail = parameters["buyerMail"];

            SellerDetailsType seller1 = new SellerDetailsType();
            seller1.PayPalAccountID = parameters["receiverEmail_0"];
            PaymentDetailsType paymentDetails1 = new PaymentDetailsType();
            paymentDetails1.SellerDetails = seller1;
            paymentDetails1.PaymentRequestID = parameters["paymentRequestID_0"];
            BasicAmountType orderTotal1 = new BasicAmountType();
            orderTotal1.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);
            orderTotal1.value = parameters["orderTotal"];
            paymentDetails1.OrderTotal = orderTotal1;

            SellerDetailsType seller2 = new SellerDetailsType();
            seller2.PayPalAccountID = parameters["receiverEmail_1"];
            PaymentDetailsType paymentDetails2 = new PaymentDetailsType();
            paymentDetails2.SellerDetails = seller2;
            paymentDetails2.PaymentRequestID = parameters["paymentRequestID_1"];
            BasicAmountType orderTotal2 = new BasicAmountType();
            orderTotal2.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);
            orderTotal2.value = parameters["orderTotal"];
            paymentDetails2.OrderTotal = orderTotal2;

            List<PaymentDetailsType> payDetails = new List<PaymentDetailsType>();
            payDetails.Add(paymentDetails1);
            payDetails.Add(paymentDetails2);

            details.PaymentDetails = payDetails;
            setExpressCheckoutReq.SetExpressCheckoutRequestDetails = details;

            SetExpressCheckoutReq expressCheckoutReq = new SetExpressCheckoutReq();
            expressCheckoutReq.SetExpressCheckoutRequest = setExpressCheckoutReq;
            SetExpressCheckoutResponseType response = null;

            try
            {
                response = service.SetExpressCheckout(expressCheckoutReq);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.Message);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;
            if (!response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
            {
                redirectUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"].ToString() + "_express-checkout&token=" + response.Token;
            }
            responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());
            Display(contextHttp, "ParallelPayment", "SetExpressCheckout", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }
        /// <summary>
        /// Handles DoExpressCheckoutForParallelPayments
        /// </summary>
        /// <param name="contextHttp"></param>
        private void DoExpressCheckoutForParallelPayment(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<String, String> configurationMap = Configuration.GetAcctAndConfig();

            // Creating service wrapper object to make an API call by loading configuration map.
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            DoExpressCheckoutPaymentRequestType doCheckoutPaymentRequestType = new DoExpressCheckoutPaymentRequestType();
            DoExpressCheckoutPaymentRequestDetailsType details = new DoExpressCheckoutPaymentRequestDetailsType();

            // A timestamped token by which you identify to PayPal that you are processing
            // this payment with Express Checkout. The token expires after three hours.
            // If you set the token in the SetExpressCheckout request, the value of the token
            // in the response is identical to the value in the request.
            // Character length and limitations: 20 single-byte characters
            details.Token = parameters["token"];

            // Unique PayPal Customer Account identification number.
            // Character length and limitations: 13 single-byte alphanumeric characters
            details.PayerID = parameters["payerID"];

            // (Optional) How you want to obtain payment. If the transaction does not include a one-time purchase, this field is ignored.
            // It is one of the following values:
            // Sale – This is a final sale for which you are requesting payment (default).
            // Authorization – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture.
            // Order – This payment is an order authorization subject to settlement with PayPal Authorization and Capture.
            // Note:
            // You cannot set this field to Sale in SetExpressCheckout request and then change
            // this value to Authorization or Order in the DoExpressCheckoutPayment request.
            // If you set the field to Authorization or Order in SetExpressCheckout, you may set the field to Sale.
            // Character length and limitations: Up to 13 single-byte alphabetic characters
            // This field is deprecated. Use PaymentAction in PaymentDetailsType instead.
            details.PaymentAction = (PaymentActionCodeType)Enum.Parse(typeof(PaymentActionCodeType), parameters["paymentType"]);

            PaymentDetailsType paymentDetails1 = new PaymentDetailsType();
            BasicAmountType orderTotal1 = new BasicAmountType();
            orderTotal1.value = parameters["orderTotal"];

            //PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables.
            orderTotal1.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);

            // (Required) The total cost of the transaction to the buyer.
            // If shipping cost (not applicable to digital goods) and tax charges are known,
            // include them in this value. If not, this value should be the current sub-total
            // of the order. If the transaction includes one or more one-time purchases, this
            // field must be equal to the sum of the purchases. Set this field to 0 if the
            // transaction does not include a one-time purchase such as when you set up a
            // billing agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            // For digital goods, the following must be true:
            // total cost > 0
            // total cost <= total cost passed in the call to SetExpressCheckout
            // Note:
            // You must set the currencyID attribute to one of the 3-character currency codes
            // for any of the supported PayPal currencies.
            // When multiple payments are passed in one transaction, all of the payments must
            // have the same currency code.
            // Character length and limitations: Value is a positive number which cannot
            // exceed $10,000 USD in any currency. It includes no currency symbol.
            // It must have 2 decimal places, the decimal separator must be a period (.),
            // and the optional thousands separator must be a comma (,).
            paymentDetails1.OrderTotal = orderTotal1;

            SellerDetailsType sellerDetailsType1 = new SellerDetailsType();
            sellerDetailsType1.PayPalAccountID = parameters["receiverEmail_0"];

            paymentDetails1.PaymentRequestID = parameters["paymentRequestID_0"];
            paymentDetails1.SellerDetails = sellerDetailsType1;

            PaymentDetailsType paymentDetails2 = new PaymentDetailsType();
            BasicAmountType orderTotal2 = new BasicAmountType();
            orderTotal2.value = parameters["orderTotal"];

            //PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables.
            orderTotal2.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);

            // (Required) The total cost of the transaction to the buyer.
            // If shipping cost (not applicable to digital goods) and tax charges are known,
            // include them in this value. If not, this value should be the current sub-total
            // of the order. If the transaction includes one or more one-time purchases, this
            // field must be equal to the sum of the purchases. Set this field to 0 if the
            // transaction does not include a one-time purchase such as when you set up a
            // billing agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            // For digital goods, the following must be true:
            // total cost > 0
            // total cost <= total cost passed in the call to SetExpressCheckout
            // Note:
            // You must set the currencyID attribute to one of the 3-character currency codes
            // for any of the supported PayPal currencies.
            // When multiple payments are passed in one transaction, all of the payments must
            // have the same currency code.
            // Character length and limitations: Value is a positive number which cannot
            // exceed $10,000 USD in any currency. It includes no currency symbol.
            // It must have 2 decimal places, the decimal separator must be a period (.),
            // and the optional thousands separator must be a comma (,).
            paymentDetails2.OrderTotal = orderTotal2;

            SellerDetailsType sellerDetailsType2 = new SellerDetailsType();
            sellerDetailsType2.PayPalAccountID = parameters["receiverEmail_1"];

            paymentDetails2.PaymentRequestID = parameters["paymentRequestID_1"];
            paymentDetails2.SellerDetails = sellerDetailsType2;

            List<PaymentDetailsType> payDetailType = new List<PaymentDetailsType>();
            payDetailType.Add(paymentDetails1);
            payDetailType.Add(paymentDetails2);

            // When implementing parallel payments, you can create up to 10 sets of payment
            // details type parameter fields, each representing one payment you are hosting
            // on your marketplace.
            details.PaymentDetails = payDetailType;

            doCheckoutPaymentRequestType.DoExpressCheckoutPaymentRequestDetails = details;
            DoExpressCheckoutPaymentReq doExpressCheckoutPaymentReq = new DoExpressCheckoutPaymentReq();
            doExpressCheckoutPaymentReq.DoExpressCheckoutPaymentRequest = doCheckoutPaymentRequestType;
            DoExpressCheckoutPaymentResponseType response = null;
            try
            {
                response = service.DoExpressCheckoutPayment(doExpressCheckoutPaymentReq);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.StackTrace);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;

            if (!response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.Ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
            {
                responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());
                responseValues.Add("PaymentType", parameters["paymentType"]);
                responseValues.Add("TransactionId", response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID);
            }
            else
            {
                responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());
            }

            Display(contextHttp, "DoExpressCheckoutForParallelPayment", "DoExpressCheckout", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }
        /// <summary>
        /// Handles Create Recurring Payments Profile
        /// </summary>
        /// <param name="contextHttp"></param>
        private void CreateRecurringPaymentsProfile(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            CreateRecurringPaymentsProfileReq req = new CreateRecurringPaymentsProfileReq();
            CreateRecurringPaymentsProfileRequestType reqType = new CreateRecurringPaymentsProfileRequestType();

            // (Required) The date when billing for this profile begins.
            // Note:
            // The profile may take up to 24 hours for activation.
            // Character length and limitations: Must be a valid date, in UTC/GMT format
            RecurringPaymentsProfileDetailsType profileDetails = new RecurringPaymentsProfileDetailsType(parameters["billingStartDate"] + "T00:00:00:000Z");

            // Populate schedule details
            ScheduleDetailsType scheduleDetails = new ScheduleDetailsType();

             // (Required) Description of the recurring payment.
             // Note:
             // You must ensure that this field matches the corresponding billing agreement
             // description included in the SetExpressCheckout request.
             // Character length and limitations: 127 single-byte alphanumeric characters
            scheduleDetails.Description = parameters["profileDescription"];

            // (Optional) Number of scheduled payments that can fail before the profile
            // is automatically suspended. An IPN message is sent to the merchant when the
            // specified number of failed payments is reached.
            // Character length and limitations: Number string representing an integer
            if (parameters["maxFailedPayments"] != string.Empty)
            {
                scheduleDetails.MaxFailedPayments = Convert.ToInt32(parameters["maxFailedPayments"]);
            }

            // (Optional) Indicates whether you would like PayPal to automatically bill
            // the outstanding balance amount in the next billing cycle.
            // The outstanding balance is the total amount of any previously failed
            // scheduled payments that have yet to be successfully paid.
            // It is one of the following values:
            // NoAutoBill – PayPal does not automatically bill the outstanding balance.
            // AddToNextBilling – PayPal automatically bills the outstanding balance.
            if (parameters["autoBillOutstandingAmount"] != string.Empty)
            {
                scheduleDetails.AutoBillOutstandingAmount = (AutoBillType)Enum.Parse(typeof(AutoBillType), parameters["autoBillOutstandingAmount"]);
            }

            CurrencyCodeType currency = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), "USD");

            if (parameters["trialBillingAmount"] != string.Empty)
            {
                // Number of billing periods that make up one billing cycle;
                // required if you specify an optional trial period.
                // The combination of billing frequency and billing period must be
                // less than or equal to one year. For example, if the billing cycle is Month,
                // the maximum value for billing frequency is 12. Similarly,
                // if the billing cycle is Week, the maximum value for billing frequency is 52.
                // Note:
                // If the billing period is SemiMonth, the billing frequency must be 1.
                int frequency = Convert.ToInt32(parameters["trialBillingFrequency"]);

                // Billing amount for each billing cycle during this payment period;
                // required if you specify an optional trial period.
                // This amount does not include shipping and tax amounts.
                // Note:
                // All amounts in the CreateRecurringPaymentsProfile request must have
                // the same currency.
                // Character length and limitations:
                // Value is a positive number which cannot exceed $10,000 USD in any currency.
                // It includes no currency symbol.
                // It must have 2 decimal places, the decimal separator must be a period (.),
                // and the optional thousands separator must be a comma (,).
                BasicAmountType paymentAmount = new BasicAmountType(currency, parameters["trialBillingAmount"]);

                // Unit for billing during this subscription period;
                // required if you specify an optional trial period.
                // It is one of the following values: [Day, Week, SemiMonth, Month, Year]
                // For SemiMonth, billing is done on the 1st and 15th of each month.
                // Note:
                // The combination of BillingPeriod and BillingFrequency cannot exceed one year.
                BillingPeriodType period = (BillingPeriodType)Enum.Parse(typeof(BillingPeriodType), parameters["trialBillingPeriod"]);

                // Number of billing periods that make up one billing cycle;
                // required if you specify an optional trial period.
                // The combination of billing frequency and billing period must be
                // less than or equal to one year. For example, if the billing cycle is Month,
                // the maximum value for billing frequency is 12. Similarly,
                // if the billing cycle is Week, the maximum value for billing frequency is 52.
                // Note:
                // If the billing period is SemiMonth, the billing frequency must be 1.
                int numCycles = Convert.ToInt32(parameters["trialBillingCycles"]);

                BillingPeriodDetailsType trialPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
                trialPeriod.TotalBillingCycles = numCycles;
                scheduleDetails.TrialPeriod = trialPeriod;
            }

            if (parameters["billingAmount"] != string.Empty)
            {
                // (Required) Number of billing periods that make up one billing cycle.
                // The combination of billing frequency and billing period must be less than
                // or equal to one year. For example, if the billing cycle is Month,
                // the maximum value for billing frequency is 12. Similarly,
                // if the billing cycle is Week, the maximum value for billing frequency is 52.
                // Note:
                // If the billing period is SemiMonth, the billing frequency must be 1.
                int frequency = Convert.ToInt32(parameters["billingFrequency"]);

                // (Required) Billing amount for each billing cycle during this payment period.
                // This amount does not include shipping and tax amounts.
                // Note:
                // All amounts in the CreateRecurringPaymentsProfile request must have the same
                // currency.
                // Character length and limitations: Value is a positive number which cannot
                // exceed $10,000 USD in any currency. It includes no currency symbol.
                // It must have 2 decimal places, the decimal separator must be a period (.),
                // and the optional thousands separator must be a comma (,).
                BasicAmountType paymentAmount = new BasicAmountType(currency, parameters["billingAmount"]);

                // (Required) Unit for billing during this subscription period.
                // It is one of the following values:
                // [Day, Week, SemiMonth, Month, Year]
                // For SemiMonth, billing is done on the 1st and 15th of each month.
                // Note:
                // The combination of BillingPeriod and BillingFrequency cannot exceed one year.
                BillingPeriodType period = (BillingPeriodType)Enum.Parse(typeof(BillingPeriodType), parameters["billingPeriod"]);

                 // (Optional) Number of billing cycles for payment period.
                 // For the regular payment period, if no value is specified or the value is 0,
                 // the regular payment period continues until the profile is canceled or deactivated.
                 // For the regular payment period, if the value is greater than 0,
                 // the regular payment period will expire after the trial period is
                 // finished and continue at the billing frequency for TotalBillingCycles cycles.
                int numCycles = Convert.ToInt32(parameters["totalBillingCycles"]);

                BillingPeriodDetailsType paymentPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
                paymentPeriod.TotalBillingCycles = numCycles;
                scheduleDetails.PaymentPeriod = paymentPeriod;
            }

            CreateRecurringPaymentsProfileRequestDetailsType reqDetails = new CreateRecurringPaymentsProfileRequestDetailsType(profileDetails, scheduleDetails);

            // Credit Card Number is required for CreateRecurringPaymentsProfile.
            // Each CreateRecurringPaymentsProfile request creates a single recurring payments profile.
            CreditCardDetailsType cc = new CreditCardDetailsType();

            // (Required) Credit Card Number.
            // Character length and limitations: Numeric characters only with no spaces
            // or punctuation. The string must conform with modulo and length required
            // by each credit card type.
            cc.CreditCardNumber = parameters["creditCardNumber"];

            // Card Verification Value, version 2.
            // Your Merchant Account settings determine whether this field is required.
            // To comply with credit card processing regulations, you must not store this
            // value after a transaction has been completed.
            // Character length and limitations:
            // For Visa, MasterCard, and Discover, the value is exactly 3 digits.
            // For American Express, the value is exactly 4 digits.
            cc.CVV2 = parameters["cvv"];

            // Expiry Month
            cc.ExpMonth = Convert.ToInt32(parameters["expMonth"]);

            // Expiry Year
            cc.ExpYear = Convert.ToInt32(parameters["expYear"]);

            // (Optional) Type of credit card.
            // For UK, only Maestro, MasterCard, Discover, and Visa are allowable.
            // For Canada, only MasterCard and Visa are allowable and
            // Interac debit cards are not supported. It is one of the following values:
            // [Visa, MasterCard, Discover, Amex, Maestro: See note.]
            // Note:
            // If the credit card type is Maestro, you must set CURRENCYCODE to GBP.
            // In addition, you must specify either STARTDATE or ISSUENUMBER.
            CreditCardTypeType type = (CreditCardTypeType)Enum.Parse(typeof(CreditCardTypeType), parameters["creditCardType"]);
            cc.CreditCardType = type;

            reqDetails.CreditCard = cc;

            reqType.CreateRecurringPaymentsProfileRequestDetails = reqDetails;
            req.CreateRecurringPaymentsProfileRequest = reqType;

            CreateRecurringPaymentsProfileResponseType response = null;
            try
            {
                response = service.CreateRecurringPaymentsProfile(req);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.Message);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;

            responseValues.Add("Acknowledgement", response.Ack.ToString());

            Display(contextHttp, "CreateRecurringPaymentsProfile", "SetExpressCheckout", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }
        /// <summary>
        /// Handles DoCapture
        /// </summary>
        /// <param name="contextHttp"></param>
        private void DoCapture(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<String, String> configurationMap = Configuration.GetAcctAndConfig();

            // Creating service wrapper object to make an API call by loading configuration map.
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // ## DoCaptureReq
            DoCaptureReq req = new DoCaptureReq();
            // 'Amount' to capture which takes mandatory params:
            //
            // * 'currencyCode'
            // * 'amount'
            BasicAmountType amount = new BasicAmountType(((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"])), parameters["amt"]);

            // 'DoCaptureRequest' which takes mandatory params:
            //
            // * 'Authorization ID' - Authorization identification number of the
            // payment you want to capture. This is the transaction ID returned from
            // DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
            // point-of-sale transactions, this is the transaction ID returned by
            // the CheckOut call when the payment action is Authorization.
            // * 'amount' - Amount to capture
            // * 'CompleteCode' - Indicates whether or not this is your last capture.
            // It is one of the following values:
            // * Complete – This is the last capture you intend to make.
            // * NotComplete – You intend to make additional captures.
            // 'Note:
            // If Complete, any remaining amount of the original authorized
            // transaction is automatically voided and all remaining open
            // authorizations are voided.'
            DoCaptureRequestType reqType = new DoCaptureRequestType
            (
                    parameters["authID"],
                    amount,
                    (CompleteCodeType)Enum.Parse(typeof(CompleteCodeType), parameters["completeCodeType"])
            );

            req.DoCaptureRequest = reqType;
            DoCaptureResponseType response = null;
            try
            {
                response = service.DoCapture(req);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.StackTrace);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;
            responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());

            Display(contextHttp, "DoCapture", "DoCapture", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }
    // # DoExpressCheckoutPayment API Operation
    // The DoExpressCheckoutPayment API operation completes an Express Checkout transaction. 
    // If you set up a billing agreement in your SetExpressCheckout API call, 
    // the billing agreement is created when you call the DoExpressCheckoutPayment API operation. 
    public DoExpressCheckoutPaymentResponseType DoExpressCheckoutPaymentAPIOperation()
    {
        // Create the DoExpressCheckoutPaymentResponseType object
        DoExpressCheckoutPaymentResponseType responseDoExpressCheckoutPaymentResponseType = new DoExpressCheckoutPaymentResponseType();

        try
        {
            // Create the DoExpressCheckoutPaymentReq object
            DoExpressCheckoutPaymentReq doExpressCheckoutPayment = new DoExpressCheckoutPaymentReq();

            DoExpressCheckoutPaymentRequestDetailsType doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();

            // The timestamped token value that was returned in the
            // `SetExpressCheckout` response and passed in the
            // `GetExpressCheckoutDetails` request.
            doExpressCheckoutPaymentRequestDetails.Token = "EC-2XW434901C650622T";

            // Unique paypal buyer account identification number as returned in
            // `GetExpressCheckoutDetails` Response
            doExpressCheckoutPaymentRequestDetails.PayerID = "A9BVYX8XCR9ZQ";

            // # Payment Information
            // list of information about the payment
            List<PaymentDetailsType> paymentDetailsList = new List<PaymentDetailsType>();

            // information about the first payment
            PaymentDetailsType paymentDetails1 = new PaymentDetailsType();

            // Total cost of the transaction to the buyer. If shipping cost and tax
            // charges are known, include them in this value. If not, this value
            // should be the current sub-total of the order.
            //
            // If the transaction includes one or more one-time purchases, this field must be equal to
            // the sum of the purchases. Set this field to 0 if the transaction does
            // not include a one-time purchase such as when you set up a billing
            // agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            //
            // * `Currency Code` - You must set the currencyID attribute to one of the
            // 3-character currency codes for any of the supported PayPal
            // currencies.
            // * `Amount`
            BasicAmountType orderTotal1 = new BasicAmountType(CurrencyCodeType.USD, "2.00");
            paymentDetails1.OrderTotal = orderTotal1;

            // How you want to obtain payment. When implementing parallel payments,
            // this field is required and must be set to `Order`. When implementing
            // digital goods, this field is required and must be set to `Sale`. If the
            // transaction does not include a one-time purchase, this field is
            // ignored. It is one of the following values:
            //
            // * `Sale` - This is a final sale for which you are requesting payment
            // (default).
            // * `Authorization` - This payment is a basic authorization subject to
            // settlement with PayPal Authorization and Capture.
            // * `Order` - This payment is an order authorization subject to
            // settlement with PayPal Authorization and Capture.
            // Note:
            // You cannot set this field to Sale in SetExpressCheckout request and
            // then change the value to Authorization or Order in the
            // DoExpressCheckoutPayment request. If you set the field to
            // Authorization or Order in SetExpressCheckout, you may set the field
            // to Sale.
            paymentDetails1.PaymentAction = PaymentActionCodeType.ORDER;

            // Unique identifier for the merchant. For parallel payments, this field
            // is required and must contain the Payer Id or the email address of the
            // merchant.
            SellerDetailsType sellerDetails1 = new SellerDetailsType();
            sellerDetails1.PayPalAccountID = "*****@*****.**";
            paymentDetails1.SellerDetails = sellerDetails1;

            // A unique identifier of the specific payment request, which is
            // required for parallel payments.
            paymentDetails1.PaymentRequestID = "PaymentRequest1";

            // information about the second payment
            PaymentDetailsType paymentDetails2 = new PaymentDetailsType();
            // Total cost of the transaction to the buyer. If shipping cost and tax
            // charges are known, include them in this value. If not, this value
            // should be the current sub-total of the order.
            //
            // If the transaction includes one or more one-time purchases, this field must be equal to
            // the sum of the purchases. Set this field to 0 if the transaction does
            // not include a one-time purchase such as when you set up a billing
            // agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            //
            // * `Currency Code` - You must set the currencyID attribute to one of the
            // 3-character currency codes for any of the supported PayPal
            // currencies.
            // * `Amount`
            BasicAmountType orderTotal2 = new BasicAmountType(CurrencyCodeType.USD, "4.00");
            paymentDetails2.OrderTotal = orderTotal2;

            // How you want to obtain payment. When implementing parallel payments,
            // this field is required and must be set to `Order`. When implementing
            // digital goods, this field is required and must be set to `Sale`. If the
            // transaction does not include a one-time purchase, this field is
            // ignored. It is one of the following values:
            //
            // * `Sale` - This is a final sale for which you are requesting payment
            // (default).
            // * `Authorization` - This payment is a basic authorization subject to
            // settlement with PayPal Authorization and Capture.
            // * `Order` - This payment is an order authorization subject to
            // settlement with PayPal Authorization and Capture.
            // `Note:
            // You cannot set this field to Sale in SetExpressCheckout request and
            // then change the value to Authorization or Order in the
            // DoExpressCheckoutPayment request. If you set the field to
            // Authorization or Order in SetExpressCheckout, you may set the field
            // to Sale.`
            paymentDetails2.PaymentAction = PaymentActionCodeType.ORDER;

            // Unique identifier for the merchant. For parallel payments, this field
            // is required and must contain the Payer Id or the email address of the
            // merchant.
            SellerDetailsType sellerDetails2 = new SellerDetailsType();
            sellerDetails2.PayPalAccountID = "*****@*****.**";
            paymentDetails2.SellerDetails = sellerDetails2;

            // A unique identifier of the specific payment request, which is
            // required for parallel payments.
            paymentDetails2.PaymentRequestID = "PaymentRequest2";
            paymentDetailsList.Add(paymentDetails1);
            paymentDetailsList.Add(paymentDetails2);
            doExpressCheckoutPaymentRequestDetails.PaymentDetails = paymentDetailsList;

            DoExpressCheckoutPaymentRequestType doExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType(doExpressCheckoutPaymentRequestDetails);
            doExpressCheckoutPayment.DoExpressCheckoutPaymentRequest = doExpressCheckoutPaymentRequest;

            // Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

            // # API call
            // Invoke the DoExpressCheckoutPayment method in service wrapper object
            responseDoExpressCheckoutPaymentResponseType = service.DoExpressCheckoutPayment(doExpressCheckoutPayment);

            if (responseDoExpressCheckoutPaymentResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "DoExpressCheckoutPayment API Operation - ";
                acknowledgement += responseDoExpressCheckoutPaymentResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseDoExpressCheckoutPaymentResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Transaction identification number of the transaction that was
                    // created.
                    // This field is only returned after a successful transaction
                    // for DoExpressCheckout has occurred.
                    if (responseDoExpressCheckoutPaymentResponseType.DoExpressCheckoutPaymentResponseDetails.PaymentInfo != null)
                    {
                        IEnumerator<PaymentInfoType> paymentInfoIterator = responseDoExpressCheckoutPaymentResponseType.DoExpressCheckoutPaymentResponseDetails.PaymentInfo.GetEnumerator();
                        while (paymentInfoIterator.MoveNext())
                        {
                            PaymentInfoType paymentInfo = paymentInfoIterator.Current;
                            logger.Info("Transaction ID : " + paymentInfo.TransactionID + "\n");
                            Console.WriteLine("Transaction ID : " + paymentInfo.TransactionID + "\n");
                        }
                    }
                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoExpressCheckoutPaymentResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }

            return responseDoExpressCheckoutPaymentResponseType;
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseDoExpressCheckoutPaymentResponseType;
    }
        // # SetExpressCheckout API Operation
        // The SetExpressCheckout API operation initiates an Express Checkout transaction.
        public SetExpressCheckoutResponseType SetExpressCheckout(string payment)
        {
            // Create the SetExpressCheckoutResponseType object
            SetExpressCheckoutResponseType responseSetExpressCheckoutResponseType = new SetExpressCheckoutResponseType();

            try
            {
                // # SetExpressCheckoutReq
                SetExpressCheckoutRequestDetailsType setExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();

                // URL to which the buyer's browser is returned after choosing to pay
                // with PayPal. For digital goods, you must add JavaScript to this page
                // to close the in-context experience.
                // `Note:
                // PayPal recommends that the value be the final review page on which
                // the buyer confirms the order and payment or billing agreement.`
                setExpressCheckoutRequestDetails.ReturnURL = System.Web.Configuration.WebConfigurationManager.AppSettings["HostingEndpoint"] + "/HirerWorkOrder/PaymentPost";

                // URL to which the buyer is returned if the buyer does not approve the
                // use of PayPal to pay you. For digital goods, you must add JavaScript
                // to this page to close the in-context experience.
                // `Note:
                // PayPal recommends that the value be the original page on which the
                // buyer chose to pay with PayPal or establish a billing agreement.`
                setExpressCheckoutRequestDetails.CancelURL = System.Web.Configuration.WebConfigurationManager.AppSettings["HostingEndpoint"] + "/HirerWorkOrder/PaymentCancel";

                // # Payment Information
                // list of information about the payment
                List<PaymentDetailsType> paymentDetailsList = new List<PaymentDetailsType>();

                // information about the first payment
                PaymentDetailsType paymentDetails1 = new PaymentDetailsType();

                // Total cost of the transaction to the buyer. If shipping cost and tax
                // charges are known, include them in this value. If not, this value
                // should be the current sub-total of the order.
                //
                // If the transaction includes one or more one-time purchases, this field must be equal to
                // the sum of the purchases. Set this field to 0 if the transaction does
                // not include a one-time purchase such as when you set up a billing
                // agreement for a recurring payment that is not immediately charged.
                // When the field is set to 0, purchase-specific fields are ignored.
                //
                // * `Currency Code` - You must set the currencyID attribute to one of the
                // 3-character currency codes for any of the supported PayPal
                // currencies.
                // * `Amount`
                BasicAmountType orderTotal1 = new BasicAmountType(CurrencyCodeType.USD, payment);
                paymentDetails1.OrderTotal = orderTotal1;
                paymentDetails1.OrderDescription = System.Web.Configuration.WebConfigurationManager.AppSettings["PaypalDescription"];

                // How you want to obtain payment. When implementing parallel payments,
                // this field is required and must be set to `Order`. When implementing
                // digital goods, this field is required and must be set to `Sale`. If the
                // transaction does not include a one-time purchase, this field is
                // ignored. It is one of the following values:
                //
                // * `Sale` - This is a final sale for which you are requesting payment
                // (default).
                // * `Authorization` - This payment is a basic authorization subject to
                // settlement with PayPal Authorization and Capture.
                // * `Order` - This payment is an order authorization subject to
                // settlement with PayPal Authorization and Capture.
                // `Note:
                // You cannot set this field to Sale in SetExpressCheckout request and
                // then change the value to Authorization or Order in the
                // DoExpressCheckoutPayment request. If you set the field to
                // Authorization or Order in SetExpressCheckout, you may set the field
                // to Sale.`
                paymentDetails1.PaymentAction = PaymentActionCodeType.SALE;

                // Unique identifier for the merchant. For parallel payments, this field
                // is required and must contain the Payer Id or the email address of the
                // merchant.
                SellerDetailsType sellerDetails1 = new SellerDetailsType();
                sellerDetails1.PayPalAccountID = System.Web.Configuration.WebConfigurationManager.AppSettings["PayPalAccountID"];
                paymentDetails1.SellerDetails = sellerDetails1;

                // A unique identifier of the specific payment request, which is
                // required for parallel payments.
                paymentDetails1.PaymentRequestID = "PaymentRequest1";

                paymentDetailsList.Add(paymentDetails1);

                setExpressCheckoutRequestDetails.PaymentDetails = paymentDetailsList;

                SetExpressCheckoutReq setExpressCheckout = new SetExpressCheckoutReq();
                SetExpressCheckoutRequestType setExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails);

                setExpressCheckout.SetExpressCheckoutRequest = setExpressCheckoutRequest;

                // Create the service wrapper object to make the API call
                PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

                // # API call
                // Invoke the SetExpressCheckout method in service wrapper object
                responseSetExpressCheckoutResponseType = service.SetExpressCheckout(setExpressCheckout);
            }
            // # Exception log
            catch (System.Exception ex)
            {
                // Log the exception message
                levent.Level = LogLevel.Error;
                levent.Message = "Logon failed for PaypalExpressCheckout: " + ex.Message;
                log.Log(levent);
            }
            return responseSetExpressCheckoutResponseType;
        }
        protected void Search_Submit(object sender, EventArgs e)
        {
            // Create request object
            TransactionSearchRequestType request = new TransactionSearchRequestType();
            if (transactionID.Value != string.Empty)
            {
                request.TransactionID = transactionID.Value;
            }
            // (Required) The earliest transaction date at which to start the search.
            if (startDate != null && startDate.Text != null)
            {
                request.StartDate = startDate.Text;
            }
            // (Optional) The latest transaction date to be included in the search.
            if (endDate != null && endDate.Text != null)
            {
                request.EndDate = endDate.Text;
            }
            // (Optional) Search by the buyer's email address.
            if (payer.Value != string.Empty)
            {
                request.Payer = payer.Value;
            }
            // (Optional) Search by the receiver's email address. If the merchant account has only one email address, this is the primary email. It can also be a non-primary email address.
            if (receiver.Value != string.Empty)
            {
                request.Receiver = receiver.Value;
            }
            // (Optional) Search by the PayPal Account Optional receipt ID. This field is not applicable to point-of-sale transactions.
            if (receiptId.Value != string.Empty)
            {
                request.ReceiptID = receiptId.Value;
            }
            // (Optional) An alphanumeric string (generated by PayPal) that uniquely identifies a recurring profile. You can specify the Profile ID in the TransactionSearch API operation to obtain all payments associated with the identified profile.
            if (profileId.Value != string.Empty)
            {
                request.ProfileID = profileId.Value;
            }
            // (Optional) Search by auction item number of the purchased goods. This field is not applicable to point-of-sale.
            if (auctionItemNumber.Value != string.Empty)
            {
                request.AuctionItemNumber = auctionItemNumber.Value;
            }
            // (Optional) Search by invoice identification key, as set by you for the original transaction. This field searches the records for items the merchant sells.
            if (invoiceID.Value != string.Empty)
            {
                request.InvoiceID = invoiceID.Value;
            }
            // (Optional) Search by credit card number, as set by you for the original transaction. This field searches the records for items the merchant sells. The field is not applicable to point-of-sale.
            // Note: No wildcards are allowed.
            if (cardNumber.Value != string.Empty)
            {
                request.CardNumber = cardNumber.Value;
            }
            // (Optional) Search by classification of transaction. Some kinds of possible classes of transactions are not searchable with this field. You cannot search for bank transfer withdrawals, for example. It is one of the following values:
            // * All – All transaction classifications
            // * Sent – Only payments sent
            // * Received – Only payments received
            // * MassPay – Only mass payments
            // * MoneyRequest – Only money requests
            // * FundsAdded – Only funds added to balance
            // * FundsWithdrawn – Only funds withdrawn from balance
            // * Referral – Only transactions involving referrals
            // * Fee – Only transactions involving fees
            // * Subscription – Only transactions involving subscriptions
            // * Dividend – Only transactions involving dividends
            // * Billpay – Only transactions involving BillPay Transactions
            // * Refund – Only transactions involving funds
            // * CurrencyConversions – Only transactions involving currency conversions
            // * BalanceTransfer – Only transactions involving balance transfers
            // * Reversal – Only transactions involving BillPay reversals
            // * Shipping – Only transactions involving UPS shipping fees
            // * BalanceAffecting – Only transactions that affect the account balance
            // * ECheck – Only transactions involving eCheck
            if (transactionClass.SelectedIndex != 0)
            {
                request.TransactionClass = (PaymentTransactionClassCodeType)
                    Enum.Parse(typeof(PaymentTransactionClassCodeType), transactionClass.SelectedValue);
            }
            // (Optional) Search by transaction amount.
            // Note: You must set the currencyID attribute to one of the 3-character currency codes for any of the supported PayPal currencies.
            if (amount.Value != string.Empty && currencyCode.SelectedIndex != 0)
            {
                request.CurrencyCode = (CurrencyCodeType)
                    Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
                BasicAmountType searchAmount = new BasicAmountType(request.CurrencyCode, amount.Value);
                request.Amount = searchAmount;

            }
            // (Optional) Search by transaction status. It is one of the following values:
            // * Pending – The payment is pending. The specific reason the payment is pending is returned by the GetTransactionDetails API PendingReason field.
            // * Processing – The payment is being processed.
            // * Success – The payment has been completed and the funds have been added successfully to your account balance.
            // * Denied – You denied the payment. This happens only if the payment was previously pending.
            // * Reversed – A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer.
            if (transactionStatus.SelectedIndex != 0)
            {
                request.Status = (PaymentTransactionStatusCodeType)
                    Enum.Parse(typeof(PaymentTransactionStatusCodeType), transactionStatus.SelectedValue);
            }

            // Invoke the API
            TransactionSearchReq wrapper = new TransactionSearchReq();
            wrapper.TransactionSearchRequest = request;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // # API call
            // Invoke the TransactionSearch method in service wrapper object
            TransactionSearchResponseType transactionDetails = service.TransactionSearch(wrapper);

            // Check for API return status
            processResponse(service, transactionDetails);
        }
        private void populateRequest(CreateRecurringPaymentsProfileRequestType request)
        {
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), "USD");

            // Set EC-Token or Credit card requestDetails
            CreateRecurringPaymentsProfileRequestDetailsType profileDetails = new CreateRecurringPaymentsProfileRequestDetailsType();
            request.CreateRecurringPaymentsProfileRequestDetails = profileDetails;

            if(token.Value != "")
            {
                profileDetails.Token = token.Value;
            }
            else if (creditCardNumber.Value != "" && cvv.Value != "")
            {
                CreditCardDetailsType cc = new CreditCardDetailsType();
                cc.CreditCardNumber = creditCardNumber.Value;
                cc.CVV2 = cvv.Value;
                cc.ExpMonth = Int32.Parse(expMonth.SelectedValue);
                cc.ExpYear = Int32.Parse(expYear.SelectedValue);
                profileDetails.CreditCard = cc;
            }

            // Populate Recurring Payments Profile Details
            RecurringPaymentsProfileDetailsType rpProfileDetails =
                new RecurringPaymentsProfileDetailsType(billingStartDate.Text);
            profileDetails.RecurringPaymentsProfileDetails = rpProfileDetails;
            if(subscriberName.Value != "")
            {
                rpProfileDetails.SubscriberName = subscriberName.Value;
            }
            if(shippingName.Value != "" && shippingStreet1.Value != "" && shippingCity.Value != ""
                && shippingState.Value != "" && shippingPostalCode.Value != "" && shippingCountry.Value != "")
            {
                AddressType shippingAddr = new AddressType();
                shippingAddr.Name = shippingName.Value;
                shippingAddr.Street1 = shippingStreet1.Value;
                shippingAddr.CityName = shippingCity.Value;
                shippingAddr.StateOrProvince = shippingCity.Value;
                shippingAddr.CountryName = shippingCountry.Value;
                shippingAddr.PostalCode = shippingPostalCode.Value;

                if(shippingStreet2.Value != "")
                {
                    shippingAddr.Street2 = shippingStreet2.Value;
                }
                if(shippingPhone.Value != "")
                {
                    shippingAddr.Phone = shippingPhone.Value;
                }
                rpProfileDetails.SubscriberShippingAddress = shippingAddr;
            }

            // Populate schedule requestDetails
            ScheduleDetailsType scheduleDetails = new ScheduleDetailsType();
            profileDetails.ScheduleDetails = scheduleDetails;
            if(profileDescription.Value != "")
            {
                scheduleDetails.Description = profileDescription.Value;
            }
            if(maxFailedPayments.Value != "")
            {
                scheduleDetails.MaxFailedPayments = Int32.Parse(maxFailedPayments.Value);
            }
            if(autoBillOutstandingAmount.SelectedIndex != 0)
            {
                scheduleDetails.AutoBillOutstandingAmount = (AutoBillType)
                    Enum.Parse(typeof(AutoBillType), autoBillOutstandingAmount.SelectedValue);
            }
            if(initialAmount.Value != "")
            {
                ActivationDetailsType activationDetails =
                    new ActivationDetailsType(new BasicAmountType(currency, initialAmount.Value));
                if(failedInitialAmountAction.SelectedIndex != 0)
                {
                    activationDetails.FailedInitialAmountAction = (FailedPaymentActionType)
                        Enum.Parse(typeof(FailedPaymentActionType), failedInitialAmountAction.SelectedValue);
                }
                scheduleDetails.ActivationDetails = activationDetails;
            }
            if(trialBillingAmount.Value != "" && trialBillingFrequency.Value != ""
                    && trialBillingCycles.Value != "")
            {
                int frequency = Int32.Parse(trialBillingFrequency.Value);
                BasicAmountType paymentAmount = new BasicAmountType(currency, trialBillingAmount.Value);
                BillingPeriodType period = (BillingPeriodType)
                    Enum.Parse(typeof(BillingPeriodType), trialBillingPeriod.SelectedValue);
                int numCycles = Int32.Parse(trialBillingCycles.Value);

                BillingPeriodDetailsType trialPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
                trialPeriod.TotalBillingCycles = numCycles;
                if(trialShippingAmount.Value != "")
                {
                    trialPeriod.ShippingAmount = new BasicAmountType(currency, trialShippingAmount.Value);
                }
                if(trialTaxAmount.Value != "")
                {
                    trialPeriod.TaxAmount = new BasicAmountType(currency, trialTaxAmount.Value);
                }

                scheduleDetails.TrialPeriod = trialPeriod;
            }
            if(billingAmount.Value != "" && billingFrequency.Value != ""
                    && totalBillingCycles.Value != "")
            {
                int frequency = Int32.Parse(billingFrequency.Value);
                BasicAmountType paymentAmount = new BasicAmountType(currency, billingAmount.Value);
                BillingPeriodType period = (BillingPeriodType)
                    Enum.Parse(typeof(BillingPeriodType), billingPeriod.SelectedValue);
                int numCycles = Int32.Parse(totalBillingCycles.Value);

                BillingPeriodDetailsType paymentPeriod = new BillingPeriodDetailsType(period, frequency, paymentAmount);
                paymentPeriod.TotalBillingCycles = numCycles;
                if(trialShippingAmount.Value != "")
                {
                    paymentPeriod.ShippingAmount = new BasicAmountType(currency, shippingAmount.Value);
                }
                if(trialTaxAmount.Value != "")
                {
                    paymentPeriod.TaxAmount = new BasicAmountType(currency, taxAmount.Value);
                }
                scheduleDetails.PaymentPeriod = paymentPeriod;
            }
        }
    // # DoReauthorization API Operation
    // Authorize a payment
    public DoReauthorizationResponseType DoReauthorizationAPIOperation()
    {
        // Create the DoReauthorizationResponseType object
        DoReauthorizationResponseType responseDoReauthorizationResponseType = new DoReauthorizationResponseType();

        try
        {
            // Create the DoAuthorizationReq object
            DoReauthorizationReq requestDoReauthorization = new DoReauthorizationReq();

            // `Amount` to reauthorize which takes mandatory params:
            //
            // * `currencyCode`
            // * `amount`
            BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "3.00");

            // `DoReauthorizationRequest` which takes mandatory params:
            //
            // * `Authorization Id` - Value of a previously authorized transaction
            // identification number returned by PayPal.
            // * `amount`
            DoReauthorizationRequestType doReauthorizationRequest = new DoReauthorizationRequestType("9B2288061E685550E", amount);
            requestDoReauthorization.DoReauthorizationRequest = doReauthorizationRequest;

            // Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

            // # API call
            // Invoke the DoReauthorization method in service wrapper object
            responseDoReauthorizationResponseType = service.DoReauthorization(requestDoReauthorization);

            if (responseDoReauthorizationResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "DoReauthorization API Operation - ";
                acknowledgement += responseDoReauthorizationResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseDoReauthorizationResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Authorization identification number
                    logger.Info("Authorization ID : " + responseDoReauthorizationResponseType.AuthorizationID + "\n");
                    Console.WriteLine("Authorization ID : " + responseDoReauthorizationResponseType.AuthorizationID + "\n");
                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoReauthorizationResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseDoReauthorizationResponseType;
    }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public DiscountType(BasicAmountType amount)
 {
     this.Amount = amount;
 }
    // # SetExpressCheckout API Operation
    // The SetExpressCheckout API operation initiates an Express Checkout transaction. 
    public SetExpressCheckoutResponseType SetExpressCheckoutAPIOperation()
    {
        // Create the SetExpressCheckoutResponseType object
        SetExpressCheckoutResponseType responseSetExpressCheckoutResponseType = new SetExpressCheckoutResponseType();

        try
        {
            // # SetExpressCheckoutReq
            SetExpressCheckoutRequestDetailsType setExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();

            // URL to which the buyer's browser is returned after choosing to pay
            // with PayPal. For digital goods, you must add JavaScript to this page
            // to close the in-context experience.
            // `Note:
            // PayPal recommends that the value be the final review page on which
            // the buyer confirms the order and payment or billing agreement.`
            setExpressCheckoutRequestDetails.ReturnURL = "http://localhost/return";

            // URL to which the buyer is returned if the buyer does not approve the
            // use of PayPal to pay you. For digital goods, you must add JavaScript
            // to this page to close the in-context experience.
            // `Note:
            // PayPal recommends that the value be the original page on which the
            // buyer chose to pay with PayPal or establish a billing agreement.`
            setExpressCheckoutRequestDetails.CancelURL = "http://localhost/cancel";

            // # Payment Information
            // list of information about the payment
            List<PaymentDetailsType> paymentDetailsList = new List<PaymentDetailsType>();

            // information about the first payment
            PaymentDetailsType paymentDetails1 = new PaymentDetailsType();

            // Total cost of the transaction to the buyer. If shipping cost and tax
            // charges are known, include them in this value. If not, this value
            // should be the current sub-total of the order.
            //
            // If the transaction includes one or more one-time purchases, this field must be equal to
            // the sum of the purchases. Set this field to 0 if the transaction does
            // not include a one-time purchase such as when you set up a billing
            // agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            //
            // * `Currency Code` - You must set the currencyID attribute to one of the
            // 3-character currency codes for any of the supported PayPal
            // currencies.
            // * `Amount`
            BasicAmountType orderTotal1 = new BasicAmountType(CurrencyCodeType.USD, "2.00");
            paymentDetails1.OrderTotal = orderTotal1;

            // How you want to obtain payment. When implementing parallel payments,
            // this field is required and must be set to `Order`. When implementing
            // digital goods, this field is required and must be set to `Sale`. If the
            // transaction does not include a one-time purchase, this field is
            // ignored. It is one of the following values:
            //
            // * `Sale` - This is a final sale for which you are requesting payment
            // (default).
            // * `Authorization` - This payment is a basic authorization subject to
            // settlement with PayPal Authorization and Capture.
            // * `Order` - This payment is an order authorization subject to
            // settlement with PayPal Authorization and Capture.
            // `Note:
            // You cannot set this field to Sale in SetExpressCheckout request and
            // then change the value to Authorization or Order in the
            // DoExpressCheckoutPayment request. If you set the field to
            // Authorization or Order in SetExpressCheckout, you may set the field
            // to Sale.`
            paymentDetails1.PaymentAction = PaymentActionCodeType.ORDER;

            // Unique identifier for the merchant. For parallel payments, this field
            // is required and must contain the Payer Id or the email address of the
            // merchant.
            SellerDetailsType sellerDetails1 = new SellerDetailsType();
            sellerDetails1.PayPalAccountID = "*****@*****.**";
            paymentDetails1.SellerDetails = sellerDetails1;

            // A unique identifier of the specific payment request, which is
            // required for parallel payments.
            paymentDetails1.PaymentRequestID = "PaymentRequest1";

            // `Address` to which the order is shipped, which takes mandatory params:
            //
            // * `Street Name`
            // * `City`
            // * `State`
            // * `Country`
            // * `Postal Code`
            AddressType shipToAddress1 = new AddressType();
            shipToAddress1.Street1 = "Ape Way";
            shipToAddress1.CityName = "Austin";
            shipToAddress1.StateOrProvince = "TX";
            shipToAddress1.Country = CountryCodeType.US;
            shipToAddress1.PostalCode = "78750";

            paymentDetails1.ShipToAddress = shipToAddress1;

            // IPN URL
            // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed        
            // * The transaction related IPN variables will be received on the call back URL specified in the request       
            // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"     
            // * PayPal would continuously resend IPN if a wrong IPN is sent        
            paymentDetails1.NotifyURL = "http://IPNhost";

            // information about the second payment
            PaymentDetailsType paymentDetails2 = new PaymentDetailsType();
            // Total cost of the transaction to the buyer. If shipping cost and tax
            // charges are known, include them in this value. If not, this value
            // should be the current sub-total of the order.
            //
            // If the transaction includes one or more one-time purchases, this field must be equal to
            // the sum of the purchases. Set this field to 0 if the transaction does
            // not include a one-time purchase such as when you set up a billing
            // agreement for a recurring payment that is not immediately charged.
            // When the field is set to 0, purchase-specific fields are ignored.
            //
            // * `Currency Code` - You must set the currencyID attribute to one of the
            // 3-character currency codes for any of the supported PayPal
            // currencies.
            // * `Amount`
            BasicAmountType orderTotal2 = new BasicAmountType(CurrencyCodeType.USD, "4.00");
            paymentDetails2.OrderTotal = orderTotal2;

            // How you want to obtain payment. When implementing parallel payments,
            // this field is required and must be set to `Order`. When implementing
            // digital goods, this field is required and must be set to `Sale`. If the
            // transaction does not include a one-time purchase, this field is
            // ignored. It is one of the following values:
            //
            // * `Sale` - This is a final sale for which you are requesting payment
            // (default).
            // * `Authorization` - This payment is a basic authorization subject to
            // settlement with PayPal Authorization and Capture.
            // * `Order` - This payment is an order authorization subject to
            // settlement with PayPal Authorization and Capture.
            // `Note:
            // You cannot set this field to Sale in SetExpressCheckout request and
            // then change the value to Authorization or Order in the
            // DoExpressCheckoutPayment request. If you set the field to
            // Authorization or Order in SetExpressCheckout, you may set the field
            // to Sale.`
            paymentDetails2.PaymentAction = PaymentActionCodeType.ORDER;

            // Unique identifier for the merchant. For parallel payments, this field
            // is required and must contain the Payer Id or the email address of the
            // merchant.
            SellerDetailsType sellerDetails2 = new SellerDetailsType();
            sellerDetails2.PayPalAccountID = "*****@*****.**";
            paymentDetails2.SellerDetails = sellerDetails2;

            // A unique identifier of the specific payment request, which is
            // required for parallel payments.
            paymentDetails2.PaymentRequestID = "PaymentRequest2";

            // IPN URL
            // * PayPal Instant Payment Notification is a call back system that is initiated when a transaction is completed        
            // * The transaction related IPN variables will be received on the call back URL specified in the request       
            // * The IPN variables have to be sent back to the PayPal system for validation, upon validation PayPal will send a response string "VERIFIED" or "INVALID"     
            // * PayPal would continuously resend IPN if a wrong IPN is sent        
            paymentDetails2.NotifyURL = "http://IPNhost";

            // `Address` to which the order is shipped, which takes mandatory params:
            //
            // * `Street Name`
            // * `City`
            // * `State`
            // * `Country`
            // * `Postal Code`
            AddressType shipToAddress2 = new AddressType();
            shipToAddress2.Street1 = "Ape Way";
            shipToAddress2.CityName = "Austin";
            shipToAddress2.StateOrProvince = "TX";
            shipToAddress2.Country = CountryCodeType.US;
            shipToAddress2.PostalCode = "78750";
            paymentDetails2.ShipToAddress = shipToAddress2;

            paymentDetailsList.Add(paymentDetails1);
            paymentDetailsList.Add(paymentDetails2);

            setExpressCheckoutRequestDetails.PaymentDetails = paymentDetailsList;

            SetExpressCheckoutReq setExpressCheckout = new SetExpressCheckoutReq();
            SetExpressCheckoutRequestType setExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails);

            setExpressCheckout.SetExpressCheckoutRequest = setExpressCheckoutRequest;

            // Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

            // # API call            
            // Invoke the SetExpressCheckout method in service wrapper object
            responseSetExpressCheckoutResponseType = service.SetExpressCheckout(setExpressCheckout);

            if (responseSetExpressCheckoutResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "SetExpressCheckout API Operation - ";
                acknowledgement += responseSetExpressCheckoutResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseSetExpressCheckoutResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // # Redirecting to PayPal for authorization
                    // Once you get the "Success" response, needs to authorise the
                    // transaction by making buyer to login into PayPal. For that,
                    // need to construct redirect url using EC token from response.
                    // For example,
                    // `redirectURL="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="+setExpressCheckoutResponse.Token;`

                    // Express Checkout Token
                    logger.Info("Express Checkout Token : " + responseSetExpressCheckoutResponseType.Token + "\n");
                    Console.WriteLine("Express Checkout Token : " + responseSetExpressCheckoutResponseType.Token + "\n");
                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseSetExpressCheckoutResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }

        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseSetExpressCheckoutResponseType;
    }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public DoCaptureRequestType(string authorizationID, BasicAmountType amount, CompleteCodeType? completeType)
 {
     this.AuthorizationID = authorizationID;
     this.Amount = amount;
     this.CompleteType = completeType;
 }
 /**
  	  * Constructor with arguments
  	  */
 public DoCaptureRequestType(string AuthorizationID, BasicAmountType Amount, CompleteCodeType? CompleteType)
 {
     this.AuthorizationID = AuthorizationID;
     this.Amount = Amount;
     this.CompleteType = CompleteType;
 }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public DoUATPAuthorizationRequestType(UATPDetailsType uATPDetails, BasicAmountType amount)
 {
     this.UATPDetails = uATPDetails;
     this.Amount = amount;
 }
 /**
  	  * Constructor with arguments
  	  */
 public BillingPeriodDetailsType(BillingPeriodType? BillingPeriod, int? BillingFrequency, BasicAmountType Amount)
 {
     this.BillingPeriod = BillingPeriod;
     this.BillingFrequency = BillingFrequency;
     this.Amount = Amount;
 }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public MassPayRequestItemType(BasicAmountType amount)
 {
     this.Amount = amount;
 }
    // # DoCapture API Operation 
    // Captures an authorized payment. 
    public DoCaptureResponseType DoCaptureAPIOperation()
    {
        // Create the DoCaptureResponseType object
        DoCaptureResponseType responseDoCaptureResponseType = new DoCaptureResponseType();

        try
        {
            // Create the DoCapture object
            DoCaptureReq doCapture = new DoCaptureReq();

            // `Amount` to capture which takes mandatory params:
            //
            // * `currencyCode`
            // * `amount`
            BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "4.00");

            // `DoCaptureRequest` which takes mandatory params:
            //
            // * `Authorization ID` - Authorization identification number of the
            // payment you want to capture. This is the transaction ID returned from
            // DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
            // point-of-sale transactions, this is the transaction ID returned by
            // the CheckOut call when the payment action is Authorization.
            // * `amount` - Amount to capture
            // * `CompleteCode` - Indicates whether or not this is your last capture.
            // It is one of the following values:
            // * Complete – This is the last capture you intend to make.
            // * NotComplete – You intend to make additional captures.
            // `Note:
            // If Complete, any remaining amount of the original authorized
            // transaction is automatically voided and all remaining open
            // authorizations are voided.`
            DoCaptureRequestType doCaptureRequest = new DoCaptureRequestType("O-4VR15106P7416533H", amount, CompleteCodeType.NOTCOMPLETE);
            doCapture.DoCaptureRequest = doCaptureRequest;

            // Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

            // # API call
            // Invoke the DoCapture method in service wrapper object
            responseDoCaptureResponseType = service.DoCapture(doCapture);

            if (responseDoCaptureResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "DoCapture API Operation - ";
                acknowledgement += responseDoCaptureResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseDoCaptureResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Authorization identification number
                    logger.Info("Authorization ID : " + responseDoCaptureResponseType.DoCaptureResponseDetails.AuthorizationID + "\n");
                    Console.WriteLine("Authorization ID : " + responseDoCaptureResponseType.DoCaptureResponseDetails.AuthorizationID + "\n");

                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoCaptureResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseDoCaptureResponseType;
    }
 /// <summary>
 /// Constructor with arguments
 /// </summary>
 public BillingPeriodDetailsType(BillingPeriodType? billingPeriod, int? billingFrequency, BasicAmountType amount)
 {
     this.BillingPeriod = billingPeriod;
     this.BillingFrequency = billingFrequency;
     this.Amount = amount;
 }
    // # CreateRecurringPaymentsProfile API Operation
    // The CreateRecurringPaymentsProfile API operation creates a recurring payments profile.
    // You must invoke the CreateRecurringPaymentsProfile API operation for each profile you want to create. 
    // The API operation creates a profile and an associated billing agreement. 
    // Note: 
    // There is a one-to-one correspondence between billing agreements and recurring payments profiles. 
    // To associate a recurring payments profile with its billing agreement, 
    // you must ensure that the description in the recurring payments profile matches the description of a billing agreement. 
    // For version 54.0 and later, use SetExpressCheckout to initiate creation of a billing agreement.
    public CreateRecurringPaymentsProfileResponseType CreateRecurringPaymentsProfileAPIOperation()
    {
        // Create the CreateRecurringPaymentsProfileResponseType object
        CreateRecurringPaymentsProfileResponseType responseCreateRecurringPaymentsProfileResponseType = new CreateRecurringPaymentsProfileResponseType();

        try
        {
            // Create the CreateRecurringPaymentsProfileReq object
            CreateRecurringPaymentsProfileReq createRecurringPaymentsProfile = new CreateRecurringPaymentsProfileReq();

            // Create the CreateRecurringPaymentsProfileRequestType object
            CreateRecurringPaymentsProfileRequestType createRecurringPaymentsProfileRequest = new CreateRecurringPaymentsProfileRequestType();

            // You can include up to 10 recurring payments profiles per request. The
            // order of the profile details must match the order of the billing
            // agreement details specified in the SetExpressCheckout request which
            // takes mandatory argument:
            // 
            // * `billing start date` - The date when billing for this profile begins.
            // `Note:
            // The profile may take up to 24 hours for activation.`
            RecurringPaymentsProfileDetailsType recurringPaymentsProfileDetails
                = new RecurringPaymentsProfileDetailsType("2013-12-31T13:01:19+00:00");

            // Billing amount for each billing cycle during this payment period.
            // This amount does not include shipping and tax amounts.
            // `Note:
            // All amounts in the CreateRecurringPaymentsProfile request must have
            // the same currency.`
            BasicAmountType billingAmount = new BasicAmountType(CurrencyCodeType.USD, "3.00");

            // Regular payment period for this schedule which takes mandatory
            // params:
            //  
            // * `Billing Period` - Unit for billing during this subscription period. It is one of the
            // following values:
            //  * Day
            //  * Week
            //  * SemiMonth
            //  * Month
            //  * Year
            //  For SemiMonth, billing is done on the 1st and 15th of each month.
            //  `Note:
            //  The combination of BillingPeriod and BillingFrequency cannot exceed
            //  one year.`
            // * `Billing Frequency` - Number of billing periods that make up one billing cycle.
            // The combination of billing frequency and billing period must be less
            // than or equal to one year. For example, if the billing cycle is
            // Month, the maximum value for billing frequency is 12. Similarly, if
            // the billing cycle is Week, the maximum value for billing frequency is
            // 52.
            // `Note:
            // If the billing period is SemiMonth, the billing frequency must be 1.`
            // * `Billing Amount`
            BillingPeriodDetailsType paymentPeriod = new BillingPeriodDetailsType(BillingPeriodType.DAY, Convert.ToInt32("5"), billingAmount);

            // Describes the recurring payments schedule, including the regular
            // payment period, whether there is a trial period, and the number of
            // payments that can fail before a profile is suspended which takes
            // mandatory params:
            //  
            // * `Description` - Description of the recurring payment.
            // `Note:
            // You must ensure that this field matches the corresponding billing
            // agreement description included in the SetExpressCheckout request.`
            // * `Payment Period`
            ScheduleDetailsType scheduleDetails = new ScheduleDetailsType("description", paymentPeriod);

            // `CreateRecurringPaymentsProfileRequestDetailsType` which takes
            // mandatory params:
            //      
            // * `Recurring Payments Profile Details`
            // * `Schedule Details`
            CreateRecurringPaymentsProfileRequestDetailsType createRecurringPaymentsProfileRequestDetails
                = new CreateRecurringPaymentsProfileRequestDetailsType(recurringPaymentsProfileDetails, scheduleDetails);

            // Either EC token or a credit card number is required.If you include
            // both token and credit card number, the token is used and credit card number is
            // ignored
            // In case of setting EC token,
            // `createRecurringPaymentsProfileRequestDetails.Token = "EC-5KH01765D1724703R";`
            // A timestamped token, the value of which was returned in the response
            // to the first call to SetExpressCheckout. Call
            // CreateRecurringPaymentsProfile once for each billing
            // agreement included in SetExpressCheckout request and use the same
            // token for each call. Each CreateRecurringPaymentsProfile request
            // creates a single recurring payments profile.
            // `Note:
            // Tokens expire after approximately 3 hours.`

            // Credit card information for recurring payments using direct payments.
            CreditCardDetailsType creditCard = new CreditCardDetailsType();

            // Type of credit card. For UK, only Maestro, MasterCard, Discover, and
            // Visa are allowable. For Canada, only MasterCard and Visa are
            // allowable and Interac debit cards are not supported. It is one of the
            // following values:
            //  
            // * Visa
            // * MasterCard
            // * Discover
            // * Amex
            // * Solo
            // * Switch
            // * Maestro: See note.
            // `Note:
            // If the credit card type is Maestro, you must set currencyId to GBP.
            // In addition, you must specify either StartMonth and StartYear or
            // IssueNumber.`
            creditCard.CreditCardType = CreditCardTypeType.VISA;

            // Credit Card Number
            creditCard.CreditCardNumber = "4442662639546634";

            // Credit Card Expiration Month
            creditCard.ExpMonth = Convert.ToInt32("12");

            // Credit Card Expiration Year
            creditCard.ExpYear = Convert.ToInt32("2016");
            createRecurringPaymentsProfileRequestDetails.CreditCard = creditCard;

            createRecurringPaymentsProfileRequest.CreateRecurringPaymentsProfileRequestDetails
                = createRecurringPaymentsProfileRequestDetails;

            createRecurringPaymentsProfile.CreateRecurringPaymentsProfileRequest = createRecurringPaymentsProfileRequest;

            // # Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();


            // # API call
            // Invoke the CreateRecurringPaymentsProfile method
            responseCreateRecurringPaymentsProfileResponseType
                = service.CreateRecurringPaymentsProfile(createRecurringPaymentsProfile);

            if (responseCreateRecurringPaymentsProfileResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "CreateRecurringPaymentsProfile API Operation - ";
                acknowledgement += responseCreateRecurringPaymentsProfileResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseCreateRecurringPaymentsProfileResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // A unique identifier for future reference to the details of this recurring payment
                    logger.Info("Profile ID : " + responseCreateRecurringPaymentsProfileResponseType.CreateRecurringPaymentsProfileResponseDetails.ProfileID + "\n");
                    Console.WriteLine("Profile ID : " + responseCreateRecurringPaymentsProfileResponseType.CreateRecurringPaymentsProfileResponseDetails.ProfileID + "\n");
                }
                // # Error Values           
                else
                {
                    List<ErrorType> errorMessages = responseCreateRecurringPaymentsProfileResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseCreateRecurringPaymentsProfileResponseType;
    }