PHPackages                             monei/monei-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. monei/monei-php-sdk

ActiveLibrary[HTTP &amp; Networking](/categories/http)

monei/monei-php-sdk
===================

The MONEI SDK will allow you to interact with our API in an easy and predictable way.

2.10.2(3mo ago)313.7k↓26.4%3[3 PRs](https://github.com/MONEI/monei-php-sdk/pulls)1MITPHPPHP &gt;=7.4CI passing

Since Sep 18Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/MONEI/monei-php-sdk)[ Packagist](https://packagist.org/packages/monei/monei-php-sdk)[ Docs](https://monei.com)[ RSS](/packages/monei-monei-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (78)Used By (1)

MONEI PHP SDK
=============

[](#monei-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/2815ddc868a77d5e640d19765293acdcf20fb5cd3131f8099ac38f14780782a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6e65692f6d6f6e65692d7068702d73646b2e737667)](https://packagist.org/packages/monei/monei-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/137ed842d552e04b1e7757912f995f305af8b73afdeac035bfb7a9939bb77eaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f6e65692f6d6f6e65692d7068702d73646b2e737667)](https://packagist.org/packages/monei/monei-php-sdk)[![License](https://camo.githubusercontent.com/205ebb6aafb7285cbd91b0c24cb16f75fddc7ca7c4a8915d6d5e6dfaf93e019d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f6e65692f6d6f6e65692d7068702d73646b2e737667)](https://packagist.org/packages/monei/monei-php-sdk)[![PHP Version](https://camo.githubusercontent.com/b2437a8907a55e4e8941250bcdd2cb5cf87984ac43b481c556b48197bee8a948/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6f6e65692f6d6f6e65692d7068702d73646b2e737667)](https://packagist.org/packages/monei/monei-php-sdk)

The MONEI PHP SDK provides convenient access to the [MONEI](https://monei.com/) API from applications written in server-side PHP.

For collecting customer and payment information in the browser, use [monei.js](https://docs.monei.com/docs/monei-js-overview).

Table of Contents
-----------------

[](#table-of-contents)

- [MONEI PHP SDK](#monei-php-sdk)
    - [Table of Contents](#table-of-contents)
    - [Requirements](#requirements)
    - [Installation](#installation)
    - [Basic Usage](#basic-usage)
        - [API Keys](#api-keys)
            - [Types of API Keys](#types-of-api-keys)
            - [API Key Security](#api-key-security)
        - [Test Mode](#test-mode)
        - [Basic Client Usage](#basic-client-usage)
    - [Payment Operations](#payment-operations)
        - [Creating a Payment](#creating-a-payment)
        - [Retrieving a Payment](#retrieving-a-payment)
        - [Refunding a Payment](#refunding-a-payment)
    - [Integration Methods](#integration-methods)
        - [Using the Prebuilt Payment Page](#using-the-prebuilt-payment-page)
            - [Features](#features)
            - [Integration Flow](#integration-flow)
    - [Webhooks](#webhooks)
        - [Signature Verification](#signature-verification)
        - [Handling Payment Callbacks](#handling-payment-callbacks)
            - [Important Notes About Webhooks](#important-notes-about-webhooks)
    - [MONEI Connect for Partners](#monei-connect-for-partners)
        - [Account ID](#account-id)
            - [Setting Account ID after initialization](#setting-account-id-after-initialization)
        - [Custom User-Agent](#custom-user-agent)
            - [Examples with Proper User-Agent Format](#examples-with-proper-user-agent-format)
        - [Managing Multiple Merchant Accounts](#managing-multiple-merchant-accounts)
    - [Development](#development)
        - [Building the SDK](#building-the-sdk)
    - [Tests](#tests)
    - [Code Style](#code-style)
    - [Documentation](#documentation)

Requirements
------------

[](#requirements)

- PHP 7.4 or later

Installation
------------

[](#installation)

Install the package using Composer:

```
composer require monei/monei-php-sdk
```

Then run `composer install`

Basic Usage
-----------

[](#basic-usage)

### API Keys

[](#api-keys)

The MONEI API uses API keys for authentication. You can obtain and manage your API keys in the [MONEI Dashboard](https://dashboard.monei.com/settings/api).

#### Types of API Keys

[](#types-of-api-keys)

MONEI provides two types of API keys:

- **Test API Keys**: Use these for development and testing. Transactions made with test API keys are not processed by real payment providers.
- **Live API Keys**: Use these in production environments. Transactions made with live API keys are processed by real payment providers and will move actual money.

Each API key has a distinct prefix that indicates its environment:

- Test API keys start with `pk_test_` (e.g., `pk_test_12345abcdef`)
- Live API keys start with `pk_live_` (e.g., `pk_live_12345abcdef`)

By checking the prefix of an API key, you can quickly determine which environment you're working in. This is especially useful when you're managing multiple projects or environments.

#### API Key Security

[](#api-key-security)

Your API keys carry significant privileges, so be sure to keep them secure:

- Keep your API keys confidential and never share them in publicly accessible areas such as GitHub, client-side code, or in your frontend application.
- Use environment variables or a secure vault to store your API keys.
- Restrict API key access to only the IP addresses that need them.
- Regularly rotate your API keys, especially if you suspect they may have been compromised.

```
// Example of loading API key from environment variable (recommended)
$apiKey = getenv('MONEI_API_KEY');
$monei = new Monei\MoneiClient($apiKey);
```

### Test Mode

[](#test-mode)

To test your integration with MONEI, you need to switch to **test mode** using the toggle in the header of your MONEI Dashboard. When in test mode:

1. Generate your test API key in [MONEI Dashboard → Settings → API Access](https://dashboard.monei.com/settings/api)
2. Configure your payment methods in [MONEI Dashboard → Settings → Payment Methods](https://dashboard.monei.com/settings/payment-methods)

**Important:** Account ID and API key generated in test mode are different from those in live (production) mode and can only be used for testing purposes.

When using test mode, you can simulate various payment scenarios using test card numbers, Bizum phone numbers, and PayPal accounts provided in the [MONEI Testing documentation](https://docs.monei.com/docs/testing/).

### Basic Client Usage

[](#basic-client-usage)

```
