if Recurly error, parse body xml rather than using regex match

This commit is contained in:
Shane Kilkelly 2016-12-06 10:39:59 +00:00
parent 58280bf6ee
commit a5d2183441

View file

@ -418,10 +418,15 @@ module.exports = RecurlyWrapper =
url: "subscriptions/#{subscriptionId}/cancel", url: "subscriptions/#{subscriptionId}/cancel",
method: "put" method: "put"
}, (error, response, body) -> }, (error, response, body) ->
if error? and body?.match(/.*A canceled subscription can't transition to canceled.*/) if error?
logger.log {subscriptionId, error, body}, "subscription already cancelled, not really an error, proceeding" RecurlyWrapper._parseXml body, (_err, parsed) ->
error = null if parsed?.error?.description == "A canceled subscription can't transition to canceled"
callback(error) logger.log {subscriptionId, error, body}, "subscription already cancelled, not really an error, proceeding"
callback(null)
else
callback(error)
else
callback(null)
) )
reactivateSubscription: (subscriptionId, callback) -> reactivateSubscription: (subscriptionId, callback) ->