How to create an invoice in invoices.zoho?
I have some code to create an invoice in invoices.zoho:
- $invoice = array(
- 'customer_id' => 918439000000063105,
- 'contact_persons' => array('918439000000063085'),
- 'invoice_number' => 'TEST-00001',
- 'reference_number' => '',
- 'template_id' => 918439000000017001,
- 'date' => '2017-09-28',
- 'payment_terms' => 0,
- 'payment_terms_label' => 'Pagadero a la recepcion',
- 'due_date' => '2015-10-28',
- 'discount' => 0,
- 'is_discount_before_tax' => true,
- 'discount_type' => '',
- 'is_inclusive_tax' => false,
- 'exchange_rate' => 0.103627,
- 'recurring_invoice_id' => '',
- 'invoiced_estimate_id' => '',
- 'salesperson_name' => '',
- 'custom_fields' => array(),
- 'line_items' => array(
- array(
- 'item_id' => 918439000000063265,
- 'project_id' => '',
- 'expense_id' => '',
- 'salesorder_item_id' => '',
- 'name' => 'Khách sạn Hạ Long-Luxury',
- 'description' => '',
- 'product_type' => 'goods',
- 'item_order' => 1,
- 'rate' => 120,
- 'unit' => '',
- 'quantity' => 2.0,
- 'discount' => 0,
- 'tax_id' => ''
- )
- ),
- 'payment_options' => array(),
- 'allow_partial_payments' => false,
- 'custom_body' => '',
- 'custom_subject' => '',
- 'notes' => 'T.C. $ 9,65',
- 'terms' => '',
- 'shipping_charge' => 0.0,
- 'adjustment' => 0.0,
- 'adjustment_description' => 'Ajuste'
- );
- $url = 'https://invoice.zoho.com/api/v3/invoices/';
- $data = array(
- 'authtoken' => '{AUTHORTOCKEN}',
- 'JSONString' => $invoice,
- "organization_id" => '{organization_id}',
- "send" => false
- );
- $ch = curl_init($url);
- curl_setopt_array($ch, array(
- CURLOPT_POST => 1,
- CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_SSL_VERIFYHOST => false,
- CURLOPT_POSTFIELDS => http_build_query($data),
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_HTTPHEADER => array("Content-Type:application/x-www-form-urlencoded")
- ));
- $response = curl_exec($ch);
- $response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- var_dump($response);
Why I alway get message error 400 or '
{"code":4,"message":"Invalid value passed for JSONString"}
'?
Access your files securely from anywhere
Zoho Developer Community
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Qntrl Resources
Zoho Creator Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.