Skip to content

Instantly share code, notes, and snippets.

@vanpelt
Created August 21, 2012 22:06
Show Gist options
  • Save vanpelt/3419863 to your computer and use it in GitHub Desktop.
Save vanpelt/3419863 to your computer and use it in GitHub Desktop.
PHP sample code
//Initiation code (should be in 1 file)
$json = $_POST['payload']
$secret = "your_secret_key_in_the_settings_page"
$obj = json_decode($json)
if(sha1($json+$secret) == $_POST['signature']) {
if(some_function_that_checks_if_a_uid_is_valid_by_checking_your_database($obj['uid'])) {
$conversion_id = some_function_that_generates_and_stores_a_conversion_id_with_the_amount($obj['amount'])
echo $conversion_id
} else {
http_response_code(401);
}
} else {
http_response_code(401);
}
//Completion code (should be in another file)
$json = $_POST['payload']
$secret = "your_secret_key_in_the_settings_page"
$obj = json_decode($json)
if(sha1($json+$secret) == $_POST['signature']) {
if(some_function_that_asks_your_database_if_a_conversion_id_is_valid($obj['conversion_id'])) {
some_function_that_records_a_completed_conversion_in_your_database($obj['conversion_id'])
echo "OK"
} else {
http_response_code(401);
}
} else {
http_response_code(401);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment