pralhadstha/omnipay-fonepay

Fonepay Omnipay Package for PHP applications

v1.0.0 2025-05-31 13:06 UTC

This package is auto-updated.

Last update: 2025-05-31 13:25:27 UTC


README

Fonepay QR driver for the Omnipay PHP payment processing library

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP.

Currently this package only implements Fonepay QR support for Omnipay. Fonepay functionality will be added soon.

Installation

Omnipay is installed via Composer.

To install, simply require league/omnipay and pralhadstha/omnipay-fonepay with Composer:

composer require league/omnipay pralhadstha/omnipay-fonepay

Basic Usage

Purchase

    use Omnipay\Omnipay;
    use Exception;

    $gateway = Omnipay::create('Fonepay_FonepayQr');

    $gateway->setUsername('fonepay_username_or_email');
    $gateway->setPassword('fonepay_password');
    $gateway->setMerchantCode('merchant_code_provided_by_fonepay');
    $gateway->setTestMode(false);

    try {
        $response = $gateway->purchase([
            'amount' => 1000.00,
            'productNumber' => "PN-100",
            'remarks1' => "Remark 1",
            'remarks2' => "Remark 2 if needed",
        ])->send();

        if ($response->isCustomRedirect()) {
            // provide the page to display the QR code.
        }
    } catch (Exception $e) {
        return $e->getMessage();
    }

Payment Complete

    $gateway = Omnipay::create('Fonepay_FonepayQr');

    $gateway->setUsername('fonepay_username_or_email');
    $gateway->setPassword('fonepay_password');
    $gateway->setMerchantCode('merchant_code_provided_by_fonepay');
    $gateway->setTestMode(false);

    try {
        $response = $gateway->completePurchase([
            'productNumber' => "PN-100",
        ])->send();

        if ($response->isSuccessful()) {
            // Payment is successful and will have fonepayTraceId.
        } else {
            // Payment is received as failed and need to again check if payment is completed.
        }
    } catch (Exception $e) {
        return $e->getMessage();
    }

Working Example

Want to see working examples before integrating them into your project? View the examples here

Official Doc

Please follow the Official Document provided by Fonepay to understand about the parameters and their descriptions. The document is not publicly available. Please contact Fonepay team for the documents.

Contributing

Contributions are welcome and will be fully credited.

Contributions can be made via a Pull Request on Github.

Support

If you are having general issues with Omnipay Khalti, drop an email to pralhad.shrestha05@gmail.com for quick support.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.

License

This package is open-sourced software licensed under the MIT license.