flo-sch / stripe-bundle

A symfony >= 3 integration for the Stripe PHP SDK
MIT License
28 stars 10 forks source link

$stripeApiKeyhas no type-hint #11

Open nigelmann opened 6 years ago

nigelmann commented 6 years ago

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

flo-sch commented 6 years ago

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%'?
nigelmann commented 6 years ago

@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 support@stripe.com.

(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.