Beispiel #1
0
        internal static WebRequest GetWebRequest(string url, string method, StripeRequestOptions requestOptions, bool useBearer = false)
        {
            requestOptions.ApiKey = requestOptions.ApiKey ?? StripeConfiguration.GetApiKey();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = method;

            if (!useBearer)
            {
                request.Headers.Add("Authorization", GetAuthorizationHeaderValue(requestOptions.ApiKey));
            }
            else
            {
                request.Headers.Add("Authorization", GetAuthorizationHeaderValueBearer(requestOptions.ApiKey));
            }

            request.Headers.Add("Stripe-Version", StripeConfiguration.ApiVersion);

            if (requestOptions.StripeConnectAccountId != null)
            {
                request.Headers.Add("Stripe-Account", requestOptions.StripeConnectAccountId);
            }

            if (requestOptions.IdempotencyKey != null)
            {
                request.Headers.Add("Idempotency-Key", requestOptions.IdempotencyKey);
            }

            request.ContentType = "application/x-www-form-urlencoded";
            request.UserAgent   = "Stripe.net (https://github.com/jaymedavis/stripe.net)";

            return(request);
        }
Beispiel #2
0
        internal static WebRequest GetWebRequest(string url, string method, string apiKey = null, bool useBearer = false)
        {
            apiKey = apiKey ?? StripeConfiguration.GetApiKey();

            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = method;

            if (!useBearer)
            {
                request.Headers.Add("Authorization", GetAuthorizationHeaderValue(apiKey));
            }
            else
            {
                request.Headers.Add("Authorization", GetAuthorizationHeaderValueBearer(apiKey));
            }

            request.Headers.Add("Stripe-Version", StripeConfiguration.ApiVersion);

            request.ContentType = "application/x-www-form-urlencoded";
            request.UserAgent   = "Stripe.net (https://github.com/jaymedavis/stripe.net)";

            return(request);
        }
Beispiel #3
0
 public StripeEventService(StripeConfiguration config)
     : base(config)
 {
 }
 public StripeInvoiceItemService(StripeConfiguration config)
     : base(config)
 {
 }
Beispiel #5
0
 protected virtual string ClassUrl(string parentId, string baseUrl = null)
 {
     baseUrl = baseUrl ?? StripeConfiguration.GetApiBase();
     return($"{baseUrl}{this.BasePath.Replace("{PARENT_ID}", parentId)}");
 }
Beispiel #6
0
 public StripeTokenService(StripeConfiguration config)
     : base(config)
 {
 }
Beispiel #7
0
 protected virtual string ClassUrl(string baseUrl = null)
 {
     baseUrl = baseUrl ?? StripeConfiguration.GetApiBase();
     return($"{baseUrl}{this.BasePath}");
 }
 public StripeChargeService(StripeConfiguration config)
     : base(config)
 {
 }
Beispiel #9
0
 internal Requestor(StripeConfiguration config)
 {
     this.config = config;
     this.AuthorizationHeaderValue = GetAuthorizationHeaderValue(config.ApiKey);
 }
Beispiel #10
0
 public StripeCustomerService(StripeConfiguration config)
     : base(config)
 {
 }