如何在C#中使用条带网关以及如何在付款成功或待处理后获得响应? [英] How to inplement stripe gateway in C# and how to get response back after payment successfull or pending ?

查看:61
本文介绍了如何在C#中使用条带网关以及如何在付款成功或待处理后获得响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How to inplement Stripe Gateway in c# and how to get response back after payment successfull or pending ?





我尝试过:





What I have tried:

if (Request.Form["stripeToken"] != null)
            {
                try
                {
                    var customers = new StripeCustomerService();
                    var customer = customers.Create(new StripeCustomerCreateOptions
                    {
                        Email = Request.Form["stripeEmail"],
                        SourceToken = Request.Form["stripeToken"]
                    });

                    var charge = new StripeChargeCreateOptions()
                    {
                        Amount =100,
                        Description = "Sample Charge",
                        Currency = "usd",
                        CustomerId = customer.Id
                    };

                    var chargeService = new StripeChargeService();
                    StripeCharge StripeCharge = chargeService.Create(charge);

                    //check msg after payment
                    lbl_status.Text = StripeCharge.Outcome.SellerMessage + "<br>" + Convert.ToInt32(StripeCharge.Amount) + "<br>" + Convert.ToInt32(StripeCharge.AmountRefunded) + "<br>" + StripeCharge.Application + "<br>" + StripeCharge.Destination + "<br>" + StripeCharge.Status + "<br>" + StripeCharge.StripeResponse;
                }
                catch (StripeException ex)
                {
                    switch (ex.StripeError.ErrorType)
                    {
                        case "card_error":
                            Console.WriteLine("   Code: " + ex.StripeError.Code);
                            Console.WriteLine("Message: " + ex.StripeError.Message);
                            break;
                        case "api_connection_error":
                            break;
                        case "api_error":
                            break;
                        case "authentication_error":
                            break;
                        case "invalid_request_error":
                            break;
                        case "rate_limit_error":
                            break;
                        case "validation_error":
                            break;
                        default:
                            // Unknown Error Type
                            break;
                    }

推荐答案

官方文档: Stripe API参考 [ ^ ]



或者您可以查看他们的.Net源代码: GitHub - stripe / stripe-dotnet:Stripe。 net是同步/异步.NET 4.5+客户端,以及stripe.com的可移植类库。 [ ^ ]
Official Documentation:Stripe API Reference[^]

Or you can look at their .Net source code: GitHub - stripe/stripe-dotnet: Stripe.net is a sync/async .NET 4.5+ client, and a portable class library for stripe.com.[^]


这篇关于如何在C#中使用条带网关以及如何在付款成功或待处理后获得响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆