2019-07-16 11:58:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Bluesquare\BillingBundle\Service;
|
|
|
|
|
2019-07-16 14:44:22 +02:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
|
2019-07-16 11:58:38 +02:00
|
|
|
class BillingSrv
|
|
|
|
{
|
2019-07-16 14:44:22 +02:00
|
|
|
private $container;
|
|
|
|
|
|
|
|
public function __construct(ContainerInterface $container)
|
2019-07-16 11:58:38 +02:00
|
|
|
{
|
2019-07-16 14:44:22 +02:00
|
|
|
$this->container = $container;
|
|
|
|
}
|
|
|
|
public function createPurchase($items)
|
|
|
|
{
|
|
|
|
$apiKey = $this->container->getParameter('stripe_api_key_secret');
|
|
|
|
|
|
|
|
\Stripe\Stripe::setApiKey($apiKey);
|
2019-07-16 11:58:38 +02:00
|
|
|
|
2019-07-16 14:44:22 +02:00
|
|
|
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',
|
|
|
|
])
|
|
|
|
);
|
2019-07-16 11:58:38 +02:00
|
|
|
}
|
|
|
|
}
|