{"id":14983729,"url":"https://github.com/flo-sch/stripe-bundle","last_synced_at":"2025-04-10T19:04:32.236Z","repository":{"id":62505753,"uuid":"65122259","full_name":"flo-sch/stripe-bundle","owner":"flo-sch","description":"A symfony \u003e= 3 integration for the Stripe PHP SDK","archived":false,"fork":false,"pushed_at":"2020-11-25T16:55:49.000Z","size":36,"stargazers_count":29,"open_issues_count":8,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-15T22:34:54.196Z","etag":null,"topics":["php","stripe-bundle","stripe-sdk","symfony-bundle","symfony3"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flo-sch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-07T07:54:52.000Z","updated_at":"2021-10-18T06:02:12.000Z","dependencies_parsed_at":"2022-11-02T12:45:39.883Z","dependency_job_id":null,"html_url":"https://github.com/flo-sch/stripe-bundle","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-sch%2Fstripe-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-sch%2Fstripe-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-sch%2Fstripe-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flo-sch%2Fstripe-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flo-sch","download_url":"https://codeload.github.com/flo-sch/stripe-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248279196,"owners_count":21077406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","stripe-bundle","stripe-sdk","symfony-bundle","symfony3"],"created_at":"2024-09-24T14:07:50.427Z","updated_at":"2025-04-10T19:04:32.214Z","avatar_url":"https://github.com/flo-sch.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flosch/stripe-bundle\nA symfony \u003e= 3 integration for the Stripe PHP SDK\n\n## ⚠️ IMPORTANT: Before you use this bundle... ⚠️\n\nSome (rather big!) changes are [coming quite soon](https://support.stripe.com/questions/strong-customer-authentication-sca-enforcement-date) affecting online payment solutions in Europe, impacting the Stripe APIs used by this bundle.\n[Read this issue carefully](https://github.com/flo-sch/stripe-bundle/issues/15) before using this bundle.\n\n## Description\n\nThis bundle allow you to manipulate the stripe SDK as a Symfony service,\nPlus some helpers to use different Stripe API notions such as Stripe Connect or the Subscriptions API.\n\n**NOTE** : The master branch, and 1.*.* releases target Symfony 3. If you are using Symfony 4, please use the 2.0.0 branch and the 2.*.* releases of this bundle.\n\n### Installation\nTo install this bundle, run the command below and you will get the latest version from [Packagist][3].\n\n``` bash\ncomposer require flosch/stripe-bundle\n```\n\nLoad required bundles in AppKernel.php:\n\n``` php\n// app/AppKernel.php\npublic function registerBundles()\n{\n  $bundles = array(\n    // [...]\n    new Flosch\\Bundle\\StripeBundle\\FloschStripeBundle()\n  );\n}\n```\n\nAnd set-up the required configuration\n\n``` yaml\n# app/config/config.yml\nflosch_stripe:\n    stripe_api_key: \"%stripe_api_key%\" # The Stripe API key can be added as a symfony parameter\n```\n\n### Usage\n\nThen, it is possible to use this service from inside a controller\n\n``` php\n$stripeClient = $this-\u003eget('flosch.stripe.client');\n```\n\nThe StripeClient php class extends the default Stripe PHP SDK class, allowing you to do anything that this SDK can do.\nPlus, it will automatically be authenticated with your Stripe API Key, which you do not have to worry about at all.\n\n\n### Extends the client\n\nI will always be open to PR in order to update this project,\nHowever if you wish to add your own custom helpers, you can easily extend it yourself, for instance :\n\n``` php\n\u003c?php // src/YourNamespace/YourProject/Stripe/StripeClient.php\n\nnamespace YourNamespace\\YourProject\\Stripe;\n\nuse Flosch\\Bundle\\StripeBundle\\Stripe\\StripeClient as BaseStripeClient;\n\nclass StripeClient extends BaseStripeClient\n{\n    public function __construct($stripeApiKey = '')\n    {\n        parent::__construct($stripeApiKey);\n\n        return $this;\n    }\n\n    public function myOwnMethod()\n    {\n        // Do what you want here...\n    }\n}\n```\n\nThen register your extension as a service, and use it.\n\n\u003e http://symfony.com/doc/current/service_container/3.3-di-changes.html\n\n``` yaml\nservices:\n    YourNamespace\\YourProject\\Stripe\\StripeClient:\n        autowire: true\n        autoconfigure: true\n        lazy: true\n\n    my.stripe.client:\n        alias: YourNamespace\\YourProject\\Stripe\\StripeClient\n```\n\n``` php\npublic function indexAction()\n{\n    // Retrieve it from the container with the old-school getter\n    $stripeClient = $this-\u003eget('my.stripe.client');\n}\n\npublic function indexAction(\\YourNamespace\\YourProject\\Stripe\\StripeClient $stripeClient)\n{\n    // Or inject it in your controllers if you use autowiring\n    // Then you're ready to go...\n}\n```\n\n### Helpers\n\nThe StripeClient currently offers four helper methods :\n\n###### Retrieve a Coupon by its ID\n\n``` php\n/**\n * $planId (string)         : The existing Coupon ID (the one you define in the Stripe dashboard)\n */\n$coupon = $stripeClient-\u003eretrieveCoupon($planId);\n```\n\n###### Retrieve a Plan by its ID\n\n``` php\n/**\n * $planId (string)         : The existing Plan ID (the one you define in the Stripe dashboard)\n */\n$plan = $stripeClient-\u003eretrievePlan($planId);\n```\n\n###### Retrieve a Customer by its ID\n\n``` php\n/**\n * $customerId (string)         : The existing Customer ID\n */\n$customer = $stripeClient-\u003eretrieveCustomer($customerId);\n```\n\n###### Retrieve a Charge by its ID\n\n``` php\n/**\n * $chargeId (string)         : The existing Charge ID\n */\n$charge = $stripeClient-\u003eretrieveCharge($chargeId);\n```\n\n###### Create a new customer\n\n``` php\n/**\n * $paymentToken (string)   : The payment token obtained using the Stripe.js library\n * $customerEmail (string)  : The customer e-mail address\n */\n$stripeClient-\u003ecreateCustomer($paymentToken, $customerEmail);\n```\n\n###### Create and subscribe a new customer to an existing plan\n\n``` php\n/**\n * $planId (string)         : The existing Plan ID (the one you define in the Stripe dashboard)\n * $paymentToken (string)   : The payment token obtained using the Stripe.js library\n * $customerEmail (string)  : The customer e-mail address\n * $couponId (string|null)  : An optional coupon ID\n */\n$stripeClient-\u003esubscribeCustomerToPlan($planId, $paymentToken, $customerEmail, $couponId);\n```\n\n###### Subscribe an existing customer to an existing plan\n\n``` php\n/**\n * $customerId (string)     : The existing Customer ID\n * $planId (string)         : The existing Plan ID (the one you define in the Stripe dashboard)\n * $parameters (array)      : An optional array of additional parameters\n */\n$stripeClient-\u003esubscribeExistingCustomerToPlan($customerId, $planId, [\n    'coupon'        =\u003e 'TEST',\n    'tax_percent'   =\u003e 19.6\n]);\n```\n\n###### Create a charge (to a platform, or a connected Stripe account)\n\n``` php\n/**\n * $chargeAmount (int)              : The charge amount in cents, for instance 1000 for 10.00 (of the currency)\n * $chargeCurrency (string)         : The charge currency (for instance, \"eur\")\n * $paymentToken (string)           : The payment token obtained using the Stripe.js library\n * $stripeAccountId (string|null)   : (optional) The connected string account ID, default null (--\u003e charge to the platform)\n * $applicationFee (int)            : The amount of the application fee (in cents), default to 0\n * $chargeDescription (string)      : (optional) The charge description for the customer\n */\n$stripeClient-\u003ecreateCharge($chargeAmount, $chargeCurrency, $paymentToken, $stripeAccountId, $applicationFee, $chargeDescription);\n```\n\n\n###### Refund a Charge\n\n``` php\n/**\n * $chargeId (string)           : The Stripe charge ID (returned by Stripe when you create a charge)\n * $refundAmount (int)          : The charge amount in cents (if null, the whole charge amount will be refunded)\n * $metadata (array)            : additional informations about the refund, default []\n * $reason (string)             : The reason of the refund, either \"requested_by_customer\", \"duplicate\" or \"fraudulent\"\n * $refundApplicationFee (bool) : Wether the application_fee should be refunded aswell, default true\n * $reverseTransfer (bool)      : Wether the transfer should be reversed (when using Stripe Connect \"destination\" parameter on charge creation), default false\n * $stripeAccountId (string)    : (optional) TheStripe account on which the charge has been made (Stripe Connect), default null (--\u003e refund by the platform)\n */\n$stripeClient-\u003erefundCharge($chargeId, $refundAmount, $metadata, $reason, $refundApplicationFee, $reverseTransfer, $stripeAccountId);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflo-sch%2Fstripe-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflo-sch%2Fstripe-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflo-sch%2Fstripe-bundle/lists"}