Jump to content

how exact use third party vendor on own modules


Recommended Posts

Firstly,i use https://validator.prestashop.com/generator generate new module,name "mymodule"

 

then,i use compoer init to generate composer json like this:

{
  "name": "jinber/mymodule",
  "autoload": {
    "psr-4": {
      "Jinber\\Mymodule\\": "src/"
    },
    "classmap": [
      "mymodule.php",
      "controllers/",
      "classes/"
    ]
  },
  "require": {},
  "config": {
    "preferred-install": "dist",
    "classmap-authoritative": true,
    "optimize-autoloader": true,
    "prepend-autoloader": false
  }
}

 

next i use composer require wechatpay/wechatpay to install this sdk

now,my vendor like this:

image.png.6abe4a85f8888bf1672e832ad94065fc.png

this sdk use guzzlehttp 7+

 

when i follow sdk doc created some code, i got error:

AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method GuzzleHttp\\Utils::chooseHandler() in
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/guzzlehttp/guzzle/src/HandlerStack.php:49\nStack trace:\n#0 
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/wechatpay/wechatpay/src/ClientXmlTrait.php(123): GuzzleHttp\\HandlerStack::create()\n#1 
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/wechatpay/wechatpay/src/ClientDecorator.php(103): WeChatPay\\ClientDecorator::xmlBased()\n#2 
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/wechatpay/wechatpay/src/Builder.php(43): WeChatPay\\ClientDecorator->__construct()\n#3 
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/classes/WePayServer.php(9): WeChatPay\\Builder::factory()\n#4 
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/mymodule.php(244): WePayServer->jsapiPay()\n#5 
/www/wwwroot/p.shoucangjie.xin/modules/mymodule/controllers/front/jsapi.php(12): Etrestapi->getPayInfo()\n#6 
/www/wwwroot/p.shoucangjie.xin/classes/contro...', referer: https://servicewechat.com/wx8bf53686614eb4e6/devtools/page-frame.html

 

no matter include vendor/autoload.php or not and  run composer dump-autoload on modules/mymodule/ . always show this error

 

note: this sdk in symfony project work fine and chooseHandler function exists

Edited by langziyang (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...