Git Product home page Git Product logo

Comments (8)

tyteck avatar tyteck commented on September 14, 2024 1

in fact you already have what you need.
in spatie/laravel-stripe-webhooks/src/StripeSignatureValidator.php you have

class StripeSignatureValidator implements SignatureValidator
{
    public function isValid(Request $request, WebhookConfig $config): bool
    {
        if (! config('stripe-webhooks.verify_signature')) {
            return true;
        }
        ...
    }
}

seems to me all you need to do is set config(['stripe-webhooks.verify_signature' => false]); before running your test.

from laravel-stripe-webhooks.

freekmurze avatar freekmurze commented on September 14, 2024

Can you give an concrete example of a situation where you want to skip the signing secret verification?

from laravel-stripe-webhooks.

sylouuu avatar sylouuu commented on September 14, 2024

In testing environment you may want to skip this verification?

Just apply the middleware in staging and production.

In a local env you also have to deal with valet share and ngrok with unsupported SSL. So sending test webhooks from Stripe may be a little pain. In my case I use Postman to reach my webhook endpoint, but the signature verification stops me.

An option to apply the middleware based on a boolean (default true) would do the job.

Best

from laravel-stripe-webhooks.

freekmurze avatar freekmurze commented on September 14, 2024

You can set a non-https url in the Stripe dashboard.

from laravel-stripe-webhooks.

adriandmitroca avatar adriandmitroca commented on September 14, 2024

@sylouuu

Have you figured it out how to pass signature verification in your tests?

from laravel-stripe-webhooks.

sylouuu avatar sylouuu commented on September 14, 2024

@adriandmitroca Finally I didn't use this package. I've added myself a signature verification in production only.

from laravel-stripe-webhooks.

adriandmitroca avatar adriandmitroca commented on September 14, 2024

That's good to know, thanks. Anyway, if someone else will struggle with this in the future, my idea is to execute jobs separately in the tests to verify expected results.

There's no real need to test it any level higher, as those stuff is covered by package tests.

from laravel-stripe-webhooks.

pierrocknroll avatar pierrocknroll commented on September 14, 2024

I found a dirty solution for this...

Instead of using Route::stripeWebhooks('stripe/webhook');
Use your own controller : Route::post('stripe/webhook', 'WebhookController');

Then override the __construct method to use the VerifySignature middleware when you want :

use Spatie\StripeWebhooks\Middlewares\VerifySignature;
use Spatie\StripeWebhooks\StripeWebhooksController;

class WebhookController extends StripeWebhooksController
{
    public function __construct()
    {
        if (!in_array(app()->environment(), ['testing', 'local'])) {
            $this->middleware(VerifySignature::class);
        }
    }
}

from laravel-stripe-webhooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.