stripe-bundle icon indicating copy to clipboard operation
stripe-bundle copied to clipboard

$stripeApiKeyhas no type-hint

Open nigelmann opened this issue 7 years ago • 2 comments

Hey,

I working on a symfony 4 project and when i wanted to integrate the bundle. when i try to create a customer i have this

Uncaught PHP Exception Symfony\Component\DependencyInjection\Exception\RuntimeException: "Cannot resolve argument $stripeClient of "App\Controller\User\RegisterPaymentMethodController()": Cannot autowire service "Flosch\Bundle\StripeBundle\Stripe\StripeClient": argument "$stripeApiKey" of method "__construct()" has no type-hint, you should configure its value explicitly." at /Users/simonackermann/Sites/courses/symfony/champeryNb/var/cache/dev/ContainerOspQEUr/getStripeClientService.php line 9

I realy don't know what to do. here is all my code; https://github.com/simonackermann/private-rent/tree/feature/creditCardPayment

Thanks in advanc for the help

nigelmann avatar Jul 09 '18 15:07 nigelmann

Hello @simonackermann , it seems that you're version of Symfony cannot autowire scalar arguments: you should configure its value explicitly.

http://symfony.com/doc/master/service_container.html#manually-wiring-arguments

I have not used this bundle on a Symfony 4 project myself, so I cannot tell you why exactly the configuration inside your own flosch_stripe.yaml file does not work, but I guess this change should solve your problem:

# config/services.yaml
Flosch\Bundle\StripeBundle\Stripe\StripeClient:
    autowire: true
    autoconfigure: true
    lazy: true
    arguments:
        $stripeApiKey: '%your_stripe_api_key%' # maybe try '%flosch_stripe.stripe_api_key%'?

flo-sch avatar Jul 09 '18 23:07 flo-sch

@flo-sch thank you very much I don't have this error anymore.

However when i use the createCustomer method i get this error.

[critical] Uncaught PHP Exception Stripe\Error\ApiConnection: "Unexpected error communicating with Stripe.  If this problem persists, let us know at [email protected].

(Network error [errno 35]: Server aborted the SSL handshake)" at /Users/simonackermann/Sites/courses/symfony/champeryNb/vendor/stripe/stripe-php/lib/HttpClient/CurlClient.php line 250

The Exception is in the stripe-php lib but maybe you have a clue on what the probleme is.

nigelmann avatar Jul 10 '18 19:07 nigelmann