【问题标题】:Confirming how to use Stripe.net Customer on a plan确认如何在计划中使用 Stripe.net 客户
【发布时间】:2013-09-18 14:52:35
【问题描述】:

我是 Stripe 新手,我决定使用 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 页面上还有一个用于创建费用的部分,我不确定是否需要对此做任何事情。

【问题讨论】:

标签: c# asp.net asp.net-mvc-4 stripe-payments


【解决方案1】:

是的,就是这样。根据过去的经验,您是否期待更痛苦的事情? ;)

Stripe API 的设计非常易于使用,大多数可用的库(包括 Stripe.net)都在努力维护这一点。

您无需处理任何费用。如果您需要为某些一次性物品(例如帽子)向客户收费,这就是收费的目的。计划会照顾好自己。

【讨论】:

【解决方案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);
        }

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-11-25
  • 2017-02-04
  • 2016-09-04
  • 1970-01-01
  • 1970-01-01
  • 2018-08-05
  • 1970-01-01
相关资源
最近更新 更多