Odd error on Post Subscription updates

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. 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. I just ran it again and produce the same error at 1800

  3. 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. Hi,

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

    Regards,

    Simon

  5. 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. 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. If you past your code here, maybe I can help.

    >

  8. 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. 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. 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. 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