Download the PHP package moolre/moolre-php without Composer

On this page you can find all versions of the php package moolre/moolre-php. 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 moolre-php

Moolre PHP SDK

Framework-agnostic PHP package for initiating Moolre hosted payments and verifying transactions from any PHP application.

This package was extracted from the working Moolre WooCommerce gateway flow. It uses the same Moolre API endpoint:

Requirements

For integration testing only, set MOOLRE_FORCE_STREAMS=1 to exercise the PHP-stream transport even when cURL is installed.

Installation

Install with Composer:

Until the package is published to Packagist, install it into an app as a local path repository:

For development inside this package:

Example Project

A complete raw PHP demo app is included at examples/raw-php-app. It shows a cart checkout, payment initiation, webhook callback handling, customer redirect verification, and a small local JSON order store.

Run it from the SDK repository:

Set your credentials before starting the server:

Then edit .env with your Moolre values. You can also set environment variables directly:

On Windows PowerShell:

Then edit .env, or set variables in the same terminal:

Then open http://localhost:8080. If Moolre needs to call your local callback/webhook, expose the app through a tunnel and set APP_URL to the public tunnel URL.

Live and Sandbox Mode

The raw PHP example uses MOOLRE_PRODUCTION as the environment switch:

Live payment initiation requires MOOLRE_PUBLIC_KEY and MOOLRE_ACCOUNT_NUMBER; live verification also requires MOOLRE_API_USER.

Sandbox mode requires MOOLRE_ACCOUNT_NUMBER and MOOLRE_API_USER. The SDK sends MOOLRE_API_USER as the X-API-USER header. MOOLRE_PUBLIC_KEY is optional only in sandbox.

MOOLRE_API_USER is required for every verifyPayment() call, including live mode. Transaction-status requests also include X-API-PUBKEY when a public key is configured.

For a direct SDK integration, choose the endpoint with your own config:

MOOLRE_BASE_URL and MOOLRE_VERIFICATION_URL are supported in the raw PHP example as advanced overrides, but most apps should switch with MOOLRE_PRODUCTION.

Raw PHP

Use callback for the server-to-server notification URL and redirect for the customer return page. Your redirect page should verify the returned reference before showing a paid receipt. Your callback/webhook should also verify the posted reference before updating fulfillment state. The SDK rejects verification responses whose returned reference does not match the reference you requested:

Integration Examples

The SDK is framework-agnostic. Each framework only needs to provide configuration, routing, redirects, and your own order update logic.

Laravel

Symfony

Slim

CodeIgniter 4

API

new Moolre\Client($publicKey, $accountNumber, $transport = null, $baseUrl = Client::DEFAULT_BASE_URL, $timeout = 60, $allowInsecureBaseUrl = false, $apiUser = null, $verificationUrl = null)

Creates a Moolre client.

By default, the SDK requires the Moolre base URL to use HTTPS. Set $allowInsecureBaseUrl to true only for a controlled local HTTP endpoint; the SDK always rejects other URL schemes and base URLs containing user credentials.

For sandbox, set $baseUrl to Client::SANDBOX_BASE_URL (https://sandbox.moolre.com/embed/src/start) and pass your Moolre account username as $apiUser. The SDK sends it as X-API-USER. Public key is optional only for sandbox payment-initiation requests.

$verificationUrl defaults to Client::DEFAULT_VERIFICATION_URL (https://api.moolre.com/open/transact/status) or, when the base URL is the sandbox host, Client::SANDBOX_VERIFICATION_URL. Pass an explicit HTTPS URL if Moolre gives your sandbox a different status endpoint.

$client->initiatePayment(array|PaymentRequest $payment): PaymentInitiation

Required payment fields:

Optional fields:

Callback and redirect URLs must use http or https. Use https in production.

$client->verifyPayment(string $reference): TransactionVerification

Confirms the payment status for a reference. It sends a JSON POST to the configured status URL with type: 1, idtype: '1', id: $reference, and accountnumber: $accountNumber; it includes both X-API-USER and X-API-PUBKEY headers when the public key is configured. $apiUser is mandatory for this method. If Moolre returns a different reference (or transaction id) in the verification response, the SDK throws Moolre\Exceptions\ApiException.

Use matchesPaymentDetails($amount, $currency, $email, $accountNumber) before delivering value. It returns true only when Moolre reports a successful payment whose amount, currency, email, and account number all match the values supplied by your application. The verification response must include data.amount, data.currency, data.email, and data.accountnumber (or data.account_number); otherwise it fails closed.

$transaction->matchesAmountAndAccountNumber(string $amount, string $accountNumber): bool

The transaction-status endpoint returns data.txstatus, data.externalref, data.amount, and data.accountnumber. Use this method when that endpoint does not provide currency or customer-email fields. It requires a successful txstatus, the exact normalized amount, and the account number; the client also matches externalref to the requested local reference.

Client::generateReference(string $prefix = 'moolre'): string

Generates a unique reference that is safe to send to Moolre.

Error Handling

All SDK exceptions extend Moolre\Exceptions\MoolreException.

Security Notes

Troubleshooting

SSL certificate problem on local PHP

If local PHP reports SSL certificate problem: unable to get local issuer certificate, PHP/cURL cannot find a trusted CA bundle. Configure curl.cainfo and openssl.cafile in php.ini, or set MOOLRE_CA_FILE/SSL_CERT_FILE to a valid cacert.pem path.

This is a local PHP trust-store issue. It can happen even when a WooCommerce integration works, because WordPress has its own HTTP layer and CA handling.

Testing

composer smoke runs without dev dependencies. composer test requires the PHPUnit dev dependency from composer install.

The client accepts a custom TransportInterface, so applications can test payment flows without hitting the live Moolre API.

Publishing Checklist

Before tagging a public release:


All versions of moolre-php with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
composer/ca-bundle Version ^1.5
ext-json Version *
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 moolre/moolre-php contains the following files

Loading the files please wait ...