Created
March 25, 2017 18:09
-
-
Save jan-koch/763135db654b1e895c266901954bf4ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpi_s2_payment_notification() { | |
if ( !empty( $_GET['yourauthenticationtoken']) && 'yes' === $_GET['yourauthenticationtoken'] ) { | |
// in the URL, I have '?yourauthenticationtoken=yes', that's what I'm looking for here. | |
// make sure the request comes from a valid user | |
if ( !empty( $_GET['user_id'] ) ) { | |
// Load the user data for the new license | |
$user_id = (integer) esc_attr( $_GET['user_id'] ); | |
$user = new WP_User($user_id); | |
$first_name = $user->first_name; | |
$last_name = $user->last_name; | |
$email = $user->user_email; | |
$username = $user->user_login; | |
// generate the request to create a license key | |
$api_params = array( | |
'slm_action' => 'slm_create_new', | |
'secret_key' => 'yoursecretkey', | |
'first_name' => $first_name, | |
'last_name' => $last_name, | |
'email' => $email, | |
'max_allowed_domains' => 1, | |
'date_created' => date("Y-m-d") | |
); | |
// send query to license manager server | |
$response = wp_remote_get( | |
add_query_arg( | |
$api_params, | |
'https://wp.immo' | |
), | |
array( | |
'timeout' => 20, | |
'ssl_verify' => false | |
) | |
); | |
// Check for error in the response | |
if (is_wp_error($response)){ | |
echo "Unexpected Error! The query returned with an error."; | |
} | |
// License data. | |
$license_data = json_decode(wp_remote_retrieve_body($response)); | |
} | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment