PHPackages                             miracode/stripe-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. miracode/stripe-bundle

ActiveSymfony-bundle[Payment Processing](/categories/payments)

miracode/stripe-bundle
======================

Symfony bundle to integrate Stripe PHP SDK. Ability to save Stripe objects in database using Doctrine.

v1.0.9(8y ago)1016.1k↓22%16[2 PRs](https://github.com/mirovskyi/stripe-bundle/pulls)MITPHPPHP &gt;=5.4.0

Since Nov 24Pushed 1y ago2 watchersCompare

[ Source](https://github.com/mirovskyi/stripe-bundle)[ Packagist](https://packagist.org/packages/miracode/stripe-bundle)[ RSS](/packages/miracode-stripe-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (29)Used By (0)

MiracodeStripeBundle
====================

[](#miracodestripebundle)

The MiracodeStripeBundle integrates Stripe PHP SDK to your Symfony project. Also you can configure bundle to save Stripe data in database. You are free to choose what Stripe objects will be stored.

This bundle tested on Symfony versions 2.7, 2.8, 3.1, 3.3, 3.4, 4.0. Compatible with Symfony &gt;=2.4

[![Build Status](https://camo.githubusercontent.com/238d11bf00c3d4b8b30e274f479c9a0ebcc41160f6f90c12ccca5531f3db455c/68747470733a2f2f7472617669732d63692e6f72672f6d69726f76736b79692f7374726970652d62756e646c652e7376673f6272616e63683d312e30)](https://travis-ci.org/mirovskyi/stripe-bundle)

Installation
------------

[](#installation)

To install this bundle, run the command below and you will get the latest stable version.

```
composer require miracode/stripe-bundle
```

Register bundle

```
// app/AppKernel.php
public function registerBundles()
{
  $bundles = array(
    // [...]
    new Miracode\StripeBundle\MiracodeStripeBundle(),
  );
}
```

For Symfony &gt;=3.4

```
// config/bundles.php
return [
    // [...]
    Miracode\StripeBundle\MiracodeStripeBundle::class => ['all' => true],
];
```

And set-up required configuration

```
# app/config/config.yml (or config/packages/miracode_stripe.yaml for Symfony >=3.4)
miracode_stripe:
    secret_key: "%stripe_secret_key%"
```

Usage
-----

[](#usage)

After minimal bundle configuration you can start using Stripe SDK.

For example create new customer:

```
$customer = \Stripe\Customer::create([
    'email' => 'newcustomer@example.com'
]);
```

#### Stripe Events

[](#stripe-events)

Add bundle routing configuration to enable Stripe webhooks handler

```
# app/config/routing.yml (or config/routing.yaml for Symfony >=3.4)
miracode_stripe:
    resource: '@MiracodeStripeBundle/Resources/config/routing.xml'
```

This will register route with url `/stripe/webhook`. You should add this webhook endpoint in Stripe Dashboard. Finally you will be able to listen all Stripe events.

For example for stripe event `charge.succeeded` webhook controller will dispatch event `stripe.charge.succeeded`.

Event Subscriber example:

```
// src/EventListener/StripeSubscriber.php

namespace App\EventListener;

use Miracode\StripeBundle\Event\StripeEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class StripeSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            'stripe.charge.succeeded' => 'onChargeSucceededEvent',
        ];
    }

    //[...]

    public function onChargeSucceededEvent(StripeEvent $event)
    {
        $stripeEvent = $event->getEvent(); //Stripe event object (instanceof \Stripe\Event)
        $charge = $event->getObjectData(); //Stripe charge object (instanceof \Stripe\Charge)
    }
}
```

#### Saving stripe data in database

[](#saving-stripe-data-in-database)

Now only Doctrine ORM driver is available.

In bundle there are abstract entity classes with orm mapping for main stripe objects:

- card: `Miracode\StripeBundle\Model\AbstractCardModel`
- charge: `Miracode\StripeBundle\Model\AbstractChargeModel`
- coupon: `Miracode\StripeBundle\Model\AbstractCouponModel`
- customer: `Miracode\StripeBundle\Model\AbstractCustomerModel`
- invoice: `Miracode\StripeBundle\Model\AbstractInvoiceModel`
- plan: `Miracode\StripeBundle\Model\AbstractPlanModel`
- refund: `Miracode\StripeBundle\Model\AbstractRefundModel`
- subscription: `Miracode\StripeBundle\Model\AbstractSubscriptionModel`

Use this abstract classes to create entities. For example charge entity class:

```
// src/Entity/Charge.php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Miracode\StripeBundle\Model\AbstractChargeModel;

/**
 * @ORM\Entity()
 * @ORM\Table(name="stripe_charge")
 */
class Charge extends AbstractChargeModel
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     *
     * @var int
     */
    protetced $id;
}
```

You must also specify entity classes in the bundle configuration

```
# app/config/config.yml (or config/packages/miracode_stripe.yaml for Symfony >=3.4)
miracode_stripe:
    #...
    database:
        model:
            charge:   'App\Entity\Charge'   #To store stripe charges
            card:     'App\Entity\Card'     #To store stripe cards
            customer: 'App\Entity\Customer' #To store stripe customers
            #...
```

After adding entity classes in bundle configuration you can use model manager service to store stripe data.

For example:

```
//Create new customer
$customer = \Stripe\Customer::create([
    'email' => 'newcustomer@example.com'
]);

//Create new card for customer
$card = $customer->sources->create([
    'source' => [
        'object' => 'card',
        'exp_month' => '12',
        'exp_year' => '2020',
        'number' => '4111111111111111',
        'cvc' => '123'
    ]
]);

//Create payment with customer card
$charge = \Stripe\Charge::create([
    'customer' => $customer->id,
    'amount' => 100,
    'currency' => 'usd',
    'source' => $card->id
]);

//Save stripe objects in database
//You can remove this code and entities will be created automatically by webhooks handler
//(see Miracode\StripeBundle\EventListener\StripeEventSubscriber)
$this->get('miracode_stripe.model_manager')->save($customer);     //Don't flush changes. Return new Customer entity object.
$this->get('miracode_stripe.model_manager')->save($card);         //Don't flush changes. Return new Card entity object.
$this->get('miracode_stripe.model_manager')->save($charge, true); //FLUSH changes in DB. Return new Charge entity object.
```

If you enabled webhooks handling (described above), you can omit using model manager service to save objects data. There is event subscriber that will save/update/remove configured entities by stripe events automatically.

**Note** some data can be deleted by webhooks handler. If you want to use safe delete technique, implement interface `Miracode\StripeBundle\Model\SafeDeleteModelInterface` in your entity classes. Also you can use trait `Miracode\StripeBundle\Model\Traits\SafeDeleteTrait` for easy interface implementation.

License
-------

[](#license)

This bundle is released under the MIT license. See the included [LICENSE](LICENSE) file for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 91.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~5 days

Total

28

Last Release

3010d ago

Major Versions

v0.9.9.2 → v1.0.02018-01-03

PHP version history (2 changes)v0.9.1PHP &gt;=5.3.0

v1.0.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7af7f00f43dd33f94f80f1ba50d9e1fd928f50ecbe088348bd6ed27fc95e620?d=identicon)[miracode](/maintainers/miracode)

---

Top Contributors

[![mirovskyi](https://avatars.githubusercontent.com/u/1011263?v=4)](https://github.com/mirovskyi "mirovskyi (42 commits)")[![DougHayward](https://avatars.githubusercontent.com/u/4302775?v=4)](https://github.com/DougHayward "DougHayward (2 commits)")[![Nightbr](https://avatars.githubusercontent.com/u/4228646?v=4)](https://github.com/Nightbr "Nightbr (2 commits)")

---

Tags

phpsymfonybundlestripepaymentwebpayment

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/miracode-stripe-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/miracode-stripe-bundle/health.svg)](https://phpackages.com/packages/miracode-stripe-bundle)
```

###  Alternatives

[payum/payum-bundle

One million downloads of Payum already! Payum offers everything you need to work with payments. Check more visiting site.

59510.3M40](/packages/payum-payum-bundle)[fpt/stripe-bundle

Stripe bundle for Symfony 5.4 / 6 / 7

1521.2k](/packages/fpt-stripe-bundle)[paymentsuite/paymentsuite

PaymentSuite is an easy implementation for lot of Payment Methods for Symfony projects

2615.5k2](/packages/paymentsuite-paymentsuite)[luyadev/luya-module-payment

LUYA Payment allows you to integrate payments in a safe and fast way. The module take care of all the provider required steps (call, create, success, abort, etc.) and provides all the informations for your store.

1012.1k](/packages/luyadev-luya-module-payment)[paymentsuite/stripe-bundle

Stripe PaymentSuite Component

105.0k](/packages/paymentsuite-stripe-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
