generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
143 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Soap\LaravelOmise\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class OmiseAccountCommand extends Command | ||
{ | ||
public $signature = 'omise:account'; | ||
|
||
public $description = 'Retrieve account information from Omise API'; | ||
|
||
public function handle(): int | ||
{ | ||
$response = app('omise')->account()->retrieve(); | ||
|
||
if ($response instanceof \Soap\LaravelOmise\Omise\Error) { | ||
$this->error($response->getMessage()); | ||
|
||
return self::FAILURE; | ||
} | ||
$this->line('Account information retrieved successfully!'); | ||
$this->table(['Key', 'Value'], [ | ||
['ID', $response->id], | ||
['Email', $response->email], | ||
['Type', $response->type], | ||
['Name', $response->name], | ||
['Bank', $response->bank], | ||
['Description', $response->description], | ||
['Public Key', $response->public_key], | ||
['Secret Key', $response->secret_key], | ||
['Currency', $response->currency], | ||
['Location', $response->location], | ||
['Created', $response->created], | ||
]); | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Soap\LaravelOmise\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @see \Soap\LaravelOmise\LaravelOmise | ||
*/ | ||
class Treasurer extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'omise'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Soap\LaravelOmise; | ||
|
||
use Soap\LaravelOmise\Omise\Account; | ||
use Soap\LaravelOmise\Omise\Charge; | ||
use Soap\LaravelOmise\Omise\Customer; | ||
|
||
class Omise | ||
{ | ||
protected $config; | ||
|
||
public function __construct(OmiseConfig $omiseConfig) | ||
{ | ||
$this->config = $omiseConfig; | ||
} | ||
|
||
public function account() | ||
{ | ||
return new Account($this->config); | ||
} | ||
|
||
public function charge() | ||
{ | ||
return new Charge($this->config); | ||
} | ||
|
||
public function customer() | ||
{ | ||
return new Customer($this->config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Soap\LaravelOmise\Omise; | ||
|
||
use OmiseAccount; | ||
use Soap\LaravelOmise\OmiseConfig; | ||
|
||
class Account extends BaseObject | ||
{ | ||
private $omiseConfig; | ||
|
||
public function __construct(OmiseConfig $omiseConfig) | ||
{ | ||
$this->omiseConfig = $omiseConfig; | ||
} | ||
|
||
/** | ||
* Retrieve account information | ||
* | ||
* @return \Soap\LaravelOmise\Omise\Error|self | ||
*/ | ||
public function retrieve() | ||
{ | ||
try { | ||
$this->refresh(OmiseAccount::retrieve($this->omiseConfig->getPublicKey(), $this->omiseConfig->getSecretKey())); | ||
} catch (\Exception $e) { | ||
return new Error([ | ||
'code' => 'not_found', | ||
'message' => $e->getMessage(), | ||
]); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace Soap\LaravelOmise; | ||
|
||
class LaravelOmise | ||
class OmiseConfig | ||
{ | ||
protected static $url; | ||
|
||
|