Untitled

 avatar
unknown
php
2 years ago
854 B
6
Indexable
<?php

Stripe::setApiKey($this->getParameter('stripe_secret'));
        $sessionParams = [
            'customer' => $this->getUser()->getCustomerId(),
            'line_items' => $products,
            'shipping_address_collection' => ['allowed_countries' => ['CH']],
            'mode' => 'payment',
            'success_url' => $this->generateUrl('app_beer_plan_success', [], UrlGeneratorInterface::ABSOLUTE_URL),
            'cancel_url' => $this->generateUrl('app_beer_plan_cancel', [], UrlGeneratorInterface::ABSOLUTE_URL),
        ];

        $session = Session::create($sessionParams);

        $stripeSessionUrl = $session->url;
        // with this return or the next one is the same result
        return new Response(null, 302, [
            'Location' => $stripeSessionUrl,
        ]);
        return new RedirectResponse($stripeSessionUrl);
Editor is loading...