Why doesn't handleWebhook Laravel Cashier?

0 like 0 dislike
Hello everyone, I want hooks to make from the Stripe, read the Doc
Routh scored like this Route::post('stripe/webhook', '\\App\\Http\\Controllers\\WebhookController@handleWebhook');
The controller extends base
use Laravel\\Cashier\\Http\\Controllers\\WebhookController as CashierController; WebhookController CashierController extends class {}

Try to test and create a stupid file
public function handleInvoicePaymentSucceeded($payload) { //http_response_code(201); //$subscription = Subscription::where('stripe_id', $payload); $path = 'screenshots/' . time() . '.txt'; $result = Storage::disk('public')->put($path, 'asdasd'); }

But nothing is created, but in response to 200 flies, already 40 minutes unable to find the cause, and if you make a stupid controller separate, does not extend CashierController, for example in the index method, the file is created perfectly
public function index() { $input = @file_get_contents('php://input'); //$event_json = json_decode($input); // Do something with $event_json $path = 'screenshots/' . time() . '.txt'; $result = Storage::disk('public')->put($path, 'asdasd'); http_response_code(200); // PHP 5.4 or greater }

I of course can use with their own controller and method, but the solution to the cashier like, and write something like no time has anyone come across?
by | 6 views

1 Answer

0 like 0 dislike
I kind of figured, had to go to class WebhookController,
and there goes the check
if (! $this->isInTestingEnvironment() && ! $this->eventExistsOnStripe($payload['id'])) { return; }

Accordingly, it is not performed, the method compares isInTestingEnvironment CASHIER_ENV c 'testing', it is prescribed in .env and it worked. Strange that such a dock has not specified...

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
asked Apr 14, 2019 by teodor7teodor7
0 like 0 dislike
1 answer
asked Apr 3, 2019 by fromrussia
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
33,901 users