Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2. $invoiceData = array();
  3.  
  4. /*
  5. c_users_invoices_created = date
  6. storitev = name of invoce item - for example: "USB dongle":)
  7. s_prices_price = price without tax
  8. c_users_invoices_amount = full amount (with tax)
  9.  
  10. user_data => array (
  11. c_users_name => name
  12. c_users_lastname => lastname
  13. c_users_email => email
  14. c_users_invoices_street => street
  15. c_users_fullphone => phone
  16.  
  17. c_users_invoices_post => array
  18. 0 => city
  19. 1 => zip
  20.  
  21. c_users_invoices_company => 0/1 (is company)
  22. c_users_invoices_company_name => company name
  23. c_users_invoices_company_street => company street
  24. c_countries_foreignname => full country name
  25. );
  26. */
  27. require_once 'ZohoInvoiceV3.php';
  28. $zohoInvoice = new ZohoInvoiceV3($invoiceData);
  29.  
  30. try {
  31. // RM: Get or create contact
  32. $contactId = $zohoInvoice->getContactIdOrCreateContact();
  33.  
  34. // RM: Create invoice
  35. $invoiceId = $zohoInvoice->createInvoice($contactId);
  36.  
  37. // RM: Mark an invoice as sent
  38. $zohoInvoice->markInvoiceAsSent($invoiceId);
  39.  
  40. // RM: Pay invoice
  41. $zohoInvoice->payInvoice($invoiceId, $contactId);
  42.  
  43. // RM: Get HTML of invoice
  44. $invoiceLink = $zohoInvoice->getInvoice($invoiceId);
  45.  
  46. $response = "<a target='_blank' href='{$invoiceLink}'>Click here to view invoice</a>";
  47. } catch (Exception $e) {
  48. $response = 'There was an error while generating invoice: ' . $e->getMessage();
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement