Odd error on Post Subscription updates

's Avatar

simon

18 Sep, 2011 05:02 PM

Hi,

I'm using the PHP API wrapper and when I try to update a subscription I get back this error

<?xml version="1.0" encoding="UTF-8"?> Invalid request for subscription edit -- need post

I've checked the Client.php code & it is going into the POST branch. What else would be causing this error?

  1. Support Staff 1 Posted by Marc Guyer on 18 Sep, 2011 05:57 PM

    Marc Guyer's Avatar

    The POST probably isn't getting through. I've enabled some extra logging on your account so we can help you troubleshoot. Go ahead and generate that error again, note the time and we'll take a look.

  2. 2 Posted by Simon Cast on 18 Sep, 2011 06:04 PM

    Simon Cast's Avatar

    I just ran it again and produce the same error at 1800

  3. Support Staff 3 Posted by Marc Guyer on 18 Sep, 2011 09:22 PM

    Marc Guyer's Avatar

    Hi Simon -- We've confirmed in our log that we're not receiving your POST params. I suggest logging your request within your app to see what's going on.

  4. 4 Posted by Simon Cast on 20 Sep, 2011 05:27 PM

    Simon Cast's Avatar

    Hi,

    I just tried again (1826 BST) and got the same POST requirement error. Could you see if it got through?

    Regards,

    Simon

  5. Support Staff 5 Posted by Marc Guyer on 20 Sep, 2011 05:40 PM

    Marc Guyer's Avatar

    Confirmed that no POST body is being received. Also confirmed that the request is actually being sent as GET which could simply be because there are no POST vars in the request.

  6. 6 Posted by Simon Cast on 21 Sep, 2011 08:37 AM

    Simon Cast's Avatar

    That is very odd. I'm using the open source PHP wrapper with the call constructed as specified. I also put some debugs into the Client.php to see if it was going into the POST branch and it was.

    Is there a particular array structure that is necessary when passing in the POST variables?

  7. Support Staff 7 Posted by Marc Guyer on 21 Sep, 2011 11:53 AM

    Marc Guyer's Avatar

    If you past your code here, maybe I can help.

    >

  8. 8 Posted by Simon Cast on 21 Sep, 2011 04:56 PM

    Simon Cast's Avatar

    Hi Marc,

    Thanks. Here are the relevant lines of code.

    //POST parameters
    $data = array('planCode' => sfConfig::get('app_cheddargetter_enterprise'),'method'=>'paypal');

    //Instantiate the CheddarGetter_Client
    $client = new CheddarGetter_Client(sfConfig::get('app_cheddargetter_host'),
                                               sfConfig::get('app_cheddargetter_username'),
                                               sfConfig::get('app_cheddargetter_password'),
                                               sfConfig::get('app_cheddargetter_application'));

    //Edit the subscription
    $response = $client->editSubscription($user_id,NULL,$data);
          
    Regards,

    Simon

  9. Support Staff 9 Posted by Marc Guyer on 23 Sep, 2011 01:43 PM

    Marc Guyer's Avatar

    Hmm... Well, first of all, that would be a in invalid request anyway even if the POST was getting through.

    http://support.cheddargetter.com/kb/api-8/using-paypal-with-the-api...

    The method, returnUrl, cancelUrl are all required if you want to update the payment method.

    However, this does not explain why the post is not making it to the API. I suggest a bit of troubleshooting code. If you're using the Zend_Http backend, then you can do this:

    .
    .
    .
    //Edit the subscription 
    $response = $client->editSubscription($user_id,NULL,$data); 
    
    echo $client->getHttpClient()->getLastRequest() . "\n\n";
    echo $client->getHttpClient()->getLastResponse() . "\n\n";
    die();
    

    If you're using cUrl, you'll have to manually add the CURLOPT_VERBOSE option to CheddarGetter_Client around line 725. Then, run it and check STDERR.

  10. 10 Posted by Simon Cast on 24 Sep, 2011 12:05 PM

    Simon Cast's Avatar

    I put the code in and it didn't produce anything of value.

    The error was thrown before the echo statements were executed.

    When I check the Errors report on the dashboard the POST error is shown.

  11. Support Staff 11 Posted by Marc Guyer on 29 Sep, 2011 10:00 PM

    Marc Guyer's Avatar

    Oops. This line throws the exception:

    //Edit the subscription 
    $response = $client->editSubscription($user_id,NULL,$data);
    

    So you need to catch it in order to continue processing:

    try {
        //Edit the subscription 
        $response = $client->editSubscription($user_id,NULL,$data); 
    } catch (Exception $e) {
        echo $e . "\n\n";
        echo $client->getHttpClient()->getLastRequest() . "\n\n";
        echo $client->getHttpClient()->getLastResponse() . "\n\n";
        die();
    }
    

    Again, the above will only work if you're using the Zend_Http_Client. If you're using curl, you'll need to troubleshoot it a different way.

  12. Dean closed this discussion on 16 Jan, 2013 09:43 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM