确认如何在计划中使用Stripe.net的客户端

9

我是新手,决定使用stripe.net (https://github.com/jaymedavis/stripe.net)。我的目标是让客户参加一个每月收费的计划,并为他们提供取消计划的选项。以下是stripe.net项目提供的代码示例:

StripeConfiguration.SetApiKey("[your api key here]");

var myCustomer = new StripeCustomerCreateOptions();

// set these properties if it makes you happy
myCustomer.Email = "pork@email.com";
myCustomer.Description = "Johnny Tenderloin (pork@email.com)";

// set these properties if using a card
myCustomer.CardNumber = "4242424242424242";
myCustomer.CardExpirationYear = "2012";
myCustomer.CardExpirationMonth = "10";
myCustomer.CardAddressCountry = "US";            

myCustomer.PlanId = *planId*;                         

var customerService = new StripeCustomerService();
StripeCustomer stripeCustomer = customerService.Create(myCustomer);

这是我需要做的全部吗,以使客户每月付费计划生效?并取消该计划...

var customerService = new StripeCustomerService();
StripeSubscription subscription = customerService.CancelSubscription(*customerId*);

这就是我需要做的全部吗?stripe.net页面还有一个创建charge的部分,我不确定是否需要进行任何操作。


Stripe支付集成在Asp.net Web Forms中,提供了100%的工作代码,您还可以下载应用程序。 https://code2night.com/Blog/MyBlog/Implement-Stripe-Payment-Gateway-In-ASPNET - Shubham
2个回答

10

没错,就是这样。你根据过去的经验是否期望更加痛苦呢? ;)

Stripe API旨在非常易于使用,大部分可用库(包括Stripe.net)都在努力保持这一点。

您无需处理任何收费事宜。如果您需要为客户收取某些一次性款项(例如帽子),那么收费就是用来处理这种情况的。计划会自己处理。


Stripe支付在Asp.net Web Forms中的集成,以及其100%有效的代码,您还可以下载应用程序 https://code2night.com/Blog/MyBlog/Implement-Stripe-Payment-Gateway-In-ASPNET - Shubham

2

最新的Stripe API中,StripeCustomerService不再支持CancelSubscription方法。以下是取消客户订阅的一种方法:

        var subscriptionService = new StripeSubscriptionService();
        var subscriptions = subscriptionService.List(account.StripeCustomerId);

        foreach (var subscription in subscriptions)
        {
            if (subscription.CanceledAt == null)
                subscriptionService.Cancel(account.StripeCustomerId, subscription.Id);
        }

Stripe支付集成在Asp.net Web Forms中,提供了100%的工作代码,您还可以下载应用程序。 https://code2night.com/Blog/MyBlog/Implement-Stripe-Payment-Gateway-In-ASPNET - Shubham

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接