Api Import issue

nstrum's Avatar

nstrum

07 Nov, 2012 09:02 PM

I am using your exact PHP script to import customers however I am getting an error "ERROR: (400) POST data must be a nested list of customer data"

this is what I am using on my php page:

$data = array(
  '0' => array(
    'code'              => $_POST['client_email'],
    'firstName'         => $_POST['client_first_name'],
    'lastName'          => $_POST['client_last_name'],
    'email'             => $_POST['client_email'],
    'gatewayToken'      => $_POST['customer_vault_token'],
    'company'           => $_POST['client_company_name'],
    'subscription'  => array(
        'planCode'          => $_POST['plan_code'],
        'gatewayToken'      => $_POST['vault_token'],
        'ccType'            => $_POST['card_type'],
        'ccLastFour'        => $_POST['last_four'],
        'ccExpiration'      => $_POST['expiration_month'] . '/' . $_POST['expiration_year'],
        'ccFirstName'       => $_POST['billing_first_name'],
        'ccLastName'        => $_POST['billing_last_name'],
        'ccZip'             => $_POST['billing_zip'],
        'initialBillDate'   => $_POST['next_billing_at_year'] . '/01/' . $_POST['next_billing_at_month'] 
    )
  )  

);
  1. 1 Posted by nstrum on 07 Nov, 2012 09:06 PM

    nstrum's Avatar

    in fact, I just copied your exact code and tried and am still getting the error that I must provide the data in a nested list:

    $data = array(

    'cust_0' => array(
        'code' => 'cust_0',
        'gatewayToken' => 'imported_token',
        'firstName' => 'First',
        'lastName' => 'Imported',
        'email' => '[email blocked]',
        'subscription' => array(
            'planCode' => 'plan_code',
            'initialBillDate' => date('c', strtotime('+ 1 week')),
            'gatewayToken' => 'imported_token',
            'ccLastFour' => '9999',
            'ccExpiration' => '02/2002',
            'ccFirstName' => 'First',
            'ccLastName' => 'Imported'
        )
    ),
    'cust_1' => array(
        'code' => 'cust_1',
        'gatewayToken' => 'imported_token',
        'firstName' => 'Second',
        'lastName' => 'Imported',
        'email' => '[email blocked]',
        'subscription' => array(
            'planCode' => 'plan_code',
            'initialBillDate' => date('c', strtotime('+ 1 week')),
            'gatewayToken' => 'imported_token',
            'ccLastFour' => '9999',
            'ccExpiration' => '02/2002',
            'ccFirstName' => 'Second',
            'ccLastName' => 'Imported'
        )
    )
    

    );

  2. Support Staff 2 Posted by Marc Guyer on 07 Nov, 2012 09:14 PM

    Marc Guyer's Avatar

    Hi Nathan -- I suspect that you're using CheddarGetter_Client::request() for this import because that method is sneaky and adds the remoteAddress param to the POST arguments if it's not set. I suppose the assumption is that every API request could contain that param. However, in the case of customers/import that param causes one of the array elements to be a scalar (remoteAddress). As soon as the import method finds an element that's not customer data, it chokes.

    Would you consider contributing a fix to the CheddarGetter_Client for this case?

  3. 3 Posted by nstrum on 07 Nov, 2012 09:28 PM

    nstrum's Avatar

    Hi Marc,

    I am not sure if I understand. How would I fix your software? I am looking for help from you? I apologize if I am misunderstanding your message.

    Nathan

  4. Support Staff 4 Posted by Marc Guyer on 07 Nov, 2012 09:54 PM

    Marc Guyer's Avatar

    The wrapper you're using is open source software. As such it can be considered to be owned by the community of which you are a member. You're using the CheddarGetter_Client::request() method, correct? This is an assumption I've made. Please correct me if I'm wrong. It would help if you provide more context of your code rather than just the $data array.

    The request() method as-is adds the remoteAddress param which is incompatible with customers/import which is why you're getting the error. As such, the customers/import method is not currently supported in that wrapper. You're free to make the changes needed to support that method. We'd be happy to do it but you'd have to wait until we got around to it. We're happy to help if you have questions.

    As a workaround, you might consider extending the CheddarGetter_Client object and implement your own request() method.

  5. 5 Posted by nstrum on 07 Nov, 2012 10:35 PM

    nstrum's Avatar

    Ok, I understand now. You are 100% correct. I attempted to modify the public wrapper. As you may have been able to tell, I am not a programmer and only can do so much.

  6. 6 Posted by nstrum on 07 Nov, 2012 10:36 PM

    nstrum's Avatar

    What would you charge to create the method I need? I have tested and looked at 20 - 30 solutions and cannot find exactly what I need other than what your system provides.

  7. Support Staff 7 Posted by Marc Guyer on 07 Nov, 2012 10:44 PM

    Marc Guyer's Avatar

    We wouldn't charge anything but it will take some time before we can get to it. If you want a hacky temporary workaround, just comment out line 740-749:

    https://github.com/marcguyer/cheddargetter-client-php/blob/master/C...

    That should do it.

  8. 8 Posted by nstrum on 07 Nov, 2012 10:52 PM

    nstrum's Avatar

    hmm, I tried that. No luck I get a server error.

  9. Support Staff 9 Posted by Marc Guyer on 07 Nov, 2012 11:07 PM

    Marc Guyer's Avatar

    What error would that be?

  10. 10 Posted by nstrum on 07 Nov, 2012 11:10 PM

    nstrum's Avatar

    Just a 500 internal server error.

  11. Support Staff 11 Posted by Marc Guyer on 07 Nov, 2012 11:22 PM

    Marc Guyer's Avatar

    Not seeing that here. Maybe an error in your app? In fact, we haven't received a customers/import request since [07/Nov/2012:20:59:36 +0000], more than an hour ago.

  12. 12 Posted by nstrum on 07 Nov, 2012 11:37 PM

    nstrum's Avatar

    you are right, I had something missing. however now I have it all
    setup properly and have commented out those lines and I getting the
    :ERROR: (400) POST data must be a nested list of customer data" again.
    Do you see my request?

  13. 13 Posted by nstrum on 07 Nov, 2012 11:41 PM

    nstrum's Avatar

    wait... I got it. I used your example import code and it worked. Thanks!

  14. Marc Guyer closed this discussion on 08 Nov, 2012 03:18 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