コード例 #1
0
        public StripeCharge Charge(int amount_cents, string currency, StripeCreditCardInfo card, string description)
        {
            if (card == null)
                throw new ArgumentNullException ("card");

            return Charge (amount_cents, currency, null, card, description);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: gooley/stripe-dotnet
 static StripeCreditCardInfo GetCC()
 {
     StripeCreditCardInfo cc = new StripeCreditCardInfo ();
     cc.CVC = "1234";
     cc.ExpirationMonth = 6;
     cc.ExpirationYear = 2012;
     cc.Number = "4242424242424242";
     return cc;
 }
コード例 #3
0
        StripeCharge Charge(int amount_cents, string currency, string customer, StripeCreditCardInfo card, string description)
        {
            if (amount_cents < 0)
                throw new ArgumentOutOfRangeException ("amount_cents", "Must be greater than or equal 0");
            if (String.IsNullOrEmpty (currency))
                throw new ArgumentNullException ("currency");
            if (currency != "usd")
                throw new ArgumentException ("The only supported currency is 'usd'");

            StringBuilder str = new StringBuilder ();
            str.AppendFormat ("amount={0}&", amount_cents);
            str.AppendFormat ("currency={0}&", currency);
            if (!String.IsNullOrEmpty (description)) {
                str.AppendFormat ("description={0}&", HttpUtility.UrlEncode (description));
            }

            if (card != null) {
                card.UrlEncode (str);
            } else {
                // customer is non-empty
                str.AppendFormat ("customer={0}&", HttpUtility.UrlEncode (customer));
            }
            str.Length--;
            string ep = String.Format ("{0}/charges", api_endpoint);
            string json = DoRequest (ep, "POST", str.ToString ());
            return JsonConvert.DeserializeObject<StripeCharge> (json);
        }