Create an invoice in php with API

Create an invoice in php with API

Hello,

I try to create an invoice in php from the API with this code :

  1. $jsonData = '{
  2. "customer_id": "467818000000193001",
  3. "reference_number": "",
  4. "date": "2016-05-18",
  5. "payment_terms": 15,
  6. "payment_terms_label": "Net 15",
  7. "due_date": "2016-05-18",
  8. "discount": 0.00,
  9. "is_discount_before_tax": true,
  10. "discount_type": "item_level",
  11. "is_inclusive_tax": "false",
  12. "exchange_rate": 1.00,
  13. "recurring_invoice_id": "",
  14. "invoiced_estimate_id": "",
  15. "salesperson_name": "",
  16. "line_items": [
  17. {
  18. "item_id": "467818000000031001",
  19. "project_id": "",
  20. "expense_id": "",
  21. "name": "Hard Drive",
  22. "description": "500GB, USB 2.0 interface 1400 rpm, protective hard case.",
  23. "item_order": 1,
  24. "rate": 120.00,
  25. "unit": "",
  26. "quantity": 1.00,
  27. "discount": 0.00,
  28. "tax_id": ""
  29. }
  30. ],
  31. "payment_options": {
  32. "payment_gateways": [
  33. {
  34. "gateway_name": "paypal",
  35. "additional_field1": "standard"
  36. },
  37. {
  38. "gateway_name": "authorize_net",
  39. "additional_field1": ""
  40. },
  41. {
  42. "gateway_name": "stripe",
  43. "additional_field1": ""
  44. }
  45. ]
  46. },
  47. "allow_partial_payments": true,
  48. "custom_body": "",
  49. "custom_subject": "",
  50. "notes": "Thanks for your business.",
  51. "terms": "Terms and conditions apply",
  52. "shipping_charge": 0.00,
  53. "adjustment": 0.00,
  54. "adjustment_description": "",
  55. "reason": ""
  56. }';

  57. //Initialize connection
  58. $ch = curl_init('https://invoice.zoho.com/api/v3/invoices?authtoken=[MYAUTHTOKEN]&organization_id=[MYORGANISATION]&JSONString='.$jsonData);
  59. curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
  60. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification
  61. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  62. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//Set to return data to string ($response)
  63. curl_setopt($ch, CURLOPT_POST, TRUE);//Regular post
  64. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json") );
  65. curl_setopt($ch, CURLOPT_POSTFIELDS,$jsonData);

  66. //Execute cUrl session
  67. $response = curl_exec($ch);

  68. echo $response;

I haven't any error but my invoice is not created :(

Anyone can help me ?

Thanks in advance