Created
August 17, 2012 12:53
-
-
Save mariusbalcytis/3378555 to your computer and use it in GitHub Desktop.
WebToPay Sign verification example
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
<?php | |
$data = '{"type":"reserved","object":"transaction","data":{"transaction_key":"Bi2NKKLSYkxgGALII4bbNc5kGVSGLgMz","created_at":1345205476,"status":"reserved","type":"page","wallet":88,"payments":[{"id":768,"transaction_key":"Bi2NKKLSYkxgGALII4bbNc5kGVSGLgMz","created_at":1345205473,"status":"reserved","price":3,"currency":"LTL","wallet":88,"freeze_until":1346415070,"items":[{"title":"Drabu\u017eio pirkimas (Louboutin kopija)","price":3,"currency":"LTL","quantity":1}],"beneficiary":98},{"id":770,"transaction_key":"Bi2NKKLSYkxgGALII4bbNc5kGVSGLgMz","created_at":1345205475,"status":"reserved","price":2,"currency":"LTL","wallet":88,"freeze_for":0,"items":[{"title":"Saugumo mokestis (Louboutin kopija)","price":2,"currency":"LTL","quantity":1}]},{"id":772,"transaction_key":"Bi2NKKLSYkxgGALII4bbNc5kGVSGLgMz","created_at":1345205476,"status":"reserved","price":1,"currency":"LTL","wallet":88,"freeze_for":0,"items":[{"title":"Drabu\u017eio pristatymas (Louboutin kopija)","price":1,"currency":"LTL","quantity":1}]}],"redirect_uri":"http:\/\/localhost:3000\/member\/transaction\/w2p_transaction_done","callback_uri":"http:\/\/dev.manodrabuziai.lt:999\/member\/transaction\/w2p_transaction_callback"}}'; | |
$sign = '1lOTF1WEcXMs+TmFpOdQYk9xTOKdjctHXZDOx7VpB5xVi593WKsWs2HNAFHluVrzy4w4hodCcIslBBg+cO131z/STuRuwUhTX+9fNORsfLdjS1JGWw+oKtq6sYDlqXTuEYif9SMbO7d8fIzDHL6YHefvlB86CmKrblhVbue0imxxuTdslBB2EkXzTKD9NGCp3OdhzFdMaxOr9pFyNOZsGCqy/8b+XR03V4bV9BKkFPXCZjWYXKc30Ynp3hBU+9zKfyIwa8wIciJ+17u+wN45Hz3F/kCScvkLGWWhm/7yjR7HDRPZuJmjqYilqKcsguzsMKZuA6LkfvyeOmWGw3vsDQ=='; | |
$publicKey = '-----BEGIN PUBLIC KEY----- | |
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7zNjm3FxOMpPKYzS/pIe | |
9RNijrBY6KoE89tAzEQsXtfikXTcCKKOCfwUgkaG892OOW1pXwIDFEEC3oKbqCtU | |
QV7gIZajkRXZYEd68XtMFQaPmUwN089XHzvyeerZNh7kB+CoMtqpt7GMQb3REhtT | |
Ww52hgiG42LEPFdxqGJoYbLgpiV3qVfsYZBBAkSkP1Zd0HHc1wQMu76A23NoK9hf | |
3sniNPrRqYkretDpnqc0vMIjso8Q+eVNeB2oq/gcbs9MQMFpdiLcs8Da8flIAgUS | |
2zrDaUvnKAs5Tcp+YVfGd2nH3+WAQil1j/DJpzyP2P8nAqjjGKLlD6q/MWn0r8KH | |
xQIDAQAB | |
-----END PUBLIC KEY----- | |
'; | |
$signedData = hash('sha256', $data, true); | |
var_dump(base64_encode($signedData)); // not used anywhere, just for debugging | |
// output: string(44) "X0FX+/LxK7OkNk+kMcDFrqvuVnBUdcFGnmJgmSR5TiY=" | |
$result = openssl_verify($signedData, base64_decode($sign), $publicKey); | |
var_dump($result); | |
// output: int(1) | |
// sign verified |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment