Laravel Cashier Failed Payments Testing
Hi,
I have a code for buying premium account:
try {
if($request->user()->subscribed('premium') || is_null($request->stripeToken))
return response()->json([
'message' => __('app.went_wrong')
], 200);
$request->user()->newSubscription('premium', 'plan_XXXXXXXX')->create($request->stripeToken);
return response()->json([
'message' => __('app.premium_bought')
], 200);
} catch (Exception $e) {
return response()->json([
'message' => __('app.went_wrong')
], 404);
}
And after executing this code with good stripeToken everything works fine and with credit cards that are not valid this also works good.
I have added webhook route
Route::post('stripe/webhook', '\Laravel\Cashier\Http\Controllers\WebhookController@handleWebhook');
I have also added all events in stripe to point to this route.
When i test buying premium account i have all Webhook attempts succeeded in Stripe dashboard.
How can i test if this webhook handling all works good and does cashier handle all webhook events by default? I don't know how to test situation where someone successfully buy premium account and after that dispute payment or refund it somehow (how can i revert their subscription from database)?
I hope you understand what i want. If you need more info please tell me.
Please or to participate in this conversation.