Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get coupon description - hosted_description #225

Closed
henryoswald opened this issue Nov 16, 2015 · 3 comments
Closed

get coupon description - hosted_description #225

henryoswald opened this issue Nov 16, 2015 · 3 comments

Comments

@henryoswald
Copy link

It would be great if when applying a coupon we can get the description, it looks to be hosted_description in the xml response.

@thbar
Copy link

thbar commented Nov 24, 2015

I asked this to the support (how to get both the description but also the period of application, e.g. number of months) and the reply last week was to issue a coupon request myself (on the server side).

That said the Recurly.js library is already itself issuing a call to check the coupon, so all this information is available somewhere, so why not propagating it to the done callback?

To me the done(price) callback should provide the data, including coupon application success or not (valid_coupon?), period of application, description etc.

@thbar
Copy link

thbar commented Nov 24, 2015

After a number of hours of digging, I actually found a way to get more information, but I think the order of the calls are important and maybe why I missed this initially.

If I use this, then I'll get the detailed coupon information:

recurly.Pricing()
  .plan(@recurly_plan(), { quantity: 1 })
  .currency(@currency())
  .on 'set.coupon', (coupon) =>
    @setCouponDescription(coupon)
  .on 'unset.coupon', () =>
    @clearCouponDescription()
  .coupon @coupon_code()
  .address(address)
  .catch (err) =>
    # snip
  .done (price) =>
    # snip

With this exact order, I will get detailed information on set.coupon.

@chrissrogers
Copy link
Member

Thank you for answering this @thbar -- yes, the pricing promise chain will only resolve with price data -- we chose not to make this polymorphic to make it easier to trust its output.

The set.coupon event is the correct event to listen to on the pricing object in order to read coupon data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants