{"id":73,"date":"2020-11-19T20:35:11","date_gmt":"2020-11-19T20:35:11","guid":{"rendered":"https:\/\/theatlass.com\/help\/?post_type=docs&#038;p=73"},"modified":"2022-04-10T14:41:15","modified_gmt":"2022-04-10T14:41:15","slug":"integration-via-api","status":"publish","type":"docs","link":"https:\/\/theatlass.com\/resources\/docs\/integration-via-api\/","title":{"rendered":"Integration via API"},"content":{"rendered":"<div class=\"wp-block-lazyblock-bootstrap-alert lazyblock-bootstrap-alert-Z1EML8Y\"><div class=\"alert alert-info \" role=\"alert\">\n     NOTICE! This should be handled by the developer who set up your website. \n<\/div><\/div>\n\n\n<p>Locate your function that processed the order.<\/p>\n\n\n\n<p>Send a post request to <code>https:\/\/atlass-302217.ew.r.appspot.com\/order\/add <\/code>containing the JSON code below.<\/p>\n\n\n\n<p>Depending on the programming languange, we set up some examples:<\/p>\n\n\n\n<p>Don&#8217;t forget to change the fields with the actual customer data.<\/p>\n\n\n\n<h5>Raw JSON<\/h5>\n\n\n<div class=\"wp-block-lazyblock-script-code-block lazyblock-script-code-block-H42II\"><div class=\"code-block w-100\" >\n<pre class=\"wp-block-code\" id=\"api-raw-json\" >\n  {\n  \"APPKEY\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\", \/\/ Organization APPKEY, *required\n  \"APP_SECRET\": \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \/\/ Organization SECRET, *required\n  \"firstname\": \"John\", \/\/Client firstname\n  \"lastname\": \"Doe\", \/\/Client lastname\n  \"email\": \"John@doe.com\", \/\/Client email, *required\n  \"IP\": \"71.23.54.682\", \/\/Client IP\n  \"orderName\": \"Order number 215645675733\",\n  \"orderPrice\": 349,\n  \"orderID\": 1252653462, \/\/internal ID of the order\n  \"orderItems\": [\n    { \n        \"Name\": \"Produs test 1\" , \n        \"Price\": 299,\n        \"Quantity\":1 \n    }\n    ...\n  ]\n}<\/pre>\n<a data-copy=\"api-raw-json\" class=\"btn-copy-script\"> <i class=\"far fa-copy\"><\/i>  <\/a>\n<\/div>\n<\/div>\n\n\n<h5>For PHP, use this code:<\/h5>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\"><div class=\"wp-block-lazyblock-script-code-block lazyblock-script-code-block-ilosx\"><div class=\"code-block w-100\" >\n<pre class=\"wp-block-code\" id=\"api-php\" >\n  $data = array(\n    \"APPKEY\" => \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\", \/\/ Organization APPKEY, *required\n    \"APP_SECRET\" => \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\", \/\/ Organization SECRET, *required\n    \"firstname\" => \"John\", \/\/Client firstname\n    \"lastname\" => \"Doe\", \/\/Client lastname\n    \"email\" => \"john.doe@gmail.com\", \/\/Client email, *required\n    \"IP\" =>  \"71.23.54.682\", \/\/Client IP\n    \"orderName\" => \"Order number 215645675733\", \/\/Order name, Purchase name or Product name \n    \"orderPrice\" => 349, \/\/Order price, Purchase price or Product price \n    \"orderID\" => 1252653462, \/\/ internal ID of the order\n    \"orderItems\" => array( \n        array( \n            \"Name\" => \"Item one\",\n            \"Price\" => 349,\n            \"Quantity\" => 1\n        ) \n    )\n);\n\n$payload = json_encode($data);\n\n\/\/ Prepare new cURL resource\n$ch = curl_init('https:\/\/atlass-302217.ew.r.appspot.com\/order\/add');\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt($ch, CURLINFO_HEADER_OUT, true);\ncurl_setopt($ch, CURLOPT_POST, true);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $payload);\n\n\/\/ Set HTTP Header for POST request \ncurl_setopt($ch, CURLOPT_HTTPHEADER, array(\n'Content-Type: application\/json',\n'Content-Length: ' . strlen($payload))\n);\n\n\/\/ Submit the POST request\n$result = curl_exec($ch);\n\n\/\/ Close cURL session handle\ncurl_close($ch);\n\nvar_dump( $result );<\/pre>\n<a data-copy=\"api-php\" class=\"btn-copy-script\"> <i class=\"far fa-copy\"><\/i>  <\/a>\n<\/div>\n<\/div><\/div><\/div>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n<div class=\"wp-block-lazyblock-bootstrap-alert lazyblock-bootstrap-alert-Z2dXWVu\"><div class=\"alert alert-danger \" role=\"alert\">\n    Don&#8217;t forget to replace the APPKEY and APP_SECRET with the ones designated to your account, as well as the dummy date with the client&#8217;s actual data.\n<\/div><\/div>\n\n\n<p>Save the page and publish it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Locate your function that processed the order. Send a post request to https:\/\/atlass-302217.ew.r.appspot.com\/order\/add containing the JSON code below. Depending on the programming languange, we set up some examples: Don&#8217;t forget to change the fields with the actual customer data. Raw JSON For PHP, use this code: Save the page and publish it.<\/p>\n","protected":false},"featured_media":0,"menu_order":10,"template":"","meta":[],"_links":{"self":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/docs\/73"}],"collection":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/media?parent=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}