Example #1
0
<?php

include './RaiseNowSignature.php';
$algorithm = "sha256";
$secret = "secretyoumustbe";
// handle post request
if (count($_POST) > 0) {
    $signature = new RaiseNowSignature($secret, $algorithm);
    $hmac = $signature->signData($_POST);
    $order = $_POST;
    $order['hmac'] = $hmac;
    include './reviewOrder.php';
    exit;
} else {
    // default order
    $order = array('hmac' => '', 'payment_method' => 'VIS', 'amount' => '5000', 'currency' => 'chf', 'test_mode' => 'true', 'stored_product_name' => 'A book', 'stored_product_id' => '125', 'stored_customer_name' => 'John Tester', 'stored_transaction_time' => (new DateTime('now'))->format('U'));
}
?>
<!-- render form -->
<html>
<head>
    <title>RaiseNow Example Checkout with HMAC</title>
<body>
<h2>Make your order</h2>
    <form action="./checkout.php" method="POST">
        <input type="hidden" name="hmac" value="<?php 
echo $order['hmac'];
?>
" />
        <input type="hidden" name="stored_transaction_time" value="<?php 
echo $order['stored_transaction_time'];
Example #2
0
<?php

include './RaiseNowSignature.php';
$algorithm = "sha256";
$secret = "secretyoumustbe";
$signature = new RaiseNowSignature($secret, $algorithm);
$hmac = $signature->signData($_GET);
$validationResult = $hmac === $_GET['response_hmac'] ? 'passed' : 'failed';
echo "<h1>HMAC Validation: " . $validationResult . "</h1>";
echo "</p>returned hmac: " . $_GET['response_hmac'];
echo "<br />calculated hmac: " . $hmac . "</p>";
echo "<br /><p>Payment Response:";
foreach ($_GET as $name => $value) {
    echo "<br />" . $name . ": " . $value;
}
echo "</p>";