Lm getting a black page ..php sdk note that l have removed the phone number , id and key


#1
<?php

// THere must be a folder called libraries which contains the folder paynow
// The paynow folder contains paynow sdk
require_once ‘./libraries/paynow/autoloader.php’;

function detectWalletName($phone_number){

// Detect wallet name

$wallet_name = “ecocash”;
if (strpos($phone_number, ‘071’) === 0) {
$wallet_name = “onemoney”;
}

if (strpos($phone_number, ‘073’) === 0) {
$wallet_name = “telecash”;
}

return $wallet_name;
}

function paynowExpress($items){

$phone_number = “”; // You can get it from request or database
$user_email = ‘user@example.com’; // You can get it from request or database

// initialize paynow payment
$paynow = new Paynow\Payments\Paynow(
‘’,
‘’,
http://example.com/gateways/paynow/update’,

  // The return url can be set at later stages. You might want to do this if you want to pass data to the return url (like the reference of the transaction)
  'http://example.com/return?gateway=paynow'

);

// Create payment

$payment = $paynow->createPayment(‘Invoice 35’, $user_email);

// Add payment items

foreach ($items as $item){
$payment->add($item[‘name’], $item[‘price’]);
}

// Detect wallet name and send payment
$wallet_name = detectWalletName($phone_number);
$response = $paynow->sendMobile($payment, $phone_number, $wallet_name);
}

// Check transaction success
if ($response->success()) {

        $timeout = 9;
        $count = 0;

        while (true) {
            sleep(3);
            // Get the status of the transaction
            // Get transaction poll URL
            $pollUrl = $response->pollUrl();
            $status = $paynow->pollTransaction($pollUrl);
            //Check if paid
            if ($status->paid()) {
                // Yay! Transaction was paid for
                // You can update transaction status here
                // Then route/redirect to a payment successful page
            }



            $count++;



            if ($count > $timeout) {
                // Timeout reached
                // Notify user here
            }
        }
    }

  
    // Payment failed
    // Route/Redirect to payment failed page

?>


#2

Did you get a response from Paynow ?Can you share your console output