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

Subscription Add-Ons causing 422 Header #86

Closed
trip-somers opened this issue May 7, 2014 · 3 comments
Closed

Subscription Add-Ons causing 422 Header #86

trip-somers opened this issue May 7, 2014 · 3 comments
Labels
V2 V2 Client

Comments

@trip-somers
Copy link

The response from a $subscription->create() call is returning an HTTP 422 header and preventing the PHP SDK from reading the XML response.

Here is the code that triggers it:

            $sub_add_ons = array();
            foreach ( $add_on_codes as $add_on_code )
            {
                $sub_add_on = new Recurly_SubscriptionAddOn();
                $sub_add_on->add_on_code            = $add_on_code;
                $sub_add_on->unit_amount_in_cents   = 0;
                $sub_add_ons[] = $sub_add_on;
            }
            if ( !empty($sub_add_ons) ) $subscription->subscription_add_ons = $sub_add_ons;
            $subscription->create();

With the code as is, create() successfully runs the API call -- creating the subscription with correct add ons -- but the SDK throws an ErrorException because the 422 header is presumably "hiding" the XML. Here is the relevant tail of the stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'DOMDocument::lo...', '{{my project dir}}...', 200, Array)
#1 {{my project dir}}/vendor/recurly/recurly-client/lib/recurly/base.php(200): DOMDocument->loadXML('HTTP/1.1 422 Un...', 256)
#2 {{my project dir}}/vendor/recurly/recurly-client/lib/recurly/resource.php(65): Recurly_Base->__parseXmlToUpdateObject('HTTP/1.1 422 Un...')
#3 {{my project dir}}/vendor/recurly/recurly-client/lib/recurly/subscription.php(28): Recurly_Resource->_save('POST', '/subscriptions')
#4 {{my script}} (116): Recurly_Subscription->create()

When I comment out the subscription_add_ons assignment, the script processes correctly but without the add ons (obviously).

This seems like an API response issue since it actually handles my request appropriately. Any idea what's happening here?

@drewish
Copy link

drewish commented May 7, 2014

@theTrip73 can you open up a support ticket for this? please reference this issue and include your site's subdomain so we can look in the logs see what the requests and responses actually look like.

@trip-somers
Copy link
Author

Done.

@drewish
Copy link

drewish commented May 7, 2014

So the issue here seems to be that subscription already exists for the account. I'm leaving this open until I can look and see if we're emitting the error message correctly on the PHP side.

@drewish drewish closed this as completed in 8c4f5c0 May 8, 2014
@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

No branches or pull requests

3 participants