Skip to content

Commit

Permalink
Remove payload injection to the callback. It can be retrieved from th…
Browse files Browse the repository at this point in the history
…e injected callback instance --- Correct laravel service provider class name
  • Loading branch information
prinx committed Dec 1, 2020
1 parent e4220ff commit c89864a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function runCallbacks()
foreach ($this->callbacks as $callback) {
$callback = $callback->bindTo($this);

call_user_func_array($callback, [$this->getPayload(), $this]);
call_user_func_array($callback, [$this]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Laravel/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Txtpay\Laravel;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Txtpay\Callback;
use Txtpay\Contracts\CallbackInterface;
use Txtpay\Contracts\MobileMoneyInterface;
use Txtpay\MobileMoney;

class RepositoryServiceProvider extends ServiceProvider
class ServiceProvider extends BaseServiceProvider
{
/**
* Register services.
Expand Down
4 changes: 1 addition & 3 deletions tests/Unit/CallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ public function callbackFunction($type)
{
$test = $this;

return function ($payload, $callback) use ($test, $type) {
$test->assertTrue(is_array($payload), "Inject payload must be an array in the success callback in closure of type/code {$type}");
return function ($callback) use ($test, $type) {
$test->assertTrue($callback instanceof Callback, "Inject callback must be the callback instance in closure of type/code {$type}");
$test->assertSame($this, $callback, "\$this must be equal to \$callback in closure of type/code {$type}");
$test->assertEquals($payload, $callback->getPayload(), "Invalid payload passed to closure of type/code {$type}");
};
}
}

0 comments on commit c89864a

Please sign in to comment.