ruudk/payment-stripe-bundle
Symfony bundle that adds Stripe as a payment provider to the ruudk/payment abstraction. Configure your Stripe API credentials, register the gateway as a service, and create charges through a consistent payment interface.
This is a Symfony2 bundle, not a Laravel package. If you're in a Laravel codebase, the practical first step is to not install it and instead read it as a reference implementation for wiring JMSPaymentCoreBundle to Stripe. For a Laravel app, use stripe/stripe-php directly or Laravel Cashier; for a legacy Symfony2 app, proceed below.
Minimal setup for the intended environment:
composer require ruudk/payment-stripe-bundle
Enable the bundle in app/AppKernel.php alongside its required dependency:
$bundles = [
new JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
new Ruudk\Payment\StripeBundle\RuudkPaymentStripeBundle(),
];
Configure the API credentials. The exact key names should be verified against DependencyInjection/Configuration.php, but expect something close to:
# app/config/config.yml
ruudk_payment_stripe:
api_key: "%stripe.secret_key%"
publishable_key: "%stripe.publishable_key%"
Where to look first, in order:
Resources/config/services.yml — the gateway service ID and its dependencies.DependencyInjection/Configuration.php — the real config schema.Gateway.php or similar) — this is where the Stripe API call is made.JMSPaymentCoreBundle docs/source — because this bundle is mostly an adapter; the payment instruction/payment state machine lives in JMS.First real use case: create a PaymentInstruction via JMS, obtain the Stripe gateway from the container, and charge a Stripe token created client-side with Stripe.js v2:
$instruction = new PaymentInstruction(
$amount,
'EUR',
'stripe'
);
$em->persist($instruction);
$em->flush();
$gateway = $container->get('ruudk_payment_stripe.gateway'); // verify service ID
$gateway->approveAndDeposit($instruction, $tokenFromStripeJs);
If you are on Laravel and only need Stripe, stop here: the day-to-day leverage of this repository is almost entirely as a historical reference.
Service-container wiring. The bundle is designed around Symfony DI. Inject the gateway service into your controller/service rather than constructing Stripe clients yourself:
class CheckoutController extends Controller
{
public function chargeAction(Request $request)
{
$gateway = $this->get('ruudk_payment_stripe.gateway');
// ...
}
}
JMS payment state machine. The intended workflow is JMSPaymentCoreBundle's, not Stripe's:
PaymentInstruction with amount, currency, and the stripe payment system name.Payment / CreditCard metadata via JMS.Do not try to bypass JMS and call the gateway directly with a raw amount; the bundle expects the instruction/payment context to be populated.
Client-side token flow. This bundle predates PaymentIntents and SCA. The pattern it supports is the old “token then charge” flow:
<form action="{{ path('checkout_charge') }}" method="post" id="payment-form">
<input type="text" data-stripe="number">
<input type="text" data-stripe="exp-month">
<input type="text" data-stripe="exp-year">
<input type="text" data-stripe="cvc">
<button type="submit">Pay</button>
</form>
<script src="https://js.stripe.com/v2/"></script>
<script>
Stripe.setPublishableKey('{{ stripe_publishable_key }}');
// submit handler -> Stripe.card.createToken(form, callback)
// inject returned token into a hidden input before POSTing
</script>
Testing pattern. Point the bundle at Stripe test keys and use the standard test card numbers. Because the gateway is a container service, you can replace it in the test container with a stub implementing the same interface, avoiding network calls in functional tests.
Integration tips.
config.yml; use Symfony parameters/environment-specific config.If you are porting to Laravel. Use the bundle as a map: the gateway class shows which Stripe SDK calls were used, and the JMS integration shows which fields were persisted. Reimplement that mapping against stripe/stripe-php PaymentIntents, and use Laravel's HTTP/queue infrastructure for webhooks. Do not attempt to run this Symfony2 bundle inside Laravel.
AppKernel, and old container semantics. It will not drop into a Symfony 5/6/7 application without a rewrite.Stripe_Charge rather than \Stripe\Charge. Modern stripe/stripe-php releases are namespaced and will conflict; check composer.json constraints before installing anything else Stripe-related.Stripe-Signature verification and idempotency keys are not part of this bundle's design. Any webhook endpoint you build around it must add those yourself.DependencyInjection/Configuration.php; a wrong key silently leaves the gateway unconfigured until the first charge fails.PaymentInstruction is in the expected state and the payment system name matches stripe.How can I help you explore Laravel packages today?