Untitled
unknown
plain_text
a year ago
1.5 kB
2
Indexable
Never
<?php /** * We recommend using Firebase's php-jwt package to verify * Json Web Tokens. You can install it with composer: * > composer require firebase/php-jwt * More information can be found at * https://github.com/firebase/php-jwt */ use \Firebase\JWT\JWT; use \Firebase\JWT\Key; // Fetched from the URL for returnUrl and from POST body->orderToken when it's a notification $orderToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1dWlkIjoidGhlLW1vbnRvbmlvLW9yZGVyLXV1aWQiLCJhY2Nlc3NLZXkiOiJNWV9BQ0NFU1NfS0VZIiwibWVyY2hhbnRSZWZlcmVuY2UiOiJNWS1PUkRFUi1JRC0xMjMiLCJtZXJjaGFudFJlZmVyZW5jZURpc3BsYXkiOiJNWS1PUkRFUi1JRC0xMjMiLCJwYXltZW50U3RhdHVzIjoiUEFJRCIsImdyYW5kVG90YWwiOjk5Ljk5LCJjdXJyZW5jeSI6IkVVUiIsIm1lcmNoYW50X3JlZmVyZW5jZSI6Ik1ZLU9SREVSLUlELTEyMyIsIm1lcmNoYW50X3JlZmVyZW5jZV9kaXNwbGF5IjoiTVktT1JERVItSUQtMTIzIiwicGF5bWVudF9zdGF0dXMiOiJQQUlEIn0.X6Ym70AA1bYIsKyNc1NL4NpznKXCrGX5xacqc1ovtuE'; // The Order ID you got from Montonio as a response to creating the order $montonioOrderId = 'the-montonio-order-uuid'; // Add a bit of leeway to the token expiration time JWT::$leeway = 60 * 5; // 5 minutes // Use your secret key to verify the orderToken $decoded = JWT::decode( $orderToken, new Key('MY_SECRET_KEY', 'HS256'), ); if ( $decoded->paymentStatus === 'PAID' && $decoded->uuid === $montonioOrderId && $decoded->accessKey === 'MY_ACCESS_KEY' ) { // Payment completed } else { // Payment not completed } ?>