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']
)
)
);
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
1 Posted by nstrum on 07 Nov, 2012 09:06 PM
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(
);
Support Staff 2 Posted by Marc Guyer on 07 Nov, 2012 09:14 PM
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 ofcustomers/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 Posted by nstrum on 07 Nov, 2012 09:28 PM
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
Support Staff 4 Posted by Marc Guyer on 07 Nov, 2012 09:54 PM
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 withcustomers/import
which is why you're getting the error. As such, thecustomers/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 Posted by nstrum on 07 Nov, 2012 10:35 PM
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 Posted by nstrum on 07 Nov, 2012 10:36 PM
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.
Support Staff 7 Posted by Marc Guyer on 07 Nov, 2012 10:44 PM
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 Posted by nstrum on 07 Nov, 2012 10:52 PM
hmm, I tried that. No luck I get a server error.
Support Staff 9 Posted by Marc Guyer on 07 Nov, 2012 11:07 PM
What error would that be?
10 Posted by nstrum on 07 Nov, 2012 11:10 PM
Just a 500 internal server error.
Support Staff 11 Posted by Marc Guyer on 07 Nov, 2012 11:22 PM
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 Posted by nstrum on 07 Nov, 2012 11:37 PM
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 Posted by nstrum on 07 Nov, 2012 11:41 PM
wait... I got it. I used your example import code and it worked. Thanks!
Marc Guyer closed this discussion on 08 Nov, 2012 03:18 PM.