public virtual StripeRefund Update(string refundId, StripeRefundUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeRefund> .MapFromJson(
                Requestor.PostString(
                    this.ApplyAllParameters(updateOptions, $"{Urls.BaseUrl}/refunds/{refundId}"),
                    SetupRequestOptions(requestOptions)
                    )
                ));
 }
        public virtual async Task <IEnumerable <StripeCard> > ListAsync(string customerOrRecipientId, StripeListOptions listOptions = null, bool isRecipient = false, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = SetupUrl(customerOrRecipientId, isRecipient);

            return(Mapper <StripeCard> .MapCollectionFromJson(
                       await Requestor.GetStringAsync(this.ApplyAllParameters(listOptions, url, true),
                                                      SetupRequestOptions(requestOptions),
                                                      cancellationToken)
                       ));
        }
        public static StripeResponse PostStringBearer(string url, StripeRequestOptions requestOptions)
        {
            var wr = GetRequestMessage(url, HttpMethod.Post, requestOptions, true);

            return(ExecuteRequest(wr));
        }
        public static Task <StripeResponse> PostStringAsync(string url, StripeRequestOptions requestOptions, CancellationToken cancellationToken = default(CancellationToken))
        {
            var wr = GetRequestMessage(url, HttpMethod.Post, requestOptions);

            return(ExecuteRequestAsync(wr, cancellationToken));
        }
        public virtual async Task <StripeCard> CreateAsync(string recipientId, StripeCreditCardOptions createOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = SetupUrl(recipientId, true);

            return(Mapper <StripeCard> .MapFromJson(
                       await Requestor.PostStringAsync(this.ApplyAllParameters(createOptions, url, false),
                                                       SetupRequestOptions(requestOptions),
                                                       cancellationToken)
                       ));
        }
        private static HttpRequestMessage GetRequestMessage(string url, HttpMethod method, StripeRequestOptions requestOptions, bool useBearer = false)
        {
            requestOptions.ApiKey = requestOptions.ApiKey ?? StripeConfiguration.GetApiKey();

#if NET45
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
#endif

            var request = BuildRequest(method, url);

            request.Headers.Add("Authorization",
                                !useBearer
                    ? GetAuthorizationHeaderValue(requestOptions.ApiKey)
                    : GetAuthorizationHeaderValueBearer(requestOptions.ApiKey));

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

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

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

            var client = new Client(request);
            client.ApplyUserAgent();
            client.ApplyClientData();

            return(request);
        }
示例#7
0
        public virtual async Task <StripeCharge> CaptureAsync(string chargeId, int?captureAmount = null, int?applicationFee = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = Infrastructure.ParameterBuilder.ApplyAllParameters(this, null, $"{Urls.Charges}/{chargeId}/capture", false);

            if (captureAmount.HasValue)
            {
                url = Infrastructure.ParameterBuilder.ApplyParameterToUrl(url, "amount", captureAmount.Value.ToString());
            }
            if (applicationFee.HasValue)
            {
                url = Infrastructure.ParameterBuilder.ApplyParameterToUrl(url, "application_fee", applicationFee.Value.ToString());
            }

            return(Mapper <StripeCharge> .MapFromJson(
                       await Requestor.PostStringAsync(url,
                                                       SetupRequestOptions(requestOptions),
                                                       cancellationToken)
                       ));
        }
        public virtual StripeDeleted Delete(string customerOrRecipientId, string cardId, bool isRecipient = false, StripeRequestOptions requestOptions = null)
        {
            var url = SetupUrl(customerOrRecipientId, isRecipient, cardId);

            return(Mapper <StripeDeleted> .MapFromJson(
                       Requestor.Delete(url, SetupRequestOptions(requestOptions))
                       ));
        }
 public virtual async Task <IEnumerable <StripeRefund> > ListAsync(StripeRefundListOptions listOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeRefund> .MapCollectionFromJson(
                await Requestor.GetStringAsync(
                    this.ApplyAllParameters(listOptions, $"{Urls.BaseUrl}/refunds", true),
                    SetupRequestOptions(requestOptions),
                    cancellationToken
                    )
                ));
 }
示例#10
0
 public virtual async Task <StripeList <StripeCharge> > ListAsync(StripeChargeListOptions listOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeList <StripeCharge> > .MapFromJson(
                await Requestor.GetStringAsync(Infrastructure.ParameterBuilder.ApplyAllParameters(this, listOptions, Urls.Charges, true),
                                               SetupRequestOptions(requestOptions),
                                               cancellationToken)
                ));
 }
 public virtual async Task <StripeRefund> UpdateAsync(string refundId, StripeRefundUpdateOptions updateOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeRefund> .MapFromJson(
                await Requestor.PostStringAsync(
                    this.ApplyAllParameters(updateOptions, $"{Urls.BaseUrl}/refunds/{refundId}"),
                    SetupRequestOptions(requestOptions),
                    cancellationToken
                    )
                ));
 }
 //Async
 public virtual async Task <StripeRefund> CreateAsync(string chargeId, StripeRefundCreateOptions createOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeRefund> .MapFromJson(
                await Requestor.PostStringAsync(this.ApplyAllParameters(createOptions, $"{Urls.Charges}/{chargeId}/refunds", false),
                                                SetupRequestOptions(requestOptions),
                                                cancellationToken)
                ));
 }
 public virtual IEnumerable <StripeRefund> List(StripeRefundListOptions listOptions = null, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeRefund> .MapCollectionFromJson(
                Requestor.GetString(
                    this.ApplyAllParameters(listOptions, $"{Urls.BaseUrl}/refunds", true),
                    SetupRequestOptions(requestOptions)
                    )
                ));
 }
        public virtual StripeCard Create(string recipientId, StripeCreditCardOptions createOptions, StripeRequestOptions requestOptions = null)
        {
            var url = SetupUrl(recipientId, true);

            return(Mapper <StripeCard> .MapFromJson(
                       Requestor.PostString(this.ApplyAllParameters(createOptions, url, false),
                                            SetupRequestOptions(requestOptions))
                       ));
        }
示例#15
0
 public virtual StripeCharge Update(string chargeId, StripeChargeUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeCharge> .MapFromJson(
                Requestor.PostString(Infrastructure.ParameterBuilder.ApplyAllParameters(this, updateOptions, $"{Urls.Charges}/{chargeId}", false),
                                     SetupRequestOptions(requestOptions))
                ));
 }
        public virtual StripeCard Update(string customerOrRecipientId, string cardId, StripeCardUpdateOptions updateOptions, bool isRecipient = false, StripeRequestOptions requestOptions = null)
        {
            var url = SetupUrl(customerOrRecipientId, isRecipient, cardId);

            return(Mapper <StripeCard> .MapFromJson(
                       Requestor.PostString(this.ApplyAllParameters(updateOptions, url, false),
                                            SetupRequestOptions(requestOptions))
                       ));
        }
示例#17
0
 public virtual StripeList <StripeCharge> List(StripeChargeListOptions listOptions = null, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeList <StripeCharge> > .MapFromJson(
                Requestor.GetString(Infrastructure.ParameterBuilder.ApplyAllParameters(this, listOptions, Urls.Charges, true),
                                    SetupRequestOptions(requestOptions))
                ));
 }
        public virtual IEnumerable <StripeCard> List(string customerOrRecipientId, StripeListOptions listOptions = null, bool isRecipient = false, StripeRequestOptions requestOptions = null)
        {
            var url = SetupUrl(customerOrRecipientId, isRecipient);

            return(Mapper <StripeCard> .MapCollectionFromJson(
                       Requestor.GetString(this.ApplyAllParameters(listOptions, url, true),
                                           SetupRequestOptions(requestOptions))
                       ));
        }
示例#19
0
        public virtual StripeCharge Capture(string chargeId, int?captureAmount = null, int?applicationFee = null, StripeRequestOptions requestOptions = null)
        {
            var url = Infrastructure.ParameterBuilder.ApplyAllParameters(this, null, $"{Urls.Charges}/{chargeId}/capture", false);

            if (captureAmount.HasValue)
            {
                url = Infrastructure.ParameterBuilder.ApplyParameterToUrl(url, "amount", captureAmount.Value.ToString());
            }
            if (applicationFee.HasValue)
            {
                url = Infrastructure.ParameterBuilder.ApplyParameterToUrl(url, "application_fee", applicationFee.Value.ToString());
            }

            return(Mapper <StripeCharge> .MapFromJson(
                       Requestor.PostString(url,
                                            SetupRequestOptions(requestOptions))
                       ));
        }
        public static Task <StripeResponse> PostFileAsync(string url, string fileName, Stream fileStream, string purpose, StripeRequestOptions requestOptions, CancellationToken cancellationToken = default(CancellationToken))
        {
            var wr = GetRequestMessage(url, HttpMethod.Post, requestOptions);

            ApplyMultiPartFileToRequest(wr, fileName, fileStream, purpose);

            return(ExecuteRequestAsync(wr, cancellationToken));
        }
示例#21
0
 //Async
 public virtual async Task <StripeCharge> CreateAsync(StripeChargeCreateOptions createOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeCharge> .MapFromJson(
                await Requestor.PostStringAsync(Infrastructure.ParameterBuilder.ApplyAllParameters(this, createOptions, Urls.Charges, false),
                                                SetupRequestOptions(requestOptions),
                                                cancellationToken)
                ));
 }
        public static StripeResponse Delete(string url, StripeRequestOptions requestOptions)
        {
            var wr = GetRequestMessage(url, HttpMethod.Delete, requestOptions);

            return(ExecuteRequest(wr));
        }
        public virtual async Task <StripeCard> UpdateAsync(string customerOrRecipientId, string cardId, StripeCardUpdateOptions updateOptions, bool isRecipient = false, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = SetupUrl(customerOrRecipientId, isRecipient, cardId);

            return(Mapper <StripeCard> .MapFromJson(
                       await Requestor.PostStringAsync(this.ApplyAllParameters(updateOptions, url, false),
                                                       SetupRequestOptions(requestOptions),
                                                       cancellationToken)
                       ));
        }
        public static StripeResponse PostFile(string url, string fileName, Stream fileStream, string purpose, StripeRequestOptions requestOptions)
        {
            var wr = GetRequestMessage(url, HttpMethod.Post, requestOptions);

            ApplyMultiPartFileToRequest(wr, fileName, fileStream, purpose);

            return(ExecuteRequest(wr));
        }
        public virtual async Task <StripeDeleted> DeleteAsync(string customerOrRecipientId, string cardId, bool isRecipient = false, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var url = SetupUrl(customerOrRecipientId, isRecipient, cardId);

            return(Mapper <StripeDeleted> .MapFromJson(
                       await Requestor.DeleteAsync(url,
                                                   SetupRequestOptions(requestOptions),
                                                   cancellationToken)
                       ));
        }
示例#26
0
 //Async
 public virtual async Task <StripeToken> CreateAsync(StripeTokenCreateOptions createOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeToken> .MapFromJson(
                await Requestor.PostStringAsync(this.ApplyAllParameters(createOptions, Urls.Tokens, false),
                                                SetupRequestOptions(requestOptions),
                                                cancellationToken)
                ));
 }
 //Sync
 public virtual StripeRefund Create(string chargeId, StripeRefundCreateOptions createOptions = null, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeRefund> .MapFromJson(
                Requestor.PostString(this.ApplyAllParameters(createOptions, $"{Urls.Charges}/{chargeId}/refunds", false),
                                     SetupRequestOptions(requestOptions))
                ));
 }