Api Import issue

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. 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. 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. 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. 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. 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. 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. 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. hmm, I tried that. No luck I get a server error.

  9. What error would that be?

  10. Just a 500 internal server error.

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