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

dev-main / 1.0.x-dev 2025-01-29 17:34 UTC

This package is auto-updated.

Last update: 2025-01-29 17:34:40 UTC


README

Latest Version on Packagist Total Downloads
Software License Build Status

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation

  1. Install the plugin ()
    composer require flux-se/sylius-stripe-plugin:dev-main
  2. Enable this plugin :
    <?php
    
    # config/bundles.php
    
    return [
        // ...
        FluxSE\SyliusStripePlugin\FluxSESyliusStripePlugin::class => ['all' => true],
        // ...
    ];
  3. 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 route

bin/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 :

  1. 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
  2. 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 a 500 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.