{"id":167470,"date":"2021-05-18T14:23:43","date_gmt":"2021-05-18T07:23:43","guid":{"rendered":"https:\/\/www.icez.net\/blog\/?p=167470"},"modified":"2021-05-18T14:31:53","modified_gmt":"2021-05-18T07:31:53","slug":"whmcs-line-notify-invoice","status":"publish","type":"post","link":"https:\/\/www.icez.net\/blog\/167470\/whmcs-line-notify-invoice","title":{"rendered":"0251 | whmcs line notify \u0e41\u0e08\u0e49\u0e07\u0e40\u0e15\u0e37\u0e2d\u0e19 invoice"},"content":{"rendered":"<p>\u0e40\u0e2d\u0e32\u0e44\u0e1b\u0e43\u0e2a\u0e48\u0e43\u0e19 folder includes\/hooks\/linenotify.php (\u0e2d\u0e22\u0e48\u0e32\u0e25\u0e37\u0e21\u0e40\u0e1b\u0e34\u0e14 tag php)<\/p>\n<pre lang=\"php\">\n<?php\nadd_hook('EmailPreSend', 1, function($vars) {\n\n    if (empty($vars['mergefields']) || empty($vars['mergefields']['client_custom_field_linenotifytoken'])) return;\n    if ($vars['messagename'] == 'Invoice Created') {\n        $message = \"THZHost.com: \u0e21\u0e35\u0e43\u0e1a\u0e41\u0e08\u0e49\u0e07\u0e0a\u0e33\u0e23\u0e30\u0e40\u0e07\u0e34\u0e19\u0e43\u0e2b\u0e21\u0e48\\n\\n\";\n        foreach ($vars['mergefields']['invoice_items'] as $item) {\n            $message .= strip_tags($item['description']).\" (\".$item['amount']->__toString().\")\\n\";\n        }\n        $message .= \"\\n\u0e22\u0e2d\u0e14\u0e04\u0e49\u0e32\u0e07\u0e0a\u0e33\u0e23\u0e30: \".$vars['mergefields']['invoice_balance']->__toString().\"\\n\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e0a\u0e33\u0e23\u0e30: \".$vars['mergefields']['invoice_date_due'].\"\\nhttps:\/\/www.thzhost.com\/viewinvoice.php?id=\".$vars['mergefields']['invoice_id'];\n        line_notify_message($vars['mergefields']['client_custom_field_linenotifytoken'], $message);\n\n    }\n    elseif ($vars['messagename'] == 'Invoice Payment Reminder')\n    {\n        $message = \"THZHost.com: \u0e22\u0e2d\u0e14\u0e0a\u0e33\u0e23\u0e30\u0e04\u0e07\u0e04\u0e49\u0e32\u0e07\u0e43\u0e01\u0e25\u0e49\u0e16\u0e36\u0e07\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e0a\u0e33\u0e23\u0e30\\n\\n\";\n        foreach ($vars['mergefields']['invoice_items'] as $item) {\n            $message .= strip_tags($item['description']).\" (\".$item['amount']->__toString().\")\\n\";\n        }\n        $message .= \"\\n\u0e22\u0e2d\u0e14\u0e04\u0e49\u0e32\u0e07\u0e0a\u0e33\u0e23\u0e30: \".$vars['mergefields']['invoice_balance']->__toString().\"\\n\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e0a\u0e33\u0e23\u0e30: \".$vars['mergefields']['invoice_date_due'].\"\\nhttps:\/\/www.thzhost.com\/viewinvoice.php?id=\".$vars['mergefields']['invoice_id'];\n        line_notify_message($vars['mergefields']['client_custom_field_linenotifytoken'], $message);\n    }\n    elseif ($vars['messagename'] == 'Invoice Payment Confirmation')\n    {\n        $message = \"THZHost.com: \u0e22\u0e37\u0e19\u0e22\u0e31\u0e19\u0e01\u0e32\u0e23\u0e0a\u0e33\u0e23\u0e30\u0e40\u0e07\u0e34\u0e19\\n\\n\";\n        foreach ($vars['mergefields']['invoice_items'] as $item) {\n            $message .= strip_tags($item['description']).\" (\".$item['amount']->__toString().\")\\n\";\n        }\n        $message .= \"\\n\u0e22\u0e2d\u0e14\u0e23\u0e27\u0e21: \".$vars['mergefields']['invoice_total']->__toString().\"\\n\u0e02\u0e2d\u0e1a\u0e04\u0e38\u0e13\u0e17\u0e35\u0e48\u0e0a\u0e33\u0e23\u0e30\u0e04\u0e48\u0e32\u0e1a\u0e23\u0e34\u0e01\u0e32\u0e23\";\n        line_notify_message($vars['mergefields']['client_custom_field_linenotifytoken'], $message);\n    }\n});\n\nfunction line_notify_message($line_token, $message)\n{\n    file_put_contents('\/tmp\/linenotify', print_r($message, true));\n    $line_api = 'https:\/\/notify-api.line.me\/api\/notify';\n\n    $queryData = array('message' => $message);\n    $queryData = http_build_query($queryData,'','&');\n    $headerOptions = array(\n        'http'=>array(\n            'method'=>'POST',\n            'timeout' => 5,\n            'header'=> \"Content-Type: application\/x-www-form-urlencoded\\r\\n\"\n                .\"Authorization: Bearer \".$line_token.\"\\r\\n\"\n                .\"Content-Length: \".strlen($queryData).\"\\r\\n\",\n            'content' => $queryData\n        )\n    );\n    $context = stream_context_create($headerOptions);\n    $result = file_get_contents($line_api, FALSE, $context);\n    $res = json_decode($result);\n    return $res;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0e40\u0e2d\u0e32\u0e44\u0e1b\u0e43\u0e2a\u0e48\u0e43\u0e19 folder includes\/hooks\/linenotify.php (\u0e2d\u0e22\u0e48\u0e32\u0e25\u0e37\u0e21\u0e40\u0e1b\u0e34\u0e14 tag php)<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8261],"class_list":["post-167470","post","type-post","status-publish","format-standard","hentry","category-misc","tag-whmcs"],"_links":{"self":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/167470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/comments?post=167470"}],"version-history":[{"count":7,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/167470\/revisions"}],"predecessor-version":[{"id":167478,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/posts\/167470\/revisions\/167478"}],"wp:attachment":[{"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/media?parent=167470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/categories?post=167470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icez.net\/blog\/wp-json\/wp\/v2\/tags?post=167470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}