dash8x/rm-laravel

Laravel wrapper for Revenue Monster PHP SDK

v0.7.0 2022-12-19 17:34 UTC

This package is auto-updated.

Last update: 2024-04-19 20:19:41 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

Laravel wrapper for Revenue Monster PHP SDK.

Installation

You can install the package via composer:

composer require dash8x/rm-laravel

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider/Facade.

After updating composer, add the ServiceProvider to the providers array in config/app.php

Dash8x\RevenueMonster\Providers\RevenueMonsterServiceProvider::class;

Optionally you can use the Facade for shorter code. Add this to your facades:

'RevenueMonster' => Dash8x\RevenueMonster\Facades\RevenueMonsterFacade::class;

Setting up the Revenue Monster credentials

Add your Revenue Monster Client ID and Client Secret to your config/services.php. You can refer to how to create the API Client from the Official Revenue Monster Documentation.

Make sure to add the private key file to gitignore if you've it in the project directory.

// config/services.php
...
'rm' => [
    'client_id' => env('RM_CLIENT_ID'), // Client ID 
    'client_secret' => env('RM_CLIENT_SECRET'), // Client Secret
    'sandbox' => env('RM_SANDBOX', false), // Whether to use the sandbox mode
    'private_key' => base_path('/rm-private-key.pem'), // Path to the private key file                           
],
...

Usage

Using the App container:

$rm = App::make('rm');

// Get merchant profile
try {
  $response = $rm->merchant->profile();
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

Using the Facade

// Get merchant profile
try {
  $response = RevenueMonster::merchant()->profile();
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

Available Methods

Refer to the readme for the Official PHP SDK.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email contact@arushad.org instead of using the issue tracker.

Credits

License

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