-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'paywall-checkout-autologin'
- Loading branch information
Showing
5 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
function write_log($log) { | ||
if (true === WP_DEBUG) { | ||
if (is_array($log) || is_object($log)) { | ||
error_log(print_r($log, true)); | ||
} else { | ||
error_log("[SSO2][Landing] ".$log); | ||
} | ||
} | ||
} | ||
|
||
$token = $_POST["jwtToken"]; | ||
if (!isset($token)) { | ||
write_log("No token available!"); | ||
die("No token available!"); | ||
} | ||
|
||
$baseurl = explode( "wp-content" , $_SERVER['SCRIPT_FILENAME'] ); | ||
$baseurl = $baseurl[0]; | ||
require_once( $baseurl . "wp-load.php" ); | ||
|
||
use \Firebase\JWT\JWT; | ||
|
||
|
||
try | ||
{ | ||
$client_secret = get_option('tulo_paywall_secret'); | ||
$session = new Tulo_Payway_Session(); | ||
$payload = $session->decode_jwt($token, $client_secret); | ||
if (isset($payload)) { | ||
$session->process_checkout_landing($payload); | ||
} | ||
|
||
} catch(Firebase\JWT\ExpiredException $e) { | ||
// we land here if the JWT token can not be decoded properly, in this case some claims have expired. | ||
write_log("Could not decode JWT from Payway! Message: ".$e->getMessage()); | ||
} | ||
|
||
die(); | ||
|
||
|
||
?> |
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
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
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
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