'3177400',
);
$defaultConvertKitTag = 'tag-to-use-if-product-is-not-in-list';
$vendor = 'mypassionp';
$secretKey = 'TYUTF6UFTU6RT67R';
$message = json_decode(file_get_contents('php://input'), true);
$encrypted = $message['notification'];
$iv = $message['iv'];
$decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128,
substr(sha1($secretKey), 0, 32),
base64_decode($encrypted),
MCRYPT_MODE_CBC,
base64_decode($iv)), "\0..\32");
$order = json_decode($decrypted, true);
$email = $order['customer']['billing']['email'];
$fname = $order['customer']['billing']['firstName'];
$item = $order['lineItems'][0]['itemNo'];
$convertkitTagId = isset($convertkitTags[$item]) ? $convertkitTags[$item] : $defaultConvertKitTag;
$data = array('api_key' => $convertkitApiKey, 'email' => $email);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, sprintf('https://api.convertkit.com/v3/tags/%s/subscribe', $convertkitTagId));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$jsonresult = curl_exec($ch);
$result = json_decode($jsonresult, true);
?>