Question

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

Actual Scenario: I am working on a site (ASP.Net using C#) where the system will have 3 different subscription plans i.e. monthly, quarterly and yearly. All the subscription plans have their own cost and pricing. Now, if the system/admin wants to give any discounts to any subscribed user (regardless of subscription plan) on their on-going subscription based on some business logic (for example, for some user it may be $4 and for other it may be $25). How can I achieve this goal. I tried PayPal and Recurly, but stuck in-between.

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

I have to create a coupon and redeem the same using Recurly dynamically in C#. But, as per the code mentioned in "https://docs.recurly.com/api/v1/subscription-plans", we have to use Recurly API v2, but we don't have the code to create and redeem the coupon. So, please help me on how can I create coupons and redeem the same.

When we are using below code in mentioned URL "Recurly PUT request working but returning server error", it causes error while getting response.

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();

}

Looking for kind response and help...

Était-ce utile?

La solution

We (recurly.com) just made available a release candidate of an all new API client for C# compatible with Recurly APIv2 that we highly recommend using. The client API is stable and this release will shortly become the final release pending new show-stopping bugs.

Here's how to get started using it.

Be sure set up your configuration.

Here's how to create a coupon.

Here's how to redeem coupons.

More examples are available here.

If you have further questions please don't hesitate to ask our support team! support@recurly.com.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top