Skip to content

Instantly share code, notes, and snippets.

@waqasajaz
Created July 21, 2023 19:04
Show Gist options
  • Save waqasajaz/ca8a4b170622469b318de42068e9196d to your computer and use it in GitHub Desktop.
Save waqasajaz/ca8a4b170622469b318de42068e9196d to your computer and use it in GitHub Desktop.
<?php
require_once('config.php');
include_once 'verify_utils.php';
$shopify = $_GET;
$shop_url = $shopify['shop'];
$shop_name = get_shop_name($shop_url, '', '.myshopify.com');
//check if app is already install or not
$store_detail = [
'name' => $shop_name,
'website' => $shop_url,
];
$req_res = shopify_store_request(
$request_url = 'https://dev-api.verifinow.io/shopify/stores',
$request_type = 'POST',
$body = $store_detail,
$filters = true
);
$jsonResponse = json_decode($req_res);
$store_data = [
'name' => $shop_name,
'website' => $shop_url,
'hmac' => $shopify['hmac'],
'access_token' => 'test',
'twilio_sid' => '',
];
if ($jsonResponse->status == false) {
$req_res = shopify_store_request(
$request_url = 'https://dev-api.verifinow.io/shopify/store',
$request_type = 'POST',
$body = $store_data
);
// redirect url if app is not install
header('Location: install.php?shop=' . $shopify['shop']);
exit();
} else {
if (empty($jsonResponse->data)) {
$req_res = shopify_store_request(
$request_url = 'https://dev-api.verifinow.io/shopify/store',
$request_type = 'POST',
$body = $store_data
);
// redirect url if app is not install
header('Location: install.php?shop=' . $shopify['shop']);
exit();
} else {
//its home page you can redirect this to orders page
header(
'Location: '. $base_url .'dashboard.php'
);
exit();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment