PHPackages                             omise/omise-php - 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. [Payment Processing](/categories/payments)
4. /
5. omise/omise-php

ActiveLibrary[Payment Processing](/categories/payments)

omise/omise-php
===============

A PHP library designed specifically to connect with Omise API.

v3.0.0(11mo ago)71478.0k—5.5%42[7 issues](https://github.com/omise/omise-php/issues)[2 PRs](https://github.com/omise/omise-php/pulls)5MITPHPPHP &gt;=5.6CI passing

Since Feb 4Pushed 1mo ago27 watchersCompare

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

READMEChangelog (10)Dependencies (5)Versions (41)Used By (5)

Omise PHP Library
=================

[](#omise-php-library)

`omise-php` is a PHP library designed specifically to connect with the Opn Payments API.

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

[](#requirements)

- PHP v7.4 and higher.
- Built-in [libcurl](http://php.net/manual/en/book.curl.php) support.

> Note: Due to the PHP [END OF LIFE](http://php.net/supported-versions.php) cycle, we encourage you to run the Omise-PHP library on PHP version 7.4 or higher as there is no longer security support for any PHP version lower than 7.4. Lack of support could cause security vulnerabilities.

Versioning and Compatibility
============================

[](#versioning-and-compatibility)

> **Security Warning**: Please do NOT use Omise PHP library versions less than 2.12.0, as they are outdated and have security vulnerabilities.

Library VersionSupportSupported Omise API VersionPHP Version(s)Notes1.xEnd of Life (EOL)N/AN/A2.xMaintenance Mode2017-11-02PHP &gt;= 5.33.xActive2019-05-29PHP &gt;= 7.4**\*Maintenance mode includes only bug fixes and security updates.**

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

[](#installation)

### Using Composer

[](#using-composer)

You can install the library via [Composer](https://getcomposer.org/). If you don't already have Composer installed, first install it by following one of these instructions, depending on your OS:

- [Composer installation instruction for Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)
- [Composer installation instruction for Mac OS X and Linux](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)

1. After Composer is installed, you can declare Omise-PHP as a project dependency by creating a `composer.json` file at the root of your project directory, with the following content:

    ```
    {
      "require": {
        "omise/omise-php": "dev-master"
      }
    }
    ```
2. Run the following command to install the Omise-PHP library:

    ```
    php composer.phar install

    ```
3. Once you run the `composer install` command, the Composer will generate a `vendor` folder in the same directory as `composer.json`.

    Add the following line to the PHP script to load the library:

    ```
    require_once dirname(__FILE__).'/vendor/autoload.php';
    ```
4. You are ready to start using the library. View the [configuration](https://github.com/omise/omise-php#configuration) and [quick start](https://github.com/omise/omise-php#quick-start) sections for usage examples.

### Manually

[](#manually)

If you are not using Composer, you can download [the latest version of Omise-PHP](https://github.com/omise/omise-php/archive/v3.0.0.zip). Then, follow the instructions to install **Omise-PHP** to the project.

1. Extract the library to your project.
2. Include the following line in your PHP file:

    ```
    require_once 'path-to-library/omise-php/lib/Omise.php';
    ```
3. You are ready to start using the library. View the [configuration](https://github.com/omise/omise-php#configuration) and [quick start](https://github.com/omise/omise-php#quick-start) sections for usage examples.

*Using Composer is recommended as you can easily keep the library up-to-date.*

Configuration
-------------

[](#configuration)

### • Configure your public and secret keys

[](#-configure-your-public-and-secret-keys)

Before you make the first request to the Opn Payments API, you will need to configure your **public key** and **secret key** (these can be found on the [Opn Payments Dashboard](https://dashboard.omise.co). Log in, then go to **Keys** from the sidebar menu).

[![configuring omise-php, public and secret keys](https://user-images.githubusercontent.com/2154669/54261954-9eed9e00-459f-11e9-96b1-747061640fab.png)](https://user-images.githubusercontent.com/2154669/54261954-9eed9e00-459f-11e9-96b1-747061640fab.png)

Place the following code next to the line where Omise-PHP library is loaded.

```
define('OMISE_PUBLIC_KEY', 'pkey_test_***');
define('OMISE_SECRET_KEY', 'skey_test_***');
```

*Reference: [API Authentication](https://docs.opn.ooo/api-authentication).*

ー

### • API version

[](#-api-version)

To enforce the API version that the application must use, define `OMISE_API_VERSION`. The version specified by this settings will override the version setting in your account. This is useful if you have multiple environments with different API versions (e.g. development on the latest but production on the older version).

```
define('OMISE_API_VERSION', '2019-05-29');
```

API version can be found on the [Opn Payments Dashboard](https://dashboard.omise.co). Log in, then go to **API versions** from the top-right menu.

[![configuring omise-php, API version](https://cloud.githubusercontent.com/assets/2154669/24141410/ef0faf46-0e55-11e7-8e25-26e2a6fc403b.png)](https://cloud.githubusercontent.com/assets/2154669/24141410/ef0faf46-0e55-11e7-8e25-26e2a6fc403b.png)

> It is highly recommended to set `OMISE_API_VERSION` to the current version that you are using to prevent any issues that might arise from accidentally clicking `update Omise-API version` on the dashboard.

Quick start
-----------

[](#quick-start)

From the preceding sections, your code will look similar to the following code:

```
