Create an invoice in php with API
Hello,
I try to create an invoice in php from the API with this code :
- $jsonData = '{
- "customer_id": "467818000000193001",
- "reference_number": "",
- "date": "2016-05-18",
- "payment_terms": 15,
- "payment_terms_label": "Net 15",
- "due_date": "2016-05-18",
- "discount": 0.00,
- "is_discount_before_tax": true,
- "discount_type": "item_level",
- "is_inclusive_tax": "false",
- "exchange_rate": 1.00,
- "recurring_invoice_id": "",
- "invoiced_estimate_id": "",
- "salesperson_name": "",
- "line_items": [
- {
- "item_id": "467818000000031001",
- "project_id": "",
- "expense_id": "",
- "name": "Hard Drive",
- "description": "500GB, USB 2.0 interface 1400 rpm, protective hard case.",
- "item_order": 1,
- "rate": 120.00,
- "unit": "",
- "quantity": 1.00,
- "discount": 0.00,
- "tax_id": ""
- }
- ],
- "payment_options": {
- "payment_gateways": [
- {
- "gateway_name": "paypal",
- "additional_field1": "standard"
- },
- {
- "gateway_name": "authorize_net",
- "additional_field1": ""
- },
- {
- "gateway_name": "stripe",
- "additional_field1": ""
- }
- ]
- },
- "allow_partial_payments": true,
- "custom_body": "",
- "custom_subject": "",
- "notes": "Thanks for your business.",
- "terms": "Terms and conditions apply",
- "shipping_charge": 0.00,
- "adjustment": 0.00,
- "adjustment_description": "",
- "reason": ""
- }';
- //Initialize connection
- $ch = curl_init('https://invoice.zoho.com/api/v3/invoices?authtoken=[MYAUTHTOKEN]&organization_id=[MYORGANISATION]&JSONString='.$jsonData);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//Set to return data to string ($response)
- curl_setopt($ch, CURLOPT_POST, TRUE);//Regular post
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json") );
- curl_setopt($ch, CURLOPT_POSTFIELDS,$jsonData);
- //Execute cUrl session
- $response = curl_exec($ch);
- echo $response;
I haven't any error but my invoice is not created :(
Anyone can help me ?
Thanks in advance