Skip to content

soap/laravel-omise

Repository files navigation

Laravel Omise Integration with Ease

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Make Omise payment gateway integration easier with Laravel.

Support us

Installation

You can install the package via composer:

composer require soap/laravel-omise

You can publish the config file with:

php artisan vendor:publish --tag="omise-config"

This is the contents of the published config file:

return [
    'url' => 'https://api.omise.co',

    'live_public_key' => env('OMISE_LIVE_PUBLIC_KEY', 'pkey_test_xxx'),
    'live_secret_key' => env('OMISE_LIVE_SECRET_KEY', 'skey_test_xxx'),

    'test_public_key' => env('OMISE_TEST_PUBLIC_KEY', ''),
    'test_secret_key' => env('OMISE_TEST_SECRET_KEY', ''),

    'api_version' => env('OMISE_API_VERSION', '2019-05-29'),

    'sanbox_status' => env('OMISE_SANDBOX_STATUS', true),
];

Usage

You have to register with Omise, then fill in the keys as in the configuration file. Note: you just add your keys in the .env file, and then test if it is valid using artisan command.

php artisan omise:verify

Create Omise API Objects

To create Omise API objects like Charge, Source, Customer you can use Laravel independency injection (Soap\LaravelOmise\Omise) or use app('omise') and the access them like this:

$account = app('omise')->account()->retrieve(); // method herer
$account->livemode; // access property access
$account->livemode(); // using method access

$account->api_version; // snake case as return from omise
$account->apiVersion(); // camelCase if use method to access

// get public key or secret key

$omise->getPublicKey(); // to get live public key or test one depends on 'sandbox_status'
$omise->getPrivateKey();

Here is the example usage from Controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Soap\LaravelOmise\Omise;
use Soap\LaravelOmise\Omise\Charge;
use Soap\LaravelOmise\Omise\Error;

class PaymentController extends Controller
{
    public function __construct(protected Omise $omise) {}

    public function create()
    {
        $publicKey = $this->omise->getPublicKey();

        return view('payments.form', compact('publicKey'));
    }
}

Artisan Commands

Verification

Account

Customer

Charge

Refund

Testing

vendor\bin\pest

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Omise wrapper for Laravel application

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages