Stripe.StripeCustomerService.Get C# (CSharp) Method

Get() public method

public Get ( string customerId, Stripe.StripeRequestOptions requestOptions = null ) : Stripe.StripeCustomer
customerId string
requestOptions Stripe.StripeRequestOptions
return Stripe.StripeCustomer
        public virtual StripeCustomer Get(string customerId, StripeRequestOptions requestOptions = null)
        {
            return Mapper<StripeCustomer>.MapFromJson(
                Requestor.GetString(this.ApplyAllParameters(null, $"{Urls.Customers}/{customerId}", false),
                SetupRequestOptions(requestOptions))
            );
        }

Usage Example

        SubscriptionDetails ISubscriptionService.GetCustomerSubscription(string customerBillingId)
        {
            SubscriptionDetails subscription = null;

            try
            {
                var customerService = new StripeCustomerService();
                StripeCustomer stripeCustomer = customerService.Get(customerBillingId);
                Coupon coupon = null;
                Discount discount = null;
                if (stripeCustomer.StripeDiscount != null && stripeCustomer.StripeDiscount.StripeCoupon != null)
                {
                    coupon = new Coupon
                    {
                        AmountOff = stripeCustomer.StripeDiscount.StripeCoupon.AmountOff,
                        Duration = stripeCustomer.StripeDiscount.StripeCoupon.Duration,
                        DurationInMonths = stripeCustomer.StripeDiscount.StripeCoupon.DurationInMonths,
                        Id = stripeCustomer.StripeDiscount.StripeCoupon.Id,
                        PercentOff = stripeCustomer.StripeDiscount.StripeCoupon.PercentOff,
                        RedeemBy = stripeCustomer.StripeDiscount.StripeCoupon.RedeemBy
                    };
                    discount = new Discount
                    {
                        Coupon = coupon,
                        End = stripeCustomer.StripeDiscount.End,
                        Id = stripeCustomer.StripeDiscount.Id,
                        Start = stripeCustomer.StripeDiscount.Start
                    };
                }

                subscription = new SubscriptionDetails
                {
                    Created = stripeCustomer.Created,
                    Deleted = stripeCustomer.Deleted,
                    CanceledAt = stripeCustomer.StripeSubscription != null? stripeCustomer.StripeSubscription.CanceledAt : null,
                    CustomerId = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.CustomerId: null,
                    EndedAt = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.EndedAt: null,
                    PeriodEnd = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.PeriodEnd: null,
                    PeriodStart = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.PeriodStart: null,
                    Start = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.Start: null,
                    TrialEnd = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.TrialEnd: null,
                    TrialStart = stripeCustomer.StripeSubscription != null?stripeCustomer.StripeSubscription.TrialStart: null,
                    Status = stripeCustomer.StripeSubscription != null? stripeCustomer.StripeSubscription.Status: null,
                    Plan = stripeCustomer.StripeSubscription != null ? stripeCustomer.StripeSubscription.StripePlan.Name : null,
                    Discount = discount
                };
            }
            catch { }

            return subscription;
        }
All Usage Examples Of Stripe.StripeCustomerService::Get