1. Go to this page and download the library: Download gladcodes/ravephp library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gladcodes / ravephp example snippets
/**
* REQUIRE AUTOLOADER
*
* Ensure that the
* You could choose to define a constant for {PROJECT_ROOT_DIR}
* And then make it available to all your PHP scripts.
*/
// Assuming you are in the project root directory
pace
use Rave\Rave;
/**
* RAVE CONFIG
*
* env (string)
* The Rave environment.
* Default 'staging'
*
* autoRefs (bool)
* Automatically generate transaction reference.
* Default: true
*/
$config = [
'env' => 'staging',
'autoRefs' => false
];
/**
* RAVE INITIALIZATION
*
* The Rave::init() method takes an optional $config array
* And returns a Rave instance
*
* Rave cannot be instantiated using the `new` keyword.
*/
$rave = Rave::init($config)->run();
use Rave\Rave;
use Rave\Event\EventHandlerInterface;
class MyEventHandler implements EventHandlerInterface
{
/**
* This is called when a transaction is initialized
* @param object $initializationData (This is the initial transaction data as passed)
**/
public function onInit($initializationData) {}
/**
* This is called only when a transaction is successful
* @param object $transactionData (This is the transaction data as returned from the Rave payment gateway)
**/
public function onSuccessful($transactionData) {}
/**
* This is called only when a transaction failed
* @param object $transactionData (This is the transaction data as returned from the Rave payment gateway)
**/
public function onFailure($transactionData) {}
/**
* This is called when a transaction is requeried from the payment gateway
* @param string $transactionReference (This is the transaction reference as returned from the Rave payment gateway)
**/
public function onRequery($transactionReference) {}
/**
* This is called when a transaction requery returns with an error
* @param string $requeryResponse (This is the error response gotten from the Rave payment gateway requery call)
**/
public function onRequeryError($requeryResponse) {}
/**
* This is called when a transaction is cancelled by the user
* @param string $transactionReference (This is the transaction reference as returned from the Rave payment gateway)
**/
public function onCancel($transactionReference);
/**
* This is called when a transaction doesn't return with a success or a failure response.
* @param string $transactionReference (This is the transaction reference as returned from the Rave payment gateway)
* @param object $data (This is the data returned from the requery call)
**/
public function onTimeout($transactionReference,$data);
}
$eventHandler = new MyEventHandler;
$rave = Rave::init()->listener($eventHandler);
$rave->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.