c# - How to create and redeem coupons in Recurly, programmatically? -
++++++++++++++
actual scenario: working on site (asp.net using c#) system have 3 different subscription plans i.e. monthly, quarterly , yearly. subscription plans have own cost , pricing. now, if system/admin wants give discounts subscribed user (regardless of subscription plan) on on-going subscription based on business logic (for example, user may $4 , other may $25). how can achieve goal. tried paypal , recurly, stuck in-between.
++++++++++++++
i have create coupon , redeem same using recurly dynamically in c#. but, per code mentioned in "https://docs.recurly.com/api/v1/subscription-plans", have use recurly api v2, don't have code create , redeem coupon. so, please me on how can create coupons , redeem same.
when using below code in mentioned url "recurly put request working returning server error", causes error while getting response.
uri = "https://" + subdomain + ".recurly.com/v2/subscriptions/" + uuid + "/reactivate"; try { string xml = "<subscription><timeframe>now</timeframe></subscription>"; //also tried 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 kind response , help...
we (recurly.com) made available release candidate of new api client c# compatible recurly apiv2 highly recommend using. client api stable , release shortly become final release pending new show-stopping bugs.
here's how get started using it.
be sure set configuration.
here's how create coupon.
here's how redeem coupons.
more examples available here.
if have further questions please don't hesitate ask our support team! support@recurly.com.
Comments
Post a Comment