apioo / fusio

Open source API management platform
https://www.fusio-project.org
Apache License 2.0
1.85k stars 221 forks source link

Install fusio/adapter-stripe error. It looks like version not compatible. How can I solve it? #504

Open cococonuts opened 1 year ago

cococonuts commented 1 year ago

sudo composer require fusio/adapter-stripe:* Do not run Composer as root/super user! See https://getcomposer.org/root for details Continue as root/super user [yes]? yes ./composer.json has been updated Running composer update fusio/adapter-stripe Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.

Problem 1

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

chriskapp commented 1 year ago

Hi @cococonuts could you explicit try to use the version v5.2.0 i.e. with composer require fusio/adapter-stripe ^5.0 we use this version also in our docker image, at our docker image we still use PHP 8.0. In general we are currently also working on a new release where we update many dependencies and we will then also update the docker PHP version.

cococonuts commented 1 year ago

hi @chriskapp I got the same issue with "sudo composer require fusio/adapter-stripe ^5.0". Is it because I installed php 8.2?

I tried this tricky method, install adapter-strip with gnore-platform-reqs option. It works and I can config stripe with API key in fusio admin. "composer require fusio/adapter-stripe ^5.0 --ignore-platform-reqs"

However, when I purchase subscription in developer app, it goes to error 500. What else should I install for stripe payment? POST | https://myhost.com/index.php/consumer/payment/stripe/checkout return 500

image
cococonuts commented 1 year ago

Do you have dev document for how to debug the router/issue in fusio?

chriskapp commented 1 year ago

Hi @cococonuts, could you check the PHP error logs, there should be an error regarding this issue, I would also assume that this is probably a problem regarding PHP 8.2

cococonuts commented 1 year ago

I just start to use PHP, so not very familiar with PHP debugging. I have no idea where is PHP log. Is the error.log in the /var/log/nginx/?

I also tried to modify /etc/php/8.2/fpm/php.ini and /etc/php/8.2/cli/php.ini to make the error_log=/var/log/nginx/error.log But the it is still empty in error.log.

cococonuts commented 1 year ago

@chriskapp , I got the error log. Do you have any thoughts? Thank you :) I find the latest source code of fusio-engine in github, getDomain exists but there is no getDomain in my version. How can I update the fusio-engine?

psx.ERROR: Call to undefined method Fusio\Engine\Payment\CheckoutContext::getDomain() {"file":"/var/www/fusio/html/vendor/fusio/adapter-stripe/src/Provider/Stripe.php","line":84,"trace":"

0 /var/www/fusio/html/vendor/fusio/impl/src/Service/Payment.php(87): Fusio\Adapter\Stripe\Provider\Stripe->checkout()\n

1 /var/www/fusio/html/vendor/fusio/impl/src/Consumer/Action/Payment/Checkout.php(54): Fusio\Impl\Service\Payment->checkout()\n

2 /var/www/fusio/html/vendor/fusio/engine/src/Processor.php(77): Fusio\Impl\Consumer\Action\Payment\Checkout->handle()\n

3 /var/www/fusio/html/vendor/fusio/impl/src/Service/Action/Invoker.php(77): Fusio\Engine\Processor->execute()\n

4 /var/www/fusio/html/vendor/fusio/impl/src/Controller/SchemaApiController.php(154): Fusio\Impl\Service\Action\Invoker->invoke()\n

5 /var/www/fusio/html/vendor/fusio/impl/src/Controller/SchemaApiController.php(109): Fusio\Impl\Controller\SchemaApiController->executeAction()\n

6 /var/www/fusio/html/vendor/psx/framework/src/Controller/ControllerAbstract.php(135): Fusio\Impl\Controller\SchemaApiController->doPost()\n

7 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): PSX\Framework\Controller\ControllerAbstract->handle()\n

8 /var/www/fusio/html/vendor/fusio/impl/src/Controller/Filter/Logger.php(61): PSX\Http\Filter\FilterChain->handle()\n

9 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): Fusio\Impl\Controller\Filter\Logger->handle()\n

10 /var/www/fusio/html/vendor/fusio/impl/src/Controller/Filter/RequestLimit.php(61): PSX\Http\Filter\FilterChain->handle()\n

11 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): Fusio\Impl\Controller\Filter\RequestLimit->handle()\n

12 /var/www/fusio/html/vendor/fusio/impl/src/Controller/Filter/Authentication.php(59): PSX\Http\Filter\FilterChain->handle()\n

13 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): Fusio\Impl\Controller\Filter\Authentication->handle()\n

14 /var/www/fusio/html/vendor/fusio/impl/src/Controller/Filter/AssertMethod.php(85): PSX\Http\Filter\FilterChain->handle()\n

15 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): Fusio\Impl\Controller\Filter\AssertMethod->handle()\n

16 /var/www/fusio/html/vendor/psx/http/src/Filter/UserAgentEnforcer.php(43): PSX\Http\Filter\FilterChain->handle()\n

17 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): PSX\Http\Filter\UserAgentEnforcer->handle()\n

18 /var/www/fusio/html/vendor/psx/http/src/Filter/CORS.php(86): PSX\Http\Filter\FilterChain->handle()\n

19 /var/www/fusio/html/vendor/psx/http/src/Filter/FilterChain.php(79): PSX\Http\Filter\CORS->handle()\n

20 /var/www/fusio/html/vendor/psx/framework/src/Loader/Loader.php(91): PSX\Http\Filter\FilterChain->handle()\n

21 /var/www/fusio/html/vendor/psx/framework/src/Loader/Loader.php(73): PSX\Framework\Loader\Loader->execute()\n

22 /var/www/fusio/html/vendor/psx/framework/src/Dispatch/Dispatch.php(95): PSX\Framework\Loader\Loader->load()\n

23 /var/www/fusio/html/vendor/psx/engine/src/WebServer/Engine.php(52): PSX\Framework\Dispatch\Dispatch->route()\n

24 /var/www/fusio/html/vendor/psx/framework/src/Environment/Environment.php(54): PSX\Engine\WebServer\Engine->serve()\n

25 /var/www/fusio/html/public/index.php(28): PSX\Framework\Environment\Environment->serve()\n

26 {main}","code":0,"severity":null} []

chriskapp commented 1 year ago

@cococonuts ok this looks indeed like you have an older version installed, could you run in your folder the composer info command to see which versions are currently installed? You should have version v5.4.3 installed of the fusio/engine package.

cococonuts commented 1 year ago

@chriskapp I upgrade the fusio-engine to v5.4.3. It works!

But I have new questions: why I don't have Contract and invoices in "Monetization"

image

I successfully purchase a subscription and one-time plan. I can't find transaction recording in fusio portal. What else should I config?

chriskapp commented 1 year ago

@cococonuts so great that this works, in a later version we have removed our internal billing system and the Contract/Invoice panel, since all this can be handled by the payment provider i.e. stripe which has much more options to customize your billing setup. You need to create a stripe connection and then register a payment webhook at the stripe portal which calls your Fusio instance at /system/payment/stripe/webhook, then you also need to set the webhook secret at the system / settings payment_stripe_secret. Then you should see all incoming transactions.

cococonuts commented 1 year ago

@chriskapp Got your point. I have set up webhook on stripe website and payment_stripe_secret on fusio admin portal. But I have not got transactions data.

I guess perhaps I didn't set up endpoint on strip webhook correctly My fusio app link is: https://myhost.com/apps/fusio The actual https router is https://myhost.com/index.php/

So which endpoint in stripe webhook should be set: https://myhost.com/apps/fusio/system/payment/stripe/webhook or https://myhost.com/index.php/system/payment/stripe/webhook

I didn't find webhook related document. Do you have a updated developer document?

chriskapp commented 1 year ago

yes, so you would need to use the url which points directly to your Fusio instance, in your case: https://myhost.com/index.php/system/payment/stripe/webhook

cococonuts commented 1 year ago

@chriskapp vendor/fusio/adapter-stripe/src/Provider/Stripe.php : portal(...) $externalId = $user->getExternalId();

externalId is empty. Where can I set the externalId for user?

image

How to set up the billing portal? So that use can view the billing portal. Do I need to setup payment_stripe_portal_configuration? Where can I find The stripe portal configuration id?

cococonuts commented 1 year ago

@chriskapp I solved the billing portal problem. I didn't find an entry-point for user cancel the subscription. How can an user cancel the subscription?

cococonuts commented 1 year ago

@chriskapp Another question: If user buy more than one subscriptions, will the points/credit added up?

chriskapp commented 1 year ago

Hey @cococonuts yes so regarding the external id, this value is also set via the stripe webhook, then a user gets the fitting external id. If the user has an external id he is able to visit the visit billing portal where he can also cancel a subscription. Regarding the points, yes so every time a user buys points those points are added to the existing points.

cococonuts commented 1 year ago

@chriskapp I could purchase subscription and visit billing portal with one account But I didn't find "Cancel subscription" function on the developer App. Do I need to implement it by myself? Could you share some details?

Here is my stripe billing portal, there is no "Cancel subscription" entry point.

image