flux-se / sylius-stripe-plugin
Sylius Stripe plugin using Payment Request
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Type:sylius-plugin
Requires
- stripe/stripe-php: ^16.1
- sylius/core-bundle: ^2.0-dev
Requires (Dev)
- behat/behat: ^3.7
- dbrekelmans/bdi: ^1.2
- doctrine/data-fixtures: ^1.8
- doctrine/orm: ^2.20
- friends-of-behat/mink: ^1.9
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0
- friends-of-behat/mink-extension: ^2.5
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- lchrusciel/api-test-case: ^5.3
- mockery/mockery: ^1.6
- nyholm/psr7: ^1.8
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan-doctrine: ^1.0
- phpstan/phpstan-mockery: ^1.1
- phpstan/phpstan-strict-rules: ^1.0
- phpstan/phpstan-symfony: ^1.4
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^9.5
- robertfausk/behat-panther-extension: ^1.1
- spaze/phpstan-stripe: ^3.2
- sylius-labs/coding-standard: ^4.1
- sylius-labs/suite-tags-extension: ^0.2.0
- sylius/sylius: ^2.0-dev
- symfony/browser-kit: ^6.4|^7.1
- symfony/debug-bundle: ^6.4|^7.1
- symfony/dotenv: ^6.4|^7.1
- symfony/intl: ^6.4|^7.1
- symfony/runtime: ^6.4|^7.1
- symfony/web-profiler-bundle: ^6.4|^7.1
- theofidry/alice-data-fixtures: ^1.7
Suggests
- sylius/admin-bundle: Use the Sylius default admin
- sylius/api-bundle: Use the Sylius default API
- sylius/shop-bundle: Use the Sylius default front shop
This package is auto-updated.
Last update: 2025-01-29 17:34:40 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
- Install the plugin ()
composer require flux-se/sylius-stripe-plugin:dev-main
- Enable this plugin :
<?php # config/bundles.php return [ // ... FluxSE\SyliusStripePlugin\FluxSESyliusStripePlugin::class => ['all' => true], // ... ];
- Import configuration
# config/packages/flux_se_sylius_stripe.yaml imports: # ... - { resource: "@FluxSESyliusStripePlugin/config/config.yaml" }
Configuration
-
Go to the admin area.
-
Log in.
-
Click on the left menu item "CONFIGURATION > Payment methods".
-
Create a new payment method type "Stripe (Checkout)" or "Stripe (Web Elements)":
![Create a new payment method][docs-assets-create-payment-method]
-
The next chapter will explain how to fill the payment method creation form.
Payment Method configuration
A form will be displayed, fill-in the required fields :
1. The "code" field (ex: "my_shop_stripe_checkout").
💡 The code will be the
gateway name
, it will be necessary to build the right webhook URL later (see Webhook key section for more info).
2. Choose which channels this payment method will be affected to.
3. The gateway configuration (need info from here) :
![Gateway Configuration][docs-assets-gateway-configuration]
![Gateway Configuration][docs-assets-gateway-configuration-authorize]
📖 NOTE1: You can add as many webhook secret keys as you need here, however generic usage needs only one.
📖 NOTE2: the screenshot contains false test credentials.
4. Give to this payment method a display name (and a description) for each language you need.
Finally, click on the "Create" button to save your new payment method.
API keys
Get your publishable_key
and your secret_key
on your Stripe dashboard :
https://dashboard.stripe.com/test/apikeys
Webhook key
Got to :
https://dashboard.stripe.com/test/webhooks
Then create a new endpoint with those events:
The URL to fill is the route named sylius_payment_method_notify
with the {code}
param equal to the payment method code
, here is an example :
https://localhost/payment-methods/my_shop_stripe_checkout
📖 As you can see in this example the URL is dedicated to
localhost
, you will need to provide to Stripe a public host name to get the webhooks working.
📖 Use this command to know the exact structure of
sylius_payment_method_notify
routebin/console debug:router sylius_payment_method_notify
Test or dev environment
Webhooks are triggered by Stripe on their server to your server. If the server is into a private network, Stripe won't be allowed to reach your server.
Stripe provide an alternate way to catch those webhook events, you can use
Stripe cli
: https://stripe.com/docs/stripe-cli
Follow the link and install Stripe cli
, then use those command line to get
your webhook key :
First login to your Stripe account (needed every 90 days) :
stripe login
Then start to listen for the Stripe events (minimal ones are used here), forwarding request to your local server :
- Example with
my_shop_stripe_checkout
as payment method code:stripe listen \ --events checkout.session.completed,checkout.session.async_payment_failed,checkout.session.async_payment_succeeded,checkout.session.expired \ --forward-to https://localhost/payment/notify/unsafe/my_shop_stripe_checkout
- Example with
my_shop_stripe_web_elements
as payment method code:stripe listen \ --events payment_intent.canceled,payment_intent.succeeded \ --forward-to https://localhost/payment/notify/unsafe/my_shop_stripe_web_elements
💡 Replace --forward-to argument value with the right one you need.
When the command finishes, a webhook secret key is displayed, copy it to your Payment method configuration edit form in the Sylius admin.
⚠️ Using the command
stripe trigger checkout.session.completed
will always result in a500 error
, because the test object will not embed any usable metadata.
API (Sylius Api Platform)
@todo
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
Please see the License File for more information about licensing.