Download the PHP package gladcodes/ravephp without Composer

On this page you can find all versions of the php package gladcodes/ravephp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ravephp

RavePHP

This package provides a very simple interface for integrating the Rave Payment Gateway to your PHP application. It is an extension of the Flutterwave-Rave-PHP-SDK package originally developed by Femi Olanipekun.


  1. Getting Started
    • Installation
    • Configuration
    • Setting Up for Payment
  2. Advanced Usage
    • Custom Payment Fields
    • Payment Metadata
    • Event Handlers
  3. License


Getting Started

Installation

This package can be installed as a dependency in your project using Composer.

This adds the RavePHP package to the vendor folder of your project root directory. You can then require the autoloader our PHP scripts to use the package as follows:


Configuration

After the installation, you can set config variables for your PHP app. This package requires that a .env file exists in the root directory of your project that contains all the config variables. The following config variables are required for Rave integration.

Variable Description Required
RAVE_APP_NAME The name of your app or business. Optional. Defaults to MY_APP_NAME if not defined.
RAVE_STAGING_PUBLIC_KEY Your staging environment public key. Required for staging
RAVE_STAGING_SECRET_KEY Your staging environment secret key. Required for staging
RAVE_LIVE_PUBLIC_KEY Your live environment public key. Required for live
RAVE_LIVE_SECRET_KEY Your live environment secret key. Required for live

Create a new .env file in your project root directory (or edit the file if it already exists) with the following content. Ensure to replace them with your own config values.


Version Control and .env file
It is adviced that you remove the .env file from version control since it usually contains some sensitive information like API keys which should not be visible to the outside world. If you are using Git for version control, remember to add the .env entry to the .gitignore file of your project.


Setting Up for Payment

Payment Form

To make payment, you will need to setup a payment form and a PHP payment script. The payment form is expected to send a form-encoded POST request to the payment script when submitted. In other words, the action of the payment form should be the payment script. Check the payment form example for a sample payment form snippet. The payment form by default should contain the following fields.

Field Description
amount The transaction payment amount
payment_method Payment method can be card, account or both
description The transaction description
logo Your app logo URL
title The transaction title
country The transaction country
currency The transaction payment currency
email The customer's email
firstname The customer's firstname
lastname The customer's lastname
phonenumber The customer's phone number
pay_button_text The text you want displayed on the payment button
ref The transaction reference. Must be unique per transaction. By default, a unique transaction reference is generated automatically for each transaction. You can override this behaviour when initializing Rave.


Payment Script

The payment script is where you initialize and run Rave to process the payment request sent from the payment form. Rave fetches the payload of the payment request from the PHP $_POST superglobal. Below is the snippet for a basic payment script. The snippet assumes that the payment script is located at the root directory of your project.


Advanced Usage

Custom Payment Fields

You can setup Rave to look for custom payment field names other than the default names in your payment form. For example, say your payment form uses a payment_amount field for the transaction payment amount and a payment_currency field for the currency. You can map the custom fields to the default fields using the fields() method of the Rave instance.

Note: The custom field names must only contain alphanumeric characters (0-9A-Za-z) and underscores (_). Also, the field name must not start with a digit. Hence, '2nd_address' and 'address-2' are invalid, but 'address_2' is valid.

Your payment form should reflect the custom fields:


Payment Metadata

Sometimes you may want to send some metadata alongside the payment request to further describe the payment. You can setup Rave to look for metadata field names in your payment form. For example, say you want to send the customer_ip_address and customer_user_agent alongside the payment data. You can specify metadata fields using the meta() method of the Rave instance.

Note: The metadata field names must only contain alphanumeric characters (0-9A-Za-z) and underscores (_). Also, the field name must not start with a digit. Hence, '2nd_address' and 'address-2' are invalid, but 'address_2' is valid.

Your payment form should include the metadata fields:


Event Handlers

An instance of the Rave\Event\BaseEventHandler is used as the default event handler for the Rave instance. This event handler simply echoes text to the output for each event. You may define your own custom event handler to use instead of the default one. Here are a few guidelines for implementing your own event handler.

  1. Must implement Rave\Event\EventHandlerInterface
    Your event handler must implement the following methods of the Rave\Event\EventHandlerInterface:

    Method Description
    onInit($initializationData) This is called when a transaction is initialized.
    onSuccessful($transactionData) This is called only when a transaction is successful.
    onFailure($transactionData) This is called only when a transaction failed.
    onRequery($transactionReference) This is called when a transaction is requeried from the payment gateway.
    onRequeryError($requeryResponse) This is called when a transaction requery returns with an error.
    onCancel($transactionReference) This is called when a transaction is cancelled by the user.
    onTimeout($transactionReference, $data) This is called when a transaction doesn't return with a success or a failure response. This can be a timedout transaction on the Rave server or an abandoned transaction by the customer.


  2. Attach an instance of the event handler to the Rave instance using the listener() method
    Create a new instance of your custom event handler and attach it to the Rave instance using the listener() method of the Rave instance.


License

This package is covered by the MIT license. Below is a copy of the license (please read carefully).



All versions of ravephp with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
monolog/monolog Version 1.*
mashape/unirest-php Version ^3.0
vlucas/phpdotenv Version ^2.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gladcodes/ravephp contains the following files

Loading the files please wait ....