Q:

Should processing logic of STRIPE be in the Laravel controller or in the validator?

I am a newcomer to laravel. I have a controller ProductController like this
    public function buy(Request $request, User $user) {

    \Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxxx");

    $token = $_POST['stripeToken'];

    $charge = \Stripe\Charge::create([
        'amount' => 100,
        'currency' => 'aud',
        'description' => 'Example charge',
        'source' => $token,
    ]);

    if ($charge->status === "succeeded") {
        //-- Processing... --//
    }

I would like to ask the more appropriate design style, should I put the part of STTRIE in other places, such as the validator.
If yes, it is to make a rule and a request than verify it in the validator ?
Can someone tell me how to use the rule in the request?

A:

Creating a Stripe charge is not request validation. It's an API call to Stripe. So, it should definitely not stay in the validator.
You can have this logic in a controller for small apps, but for medium/large scale apps with abstraction (e.g. if you want to have the option later to change the payment provider from Stripe to say Braintree), it should be in a service class.
Also, never use $_POST directly. Use $request->input instead. As a thumb rule, if you have 2 ways to do something in code, always use the way that implements higher level libraries (libraries > then framework > then core PHP).

