stripe / stripe-php

PHP library for the Stripe API.
https://stripe.com
MIT License
3.75k stars 848 forks source link

Stripe error: Unexpected error communicating with Stripe. #1746

Closed saram-aman closed 2 months ago

saram-aman commented 2 months ago

Describe the bug

Stripe error: Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com.\n\n(Network error [errno 77]: error setting certificate verify locations:\n CAfile: /var/www/html/application/third_party/vendor/stripe/stripe-php/data/ca-certificates.crt\n CApath: /etc/ssl/certs)

To Reproduce

$stripe = new \Stripe\StripeClient($stripeSecretKey); $customer = $stripe->customers->create([ 'description' => 'Customer for ' . $apiData['data']['email'], ], [ 'idempotency_key' => uniqid() ]); $source = $stripe->sources->create([ 'type' => 'card', 'card' => [ 'number' => '4242424242424242', 'exp_month' => '12', 'exp_year' => '2024', 'cvc' => '123', ], ]); $stripe->customers->createSource($customer->id, [ 'source' => $source->id ]);

Expected behavior

Should be success stripe connection while calling api

Code snippets

No response

OS

Linux

PHP version

PHP 8.1

Library version

15.1

API version

2024-08-08

Additional context

No response

remi-stripe commented 2 months ago

Github issues are limited to bugs with the stripe-php SDK itself. This looks more like a configuration issue on your end with your installation. A common cause for this error is that the data/ca-certificates.crt file is not included in your stripe-php installation or it has file permissions that is preventing your code from accessing it. Once you have done this, you should be fine (and the SSL handshake between your server and our API should work fine).

If you have follow up questions, please work with our support team instead for 1:1 help though this would be more a question for host provider.