-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I add service provider #36
Comments
hello @khunemz thank you for using Omise, can you give me more detail such as
so I can investigate your problem and give an exactly advise for you. |
Hi, I also working on Laravel project using this library as well but, I don't use service provider to make this library work with laravel, instead I use this very quick and dirty way. (I have a bad English skill, so bare with me)
namespace App\Services;
require_once dirname(__FILE__, 3).'/app/Omise/lib/Omise.php';
class Cashier
{
} And just call Omise's methods inside that class like this. namespace App\Services;
require_once dirname(__FILE__, 3).'/app/Omise/lib/Omise.php';
class Cashier
{
public static function charge(Array $data)
{
return \OmiseCharge::create($data);
}
} Now you can use your class as an interface (not sure what to call it) to communicate with Omise from anywhere in your Laravel app. For example : <?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Services\Cashier;
class User extends Authenticatable
{
/**
* Charge the customer.
*
* @param integer $amount
* @param string $card
* @return OmiseChargeObject
*/
public function charge($amount, $card)
{
return Cashier::charge([
'amount' => $amount,
'currency' => 'thb',
'customer' => $this->customerToken,
'card' => $card,
]);
}
} And that's it. Keep in mind that this is very quick and dirty way to do it. If you happen to find a better way, please share! |
@supershooter152 useful idea , i ll try it. (could I add the 'lib' folder into autoload psr-4 ?) @bank-omise I challenge you if you make Omise and Laravel (the world's most popular PHP framework) integrating more easily , you would solve an annoying problem in the world |
Haven't got around to try it yet, but my guess is that you could. |
@supershooter152 nope , it does not work . Instead it shows .
|
this is really quite ridiculous that you don't even namespace. you make a simple thing a big pain :-( |
@jrmadsen67 Hi, I understand. Also, for the adding namespace PR, now it's in review process, which is you can follow the PR at #47 Cheers, |
It's been 2 years and you guys still haven't namespaced this? Is this ever going to happen? |
Is this moving forward? |
don't hold your breathe, I've been asking for namespaces for about 16 months now |
We might as well fork this and add proper namespace ourselve now lol. |
It would seem like the best thing to do, people have been asking for namespaces for like 3-4 years now, let alone other basic features. Seems weird that a first party package can be so outdated and unmaintained. We gave up in the end and used another payment gateway. |
Great |
I am working on Laravel project . It throw error about the dash sign on file name 'omise-php' . How can I fix it ??
in the UsersController , you can notice that it hit the line number 6 and thrown error.
in the app.php
Error that was thrown
Moreover, in naming convention , I have never seen name with dash sign before . I have seen only camelCase , snake_case or PascalCase.
The text was updated successfully, but these errors were encountered: