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

Updating subscription with coupon code returns dot mark '.' #284

Closed
mpietraszneurosys opened this issue Nov 16, 2016 · 2 comments · Fixed by #298
Closed

Updating subscription with coupon code returns dot mark '.' #284

mpietraszneurosys opened this issue Nov 16, 2016 · 2 comments · Fixed by #298
Assignees
Labels
bug V2 V2 Client

Comments

@mpietraszneurosys
Copy link

I found problem when I use coupon code. When I create new subscription with coupon everything is fine. When Im updating subscription to another plan with coupon I spot weird error. This code should update my subscription, set new plan code and add coupon when exists. When I enter coupon code I got this error:

Recurly_ValidationError: . in /var/www/vendor/recurly/recurly-client/lib/recurly/response.php on line 30

here is my code:

try {
    $subscription = Recurly_Subscription::get($active_subsciption);
    if($this->coupon) {
        $subscription->coupon_code = $this->coupon;
    }
    $subscription->plan_code = $this->license;
    $subscription->quantity = 1;
    $subscription->updateImmediately();
    return [
        'status' => 200,
        'subscription' => $subscription
    ];
}catch (Recurly_Error $e) {
    return [
        'status' => 400,
        'error' => "Error: ".$e->getMessage()
    ];
}

$e->getMessage() returns . (dot mark)
Im using string on $this->coupon

what do I do wrong ?

@drewish
Copy link

drewish commented Nov 16, 2016

That is pretty odd. I'd stick a var_dump in at https://github.com/recurly/recurly-client-php/blob/master/lib/recurly/client.php#L171 and see what the body of the error response looks like. I wonder if there's just a problem parsing the error message out.

@bhelx bhelx self-assigned this Jan 18, 2017
@bhelx
Copy link
Contributor

bhelx commented Jan 18, 2017

Hey @mpietraszneurosys

I was able to reproduce this. The problem has to do with the format of the coupon error. In my case it looks like this:

<error>
  <symbol>subscription_must_change</symbol>
  <description>You must change the subscription in order to redeem a coupon.</description>
</error>

The problem is that this is a ValidationError but the xml is of the shape of a FieldError. The validation error parser needs to be able to handle both shapes of xml.

I'm working on a fix for this now. I also think this is related to #281 as they are experiencing the same thing when getting what appears to also be a coupon error.

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

Successfully merging a pull request may close this issue.

3 participants