I am getting Hash error https://fixelr.in


#1

define(‘INTEGRATION_KEY’, ‘xyzxyz’);
define(‘MERCHANT_ID’, ‘123123’);

// Define functions
function CreateHash($values) {
$string = “”;
foreach ($values as $key => $value) {
if (strtoupper($key) != “HASH”) {
$string .= $value;
}
}
echo $string;

$string .= INTEGRATION_KEY;
echo $string;
$hash = hash("sha512", $string);
return strtoupper($hash);

}

function initiatePayment($amount, $reference) {
// Define base URL
$baseUrl = ‘https://pay.xyz.com’;

// Define the URLs where Paynow ZW will redirect the user after payment
$returnUrl = $baseUrl . '/success.php?ref=xyz';
$resultUrl = $baseUrl . '/result.php';

$data = [
    'id' => MERCHANT_ID,
    'reference' => $reference,
    'amount' => $amount,
    'additionalinfo' => 'A test ticket transaction',
    'returnurl' => $returnUrl,
    'resulturl' => $resultUrl,
    'status' => 'Message', // Initial status
    'authemail' => 'raj@gmail.com'
];

$hash = CreateHash($data);
//$data['hash'] = $hash;

// Send data to Paynow ZW API
// You need to implement this part based on your preferred HTTP client (e.g., cURL, Guzzle)
$response = sendRequest('https://www.paynow.co.zw/interface/initiatetransaction', $data);

// Process response
if (!empty($response['status']) && $response['status'] == 'ok') {
    // Redirect user to payment page
    header('Location: ' . $response['browserurl']);
    exit;
} else {
    // Handle error
    echo 'Error initiating payment: ' . print_r($response, true);
    die(); // Terminate script execution
}

}

function sendRequest($url, $data) {
// You need to implement this part based on your preferred HTTP client (e.g., cURL, Guzzle)
// This is a placeholder function
// Example using cURL:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
return json_decode($response, true);
}

// Example usage
$amount = 100.00; // Amount to be paid (in ZWL)
$reference = ‘ORDER hj’; // Your unique order/reference ID

try {
initiatePayment($amount, $reference);
} catch (Exception $e) {
// If payment fails, redirect to failure page with error message
header(‘Location: failure.php?error=’ . urlencode($e->getMessage()));
exit;
}
i am getting this error
status=Error&error=Invalid+Hash.++Hash+should+start+with%3a+E43D78


#2

Good day Raj,

Please make sure your integration is live. If your integration is still on test mode please use your registered email as auth email.
For test mode

We recommend that you use our PHP SDKs for integration

use the command below to install

composer require paynow/php-sdk

You can also clone the SDK from github and import into your project


#3

Failed to download paynow/php-sdk from dist: The zip extension and unzip/7z commands are both missing, skipping.
The php.ini used by your command-line PHP is: C:\xampp\php\php.ini
Now trying to download from source
Can You Give Me A Working Git Source Of Implemented Paynow SDK In Laravel i have tried finding one


#4

when using on Laravel i am getting failed response and my key and id is on testing i have applied for live form last week i dont know what to do next?


#5

image
this is the response i am getting in UI

and this is my code in controller
public function create(Request $request){
try{
$paynow = new Paynow(
‘xyzid’,
‘xyzkey’,
https://pay.mydomain.com/fj/public/checkout-payment”,

        "https://pay.mydomain.com/fj/public/result/"
        );
        

        
        $payment = $paynow->createPayment('Invoice 35', 'mypaynowemail@mail.com');
        
        $payment->add('Bananas', 2.5);
        //return response()->json(['er' => $paynow]);
        $response = $paynow->send($payment);
        
        
        if($response->success()) {
            // Or if you prefer more control, get the link to redirect the user to, then use it as you see fit
            $link = $response->redirectUrl();
        
            $pollUrl = $response->pollUrl();
        
        
            // Check the status of the transaction
            $status = $paynow->pollTransaction($pollUrl);
        
        }else{
            #this is getting called with above image
            return response()->json(['er' => $response]);
        }
    
    
}catch(\Exception $e){
    return response()->json(['success' => $e->getMessage()]);
}
}

#6

Hi Raj, That error means you dont have the zip extension on your PHP installation, Its your internal error.

You can just download the src and manually unzip and include the folder on your project, if you are using Laravel then use the composer package it works in all PHP frameworks

composer require paynow/php-sdk

#7

no i have check zip extension is working on my PHP and i have tried manual and using composer but i am getting success : false status : error


#8

i dont know your whole software is outdated and there is no good documentation about your service how can i implement what things to takecare when doing testing what is precaution and etc.


#9

help me on this i am waiting for response from last two weeks


#10

Hi Raj can you send full response from Paynow damp the response data Object. and kindly send your integration ID to my inbox