New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

dcodegroup/laravel-myob-oauth

Simple package which dcode uses to handle the connection to MYOB for all projects. Provides endpoints for UI and callbacks for MYOB
3,043 1
Install
composer require dcodegroup/laravel-myob-oauth
Latest Version:0.1.8
PHP:^8.0|^8.1
Laravel:8 · 9
Older releases:7
License:MIT
Last Updated:Dec 11, 2024
Links: GitHub  ·  Packagist
Maintainer: dcodegroup

Laravel MYOB

This package provides the standard MYOB connection functionality used in most projects.

Installation

You can install the package via composer:

composer require dcodegroup/laravel-myob-oauth

Then run the install command.

php artsian laravel-myob:install

This will publish the configuration file and the migration file.

Run the migrations

php artsian migrate

Configuration

Most of configuration has been set the fair defaults. However you can review the configuration file at config/laravel-myob-oauth.php and adjust as needed

Usage

The package provides an endpoints which you can use. See the full list by running

php artsian route:list --name=myob
+--------+----------+-------------------------+--------------------+-------------------------------------------------------------------------+----------------------------------+
| Domain | Method   | URI                     | Name               | Action                                                                  | Middleware                       |
+--------+----------+-------------------------+--------------------+-------------------------------------------------------------------------+----------------------------------+
|        | GET|HEAD | myob                    | myob.index         | Dcodegroup\LaravelMyobOauth\Http\Controllers\XeroController             | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
|        | GET|HEAD | myob/auth               | xero.auth          | Dcodegroup\LaravelMyobOauth\Http\Controllers\XeroAuthController         | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
|        | GET|HEAD | myob/callback           | xero.callback      | Dcodegroup\LaravelMyobOauth\Http\Controllers\XeroCallbackController     | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
|        | POST     | myob/tenants/{tenantId} | xero.tenant.update | Dcodegroup\LaravelMyobOauth\Http\Controllers\SwitchXeroTenantController | web                              |
|        |          |                         |                    |                                                                         | App\Http\Middleware\Authenticate |
+--------+----------+-------------------------+--------------------+-------------------------------------------------------------------------+----------------------------------+

More Information

example.com/myob Which is where you will generate the link to authorise MYOB. This is by default protected auth middleware but you can modify in the configuration. This is where you want to link to in your admin and possibly a new window

example.com/myob/callback This is the route for which xero will redirect back tp after the oauth has occurred. This is excluded from the middleware auth. You can change this list in the configuration also.

BaseMyobService

The package has a BaseMyobService class located at Dcodegroup\LaravelMyobOauth\BaseMyobService

So your application should have its own MyobService extend this base class as the initialisation is already done.

<?php

namespace App\Services\Myob;

use Dcodegroup\LaravelMyobOauth\MyobService;
use XeroPHP\Models\Accounting\Contact;

class MyobService extends MyobService
{
    /**
     * @inheritDoc
     */
    public function createContact(object $data)
    {
    
        /**
         * $this->>xeroClient is inherited from the  BaseXeroService
         */
        $contact = new Contact($this->xeroClient);

        $contact->setName($data->name . ' (' . $data->code . ')')
            ->setFirstName($data->name)
            ->setContactNumber($data->code)
            ->setAccountNumber($data->code)
            ->setContactStatus(Contact::CONTACT_STATUS_ACTIVE)
            ->setEmailAddress($data->email)
            ->setTaxNumber('ABN')
            ->setDefaultCurrency('AUD');

        $contact = head($contact->save()->getElements());

        return $this->xeroClient->loadByGUID(Contact::class, $contact['ContactID']);
    }

}

Related Packages

dcodegroup/laravel-xero-oauth

Simple package which dcode uses to handle the connection to xero for all project...

33,686 1
directorytree/bartender

An opinionated way to authenticate users using Laravel Socialite.

25,038 285
laravel/socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

131,376,500 5,743
jenssegers/oauth

Laravel OAuth library based on Lusitanian/PHPoAuthLib

18,571 65
liaol/socialite-cn

Laravel wrapper around OAuth 1 & OAuth 2 libraries for Chinese Company.

1,961 47

Version History

Version Released PHP Laravel License
0.1.8 ^8.0|^8.1 ^8.0|^9.0 MIT
0.1.7 ^8.0|^8.1 ^8.0|^9.0 MIT
0.1.6 ^8.0|^8.1 ^8.0|^9.0 MIT
0.1.5 ^8.0|^8.1 ^8.0|^9.0 MIT
0.1.4 ^8.0|^8.1 ^8.0|^9.0 MIT