fix to redirect request on dev controller
This commit is contained in:
parent
5453a69312
commit
e08c583b72
|
@ -18,11 +18,4 @@ class BillingBundle extends Bundle
|
|||
{
|
||||
parent::build($container);
|
||||
}
|
||||
|
||||
// public function getContainerExtension()
|
||||
// {
|
||||
// if (null === $this->extension)
|
||||
// $this->extension = new StorageExtension();
|
||||
// return $this->extension;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -33,10 +33,7 @@ class BillingController extends AbstractController
|
|||
if ($event->type == 'checkout.session.completed') {
|
||||
$session = $event->data->object;
|
||||
|
||||
// Fulfill the purchase...
|
||||
if (file_put_contents("/tmp/return_stripe_session", json_encode($session)) !== false)
|
||||
return $this->json("OK", 200);
|
||||
return $this->json("KO", 500);
|
||||
return $this->redirectToRoute($this->container->getParameter('payment_confirmation_route'), $session);
|
||||
}
|
||||
|
||||
} catch(\UnexpectedValueException $e) {
|
||||
|
|
|
@ -16,6 +16,10 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('stripe_api_key_pub')->end()
|
||||
->scalarNode('stripe_api_key')->end()
|
||||
->scalarNode('stripe_webhook_key')->end()
|
||||
->scalarNode('stripe_success_url')->end()
|
||||
->scalarNode('stripe_cancel_url')->end()
|
||||
->scalarNode('payment_method')->end()
|
||||
->scalarNode('payment_confirmation_route')->end()
|
||||
->end()
|
||||
->end();
|
||||
|
||||
|
|
|
@ -13,25 +13,23 @@ class BillingSrv
|
|||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function createPurchase($items)
|
||||
public function createPurchase($user_email, $items, $cbFormatter)
|
||||
{
|
||||
$apiKey = $this->container->getParameter('stripe_api_key_secret');
|
||||
|
||||
\Stripe\Stripe::setApiKey($apiKey);
|
||||
|
||||
$line_items = [];
|
||||
|
||||
foreach ($items as $item) $line_items = $cbFormatter($item);
|
||||
|
||||
return (
|
||||
\Stripe\Checkout\Session::create([
|
||||
'payment_method_types' => ['card'],
|
||||
'line_items' => [[
|
||||
'name' => 'T-shirt',
|
||||
'description' => 'Comfortable cotton t-shirt',
|
||||
'images' => ['https://example.com/t-shirt.png'],
|
||||
'amount' => 500,
|
||||
'currency' => 'eur',
|
||||
'quantity' => 1,
|
||||
]],
|
||||
'success_url' => 'http://18d049f8.ngrok.io/redirected',
|
||||
'cancel_url' => 'http://18d049f8.ngrok.io/cancel',
|
||||
'customer_email' => $user_email,
|
||||
'payment_method_types' => $this->container->getParameter('payment_method'),
|
||||
'line_items' => $line_items,
|
||||
'success_url' => 'http://18d049f8.ngrok.io' . $this->container->getParameter('stripe_success_url'),
|
||||
'cancel_url' => 'http://18d049f8.ngrok.io' . $this->container->getParameter('stripe_cancel_url'),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue