Git Product home page Git Product logo

Comments (12)

aerni avatar aerni commented on September 14, 2024 1

Hmm, it looks like the where clause on json is not supported by all databases.

Can you try this implementation in your StripeWebhookProfile instead? This should work.

public function shouldProcess(Request $request): bool
{
    return WebhookCall::all()->where('payload.id', $request->get('id'))->isEmpty();
}

I'm not really sure if this is less performant than the first solution. But at least it should work with all databases without further changes.

from laravel-stripe-webhooks.

freekmurze avatar freekmurze commented on September 14, 2024

@aerni could you take a look at this?

from laravel-stripe-webhooks.

reganjohnson avatar reganjohnson commented on September 14, 2024

Other option to update column payload to type json- should work, but doing some testing to see.

ALTER TABLE webhook_calls ALTER COLUMN payload TYPE JSON USING payload::JSON;

from laravel-stripe-webhooks.

BrekiTomasson avatar BrekiTomasson commented on September 14, 2024

After altering the column to JSON on my Postgres database, I'm getting this instead:

[{"exception":"[object] (Illuminate\\Database\\QueryException(code: 22P05): SQLSTATE[22P05]:
 Untranslatable character: 7 ERROR:  unsupported Unicode escape sequence
DETAIL:  \\u0000 cannot be converted to text.

from laravel-stripe-webhooks.

ankurk91 avatar ankurk91 commented on September 14, 2024

Postgres allow to cast text to json on the fly, source

\Spatie\WebhookClient\Models\WebhookCall::whereRaw("payload::json->>'id' = 'id_sent_by_stripe'")->exists()

P.S. - This query is NOT compatible with MySql

It would be best if payload column can be converted to json type
https://github.com/spatie/laravel-webhook-client/blob/master/database/migrations/create_webhook_calls_table.php.stub#L10

from laravel-stripe-webhooks.

aerni avatar aerni commented on September 14, 2024

@freekmurze Can you take a look at this? I'm not really familiar with all the implications of a change like that.

from laravel-stripe-webhooks.

freekmurze avatar freekmurze commented on September 14, 2024

Personally I'm inclined to reverse the changes of the PR.

from laravel-stripe-webhooks.

aerni avatar aerni commented on September 14, 2024

I also think that it's probably a good idea to revert the changes in the Spatie\StripeWebhooks\StripeWebhookProfile. Then everyone can implement their own profile to suit their needs. But I wouldn't revert the option to add a custom profile.

from laravel-stripe-webhooks.

ankurk91 avatar ankurk91 commented on September 14, 2024

I made a quick fix in my project, like this

Update config file with

'profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class,

from laravel-stripe-webhooks.

freekmurze avatar freekmurze commented on September 14, 2024

I also think that it's probably a good idea to revert the changes in the Spatie\StripeWebhooks\StripeWebhookProfile.

Could you send a PR for that?

from laravel-stripe-webhooks.

spatie-bot avatar spatie-bot commented on September 14, 2024

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

from laravel-stripe-webhooks.

ankurk91 avatar ankurk91 commented on September 14, 2024

@freekmurze
The payload column is json type now in v3.x and is supported by most databases

https://github.com/spatie/laravel-webhook-client/blob/06ce01b3855df7007ed42d291f2096af0f7b80c0/database/migrations/create_webhook_calls_table.php.stub?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L16

Can you consider this PR again?
#87

This would be a great addition to prevent duplicate webhooks.
//cc @aerni

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.