public static NvpBaItem GetBillingAgreement(String subscription, String description)
        {
            NvpBaItem agreement = new NvpBaItem();
            agreement.BillingType = NvpBillingCodeType.RecurringPayments;
            agreement.Custom = subscription;
            agreement.Description = description;
            agreement.PaymentType = NvpMerchantPullPaymentCodeType.Any;

            return agreement;
        }
        public ProfileResultStatus CreateRecurringPayment(NvpBaItem agreement, Double total, int freeTrial = -1)
        {
            if (freeTrial == -1)
                freeTrial = GooeyConfigManager.FreeTrialLength;

            NvpCreateRecurringPaymentsProfile action = new NvpCreateRecurringPaymentsProfile();
            SetDefaults(action);

            action.Add(NvpCreateRecurringPaymentsProfile.Request._TOKEN, token);
            action.Add(NvpCreateRecurringPaymentsProfile.Request._DESC, agreement.Description);
            action.Add(NvpCreateRecurringPaymentsProfile.Request._PROFILESTARTDATE, DateTime.Now.ToUniversalTime().ToString("o"));
            action.Add(NvpCreateRecurringPaymentsProfile.Request._AMT, total.ToString("f"));
            action.Add(NvpCreateRecurringPaymentsProfile.Request._BILLINGFREQUENCY, "1");
            action.Add(NvpCreateRecurringPaymentsProfile.Request._BILLINGPERIOD, NvpBillingPeriodType.Month);

            if (freeTrial > 0)
            {
                action.Add(NvpCreateRecurringPaymentsProfile.Request._TRIALBILLINGPERIOD, NvpBillingPeriodType.Day);
                action.Add(NvpCreateRecurringPaymentsProfile.Request._TRIALBILLINGFREQUENCY, "1"); //bill once a day for "freetriallength" days
                action.Add(NvpCreateRecurringPaymentsProfile.Request._TRIALTOTALBILLINGCYCLES, freeTrial.ToString());
                action.Add(NvpCreateRecurringPaymentsProfile.Request._TRIALAMT, Double.Parse("0").ToString("f"));
            }

            action.Add(NvpCreateRecurringPaymentsProfile.Request.MAXFAILEDPAYMENTS, GooeyConfigManager.PaypalMaxFailedPayments.ToString());
            action.Add(NvpCreateRecurringPaymentsProfile.Request.AUTOBILLOUTAMT, NvpAutoBillType.AddToNextBilling);

            Boolean result = action.Post();
            if (!result)
                throw PaypalException.GenerateException(action);

            String profileId = action.Get(NvpCreateRecurringPaymentsProfile.Response.PROFILEID);
            String profileStatus = action.Get(NvpCreateRecurringPaymentsProfile.Response.PROFILESTATUS);

            ProfileResultStatus status = new ProfileResultStatus();
            status.ProfileId = profileId;
            status.ProfileStatus = profileStatus;

            return status;
        }
 public void AddBillingAgreement(NvpBaItem agreement)
 {
     this.billingAgreements.Add(agreement);
 }