Connecting Shopify to Heroku to NetSuite

Create a Heroku app in Heroku Server.

Connect to a Git Hub, which we can deploy our code for execution.

Connect to a public repository to the Heroku and add execution code in created new repository. After successful deployment, we can sent notification from shopify.

In order to deploy successful, we need some packages installed. For that every package files need to be added in git hub repository.

Needed files as follows.

Composer.lock file (The Composer lock file is a guarantee of the dependency versions that will be installed, right down to an individual commit level.)

Composer.json file (composer.json also checks for version compatibility with your project. This means if you are using an older package, composer.json will let you know in order to avoid future issues. You have the option to create and update composer.json yourself.)

Shopify.PHP file (Code to connect from shopify to heroku to NetSuite)

<?php
$_POST = json_decode(file_get_contents('php://input'), true);
$data = $_POST;

$data['type'] = $_GET['type'];
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://tstdrv1494412.extforms.netsuite.com/app/site/hosting/scriptlet.nl?script=1663&deploy=1&compid=TSTDRV1494412&h=477ca241de02f439c8a9",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"accept: */*",
"accept-language: en-US,en;q=0.8",
"content-type: application/json",
"User-Agent: Mozilla/5.0"
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

// if ($err) {
// echo "cURL Error #:" . $err;
// } else {
// print_r(json_decode($response));
// print_r('hhhh');
// }

?>

In Shopify Setup

Create a webhook in shopify under notification tab in settings.

select the event type as we need for example (Order Creation)

Provide the app URL and the file we deployed in git hub example (https://tgraphtech-shopify-integration.herokuapp.com/shopify.php)

When ever an order created in shopify a notification will sent to the URL provided in PHP code.

Leave a comment

Your email address will not be published. Required fields are marked *