Looking for example code

David's Avatar

David

10 Apr, 2011 07:00 PM

Can someone share the typical php code to handle and read the xml post transaction data sent by CG cancellation event???

I need some help and am confused.

Thanks

  1. Support Staff 1 Posted by Marc Guyer on 10 Apr, 2011 08:04 PM

    Marc Guyer's Avatar

    Have you seen the official wrapper and quick start guide?

    http://support.cheddargetter.com/faqs/api-8/cheddargetter-client-library-quick-start

  2. 2 Posted by David on 10 Apr, 2011 09:03 PM

    David's Avatar

    Yes... I've read through that several times.

    My confusion is around using something like: $xmlData = file_get_contents("php://input");... but not sure what to follow that up with.

    or something else.

    Do you have an example of the code to read in the post transaction or cancellation data? Since the data is sent to my .php page, I an struggling on how to read it.

  3. Support Staff 3 Posted by Marc Guyer on 11 Apr, 2011 04:23 PM

    Marc Guyer's Avatar

    Hmm.. I'm not sure why you're trying to do that. The wrapper does it for you. There's quite a bit of example code in the quick start guide. Here's something specific to canceling a customer:

    <?php
        $client = new CheddarGetter_Client('https://cheddargetter.com', 'yourusername', 'yourpassword', 'yourproductcode');
        $response = $client->cancelSubscription('thecustomercode');
        print_r($response->getCustomer());
    ?>
    
  4. 4 Posted by David on 13 Apr, 2011 02:00 AM

    David's Avatar

    I am looking for code to read the 'thecustomercode' and the error reason that come back if a users credit card fails to process a transaction... for example, a credit card fails to process x number of months after subscribing.

    I want to store the customer code and reason in my database table and process them... but I can't seem to read the data. I have been using your test button on the "We'll send some POST data here whenever a customer is canceled" test button that sends to my url.

  5. 5 Posted by David on 13 Apr, 2011 03:11 AM

    David's Avatar

    I guess I really don't know how to handle the POST transaction (specifically the cancel).

    I'm sure its simple, but I am confused.

    Sorry... really would appreciate any help you can give me. How do I get the customer code or customer ID of a failed transaction that become cancelled and the reason for the cancel.?

  6. Support Staff 6 Posted by Marc Guyer on 13 Apr, 2011 01:43 PM

    Marc Guyer's Avatar

    David -- Sorry you're having trouble. We'd like to help but we can't provide the type of support you require. You seem to be building a fairly complex system and what you're asking for is more along the lines of a consulting service.

    The post hook sends data to your location just like when an HTML form is submitted to the URL you specify.

  7. 7 Posted by billing on 13 Apr, 2011 02:56 PM

    billing's Avatar

    Marc...

    Since "The post hook sends data to your location just like when an HTML form is submitted to the URL you specify."... Do I have to search through all the customer data to find which one failed?

    Normally on my forms, I know which customer what being used.... when you post hook back to me, I don't.

    I'm not looking for consulting... just trying to understand and how to handle CG's cancellation posts back to my url. Having to search through ALL customer data will be slow.

  8. Support Staff 8 Posted by Marc Guyer on 13 Apr, 2011 07:54 PM

    Marc Guyer's Avatar

    The customer code (which you provide when creating the customer) is intended to be your unique id for the customer in your system. So, when you receive the post hook, you know which customer it is for.

    It sounds like you're pulling all customers. You should never need to do this. If you use the customer code effectively, you'll get what you want.

  9. 9 Posted by David on 13 Apr, 2011 09:36 PM

    David's Avatar

    Mark... thanks

    If a customers credit card fails to successfully process a recurring invoice (aka future invoice)... Can I assume CG will post data back to the url I specified?

    If so, how do I know what customer code failed? Assuming its in your post back data... how do I read it?

    Thanks again

  10. Support Staff 10 Posted by Marc Guyer on 15 Apr, 2011 02:32 PM

    Marc Guyer's Avatar

    Can I assume CG will post data back to the url I specified?

    yes

    If so, how do I know what customer code failed?

    The customer code is in the POST data sent to the URL you specify.

    Assuming its in your post back data... how do I read it?

    Post data is sent to the URL just like if you created an HTML form with an action of the same URL. It will be in the PHP $_POST array.

  11. Dean closed this discussion on 16 Jan, 2013 04:49 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