Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Error, no Exception Message #214

Open
s7thamon opened this issue Jun 1, 2022 · 5 comments · May be fixed by #215
Open

400 Error, no Exception Message #214

s7thamon opened this issue Jun 1, 2022 · 5 comments · May be fixed by #215

Comments

@s7thamon
Copy link

s7thamon commented Jun 1, 2022

I'm creating a checkout session with a large number of line_items in a try/catch. Normally an exception message is gathered if there are any issues but in this instance when there are a large number of line_items, somewhere around 40, no exception message is captured. Trying to figure out if this is an issue on Stripe's end or not. Nothing in their documentation indicates there is any limit there (https://stripe.com/docs/js/checkout/redirect_to_checkout).

Exception::__construct(): Passing null to parameter #1 ($message) of type string is deprecated in /vendor/cartalyst/stripe/src/Exception/Handler.php on line 125

try {
    $paymentMethod = \Stripe::checkout()->sessions()->create([
        'payment_method_types' => ['card'],
        'mode' => 'payment',
        'payment_intent_data' => [
            'description' => $description,
            'metadata' => $metadata,
            'receipt_email' => $this->selectedCustomerEmail,
        ],
        'customer_email' => $this->selectedCustomerEmail,
        'line_items' => $invoices,
    ]);

} catch (\Exception $exception) {
    Log::error('Backend: ' . $exception->getMessage());
    return $exception->getCode();
}
@s7thamon
Copy link
Author

s7thamon commented Jun 2, 2022

According to Stripe support "The limit is 100 line items". I'm well under that, hmm.

@brunogaspar
Copy link
Member

Thanks for the report.

I'll try to reproduce the issue and adjust the error handler so it at least gives a better output.

For the limit itself, if that's true, and you're under the limit, then something is off somewhere (wouldn't surprise me to be on Stripe end to be honest).

@s7thamon
Copy link
Author

s7thamon commented Jun 6, 2022

After some back and forth with Stripe, they're not seeing anything. I can verify the request is making it out to their API on my end via tcpdump:

08:17:30.296098 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [S], seq 1679654649, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 1312124196 ecr 0,sackOK,eol], length 0
08:17:30.314977 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], ack 1355576128, win 2058, options [nop,nop,TS val 1312124215 ecr 2839958387], length 0
08:17:30.387465 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [P.], seq 0:517, ack 1, win 2058, options [nop,nop,TS val 1312124287 ecr 2839958387], length 517
08:17:30.406276 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], ack 2897, win 2013, options [nop,nop,TS val 1312124306 ecr 2839958478], length 0
08:17:30.406308 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], ack 3509, win 2004, options [nop,nop,TS val 1312124306 ecr 2839958478], length 0
08:17:30.407532 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [P.], seq 517:610, ack 3509, win 2048, options [nop,nop,TS val 1312124307 ecr 2839958478], length 93
08:17:30.425564 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], ack 3560, win 2047, options [nop,nop,TS val 1312124325 ecr 2839958497], length 0
08:17:30.426141 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 610:2058, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426145 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 2058:3506, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426147 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 3506:4954, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426148 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 4954:6402, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426149 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 6402:7850, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426151 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 7850:9298, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426152 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 9298:10746, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426153 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], seq 10746:12194, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1448
08:17:30.426185 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [P.], seq 12194:13282, ack 3560, win 2048, options [nop,nop,TS val 1312124325 ecr 2839958497], length 1088
08:17:30.542788 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [.], ack 4087, win 2039, options [nop,nop,TS val 1312124443 ecr 2839958615], length 0
08:17:30.552255 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [P.], seq 13282:13313, ack 4087, win 2048, options [nop,nop,TS val 1312124452 ecr 2839958615], length 31
08:17:30.553865 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [F.], seq 13313, ack 4087, win 2048, options [nop,nop,TS val 1312124454 ecr 2839958615], length 0
08:17:30.570550 IP 192.168.1.247.54508 > api-34-200-27-109.stripe.com.https: Flags [F.], seq 13313, ack 4088, win 2048, options [nop,nop,TS val 1312124470 ecr 2839958642], length 0

Their response back is:

Unfortunately, this would indicate that we’re not receiving/processing these requests. This means that they're likely failing due to networking or other code failing issues on your end.
We can recommend a few troubleshooting steps:

Ensure that our API is reachable from your server/network [0].
Confirm that it’s not your local function/code that’s returning the 400 error -- it could be that your PHP function which calls the Stripe API is actually throwing an error before it sends the API requests, and it's not caught properly.

As there’s no other logs on your Stripe account other than the ones displayed on your dashboard, we don't have more insight on this situation.

@s7thamon
Copy link
Author

We had a client that needed to push some large charges through. Don't know if it helps this issue out but using the official Stripe php sdk directly does not have the problem.

$stripe = new \Stripe\StripeClient(config('services.stripe.secret'));
$paymentMethod = $stripe->checkout->sessions->create([]);

@brunogaspar
Copy link
Member

Hello again @s7thamon

I've debugged this and i understand the cause of the problem.

Pretty much the problem is that, the current way of sending the payload is through the query string (which is supported by Stripe), so this is of course reaching the limit of the size of the entire url, so it's not related to Stripe in any way.

I'll try to address this limitation in the next few days, when i have a bit more time to properly look into this :)

Thanks again for the report and further insights!

brunogaspar added a commit that referenced this issue Jun 16, 2022
@brunogaspar brunogaspar linked a pull request Jun 16, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants