コード例 #1
0
ファイル: ChargeTests.cs プロジェクト: whoffman/stripe-dotnet
        public void ListCharges_Test()
        {
            StripeArray response = _client.ListCharges();

            Assert.NotNull(response);
            Assert.False(response.IsError);
            Assert.True(response.Any());
        }
コード例 #2
0
ファイル: RefundTests.cs プロジェクト: kikotaz/ParkKL
        public void List_Refund_Card_Charge_Test()
        {
            dynamic charge = _client.CreateCharge(100M, "usd", _card);

            dynamic refund       = _client.CreateRefund(charge.Id, amount: 10M);
            dynamic secondRefund = _client.CreateRefund(charge.Id, amount: 15M);

            StripeArray response = _client.ListRefunds(charge.Id, limit: 2);

            Assert.NotNull(response);
            Assert.False(response.IsError);
            Assert.True(response.Any());
        }
コード例 #3
0
ファイル: StripeClient.cs プロジェクト: JasonS/stripe-dotnet
        /// <summary>
        /// Execute a manual REST request
        /// </summary>
        /// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam>
        /// <param name="request">The RestRequest to execute (will use client credentials)</param>
        public StripeArray ExecuteArray(RestRequest request)
        {
            request.OnBeforeDeserialization = (resp) => {
                // for individual resources when there's an error to make
                // sure that RestException props are populated
                if (((int)resp.StatusCode) >= 400)
                    request.RootElement = "";
            };

            var response = _client.Execute(request);
            var json = Deserialize(response.Content);
            var obj = new StripeArray();
            obj.SetModel(json);

            return obj;
        }
コード例 #4
0
        public void ListCharges_TestDateRange()
        {
            var         begin    = new DateTimeOffset(new DateTime(2013, 1, 1));
            var         end      = new DateTimeOffset(new DateTime(2014, 1, 1));
            StripeArray response = _client.ListCharges(periodBegin: begin, periodEnd: end);

            Assert.NotNull(response);
            Assert.False(response.IsError);
            Assert.True(response.Any());

            foreach (var obj in response)
            {
                var created = long.Parse(obj["created"].ToString()).ToDateTime();
                Assert.True(created >= begin);
                Assert.True(created < end);
            }
        }