Ad

Does Laravel Cashier Handle Race Condition?

Does Laravel Cashier handle race condition?

//code to charege some amount

$stripeCharge = $user->charge(100);

The call could succeed, but the connection break before the stripe server can tell about it.

Now in this case, How does Cashier Package handle this?

Ad

Answer

Stripe allows you to handle such scenarios by passing idempotency keys on your requests.

The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response.

https://stripe.com/docs/api/idempotent_requests?lang=php

From the looks of it, this feature is not yet implemented in Cashier, see the open issue

Support Idempotency Option

https://github.com/laravel/cashier/issues/492

Ad
source: stackoverflow.com
Ad