Ejemplo n.º 1
0
        private async Task <string> ProcessPayment(StripeChargeModel model)
        {
            return(await Task.Run(() =>
            {
                var charge = new Stripe.StripeChargeCreateOptions
                {
                    Amount = (int)(model.Amount),
                    Currency = "usd",
                    Description = "Purchase",
                    Source = new Stripe.StripeSourceOptions
                    {
                        TokenId = model.Token
                    }
                };

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;

                var chargeService = new Stripe.StripeChargeService("sk_test_4lknJTkG0q14upuDDfpZO1Nl006QJSGsZF");
                Stripe.StripeCharge chargeId = null;
                try
                {
                    chargeId = chargeService.Create(charge);
                } catch (Exception e)
                {
                    System.Diagnostics.Debug.Print(e.Message);
                }


                return chargeId.Id;
            }));
        }