c# - 如何以编程方式在 Recurly 中创建和兑换优惠券?

标签 c# asp.net .net paypal recurly

++++++++++++++

实际情况:我在一个站点(使用 C# 的 ASP.Net)上工作,系统将有 3 种不同的订阅计划,即每月、每季度和每年。所有订阅计划都有自己的成本和定价。现在,如果系统/管理员想要根据某些业务逻辑(例如,对于某些用户可能是 4 美元,而对于其他用户可能是25 美元)。我怎样才能实现这个目标。我尝试了 PayPal 和 Recurly,但介于两者之间。

++++++++++++++

我必须在 C# 中使用 Recurly 动态创建优惠券并兑换优惠券。但是,根据“https://docs.recurly.com/api/v1/subscription-plans”中提到的代码,我们必须使用 Recurly API v2,但我们没有创建和兑换优惠券的代码。所以,请帮助我如何创建和兑换优惠券。

当我们在提到的 URL“Recurly PUT request working but returning server error”中使用以下代码时,在获取响应时会导致错误。

uri = "https://" + subdomain + ".recurly.com/v2/subscriptions/" + uuid + "/reactivate";

try
{
    string xml = "<subscription><timeframe>now</timeframe></subscription>"; //also tried with blank string.
    byte[] arr = System.Text.Encoding.UTF8.GetBytes(xml);
    HttpWebRequest renewRequest = (HttpWebRequest)WebRequest.Create(uri);
    renewRequest.Headers.Add("Authorization", "Basic " + encodeB64);
    renewRequest.Method = "PUT";
    renewRequest.ContentType = "text/XML";
    renewRequest.ContentLength = arr.Length;

    Stream datastream = renewRequest.GetRequestStream();
    datastream.Write(arr, 0, arr.Length);
    datastream.Close();

    HttpWebResponse renewResponse = (HttpWebResponse)renewRequest.GetResponse();

}

寻求善意的回应和帮助...

最佳答案

我们 ( recurly.com ) 刚刚提供了一个 release candidate of an all new API client for C#Recurly APIv2 兼容我们强烈推荐使用。客户端 API 是稳定的,此版本将很快成为最终版本,等待新的显示停止错误。

以下是如何get started using it .

确定set up your configuration .

以下是如何create a coupon .

以下是如何redeem coupons .

更多例子是available here .

如果您还有其他问题,请随时咨询我们的支持团队! support@recurly.com。

关于c# - 如何以编程方式在 Recurly 中创建和兑换优惠券?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23109325/

相关文章:

c# - 这个 C# 按位或运算的结果是什么?

C# 编程 : Maintaining a List that Associates an ID with Information Quickly

c# - 在c#中获取Powershell脚本的错误并用条件语句输出它?

c# - 对 ServiceStack 的 PUT/POST 请求挂起

.net - 为什么我不应该将我的服务设为单例 (ioc)?

c# - NamedPipeClientStream 在应用程序服务中不起作用

c# - 多重性与引用约束错误冲突

c# - 页面渲染和 http 处理程序

javascript - Page.ResolveUrl 在 JavaScript 中不起作用

c# - 我应该为其创建一个控制台应用程序还是一个公共(public)库?