Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Pimple\Exception\UnknownIdentifierException #901

Closed
xuxucode opened this issue Sep 1, 2017 · 5 comments
Closed

[4.0] Pimple\Exception\UnknownIdentifierException #901

xuxucode opened this issue Sep 1, 2017 · 5 comments

Comments

@xuxucode
Copy link
Contributor

xuxucode commented Sep 1, 2017

我用的环境

PHP 版本:7.0
overtrue/wechat 版本:4.0

问题及现象

$payment->jssdk 抛异常:

Pimple\Exception\UnknownIdentifierException:
Identifier 'access_token' is not defined in Pimple\Container->offsetGet()

代码段:

use EasyWeChat\Factory;

$payment = Factory::payment([
   // ...
]);

$jssdk= $paymen->jssdk;  // throw exception: UnknownIdentifierException
@xuxucode
Copy link
Contributor Author

xuxucode commented Sep 2, 2017

\EasyWeChat\Payment\Jssdk\Client 只用于生成客户端(js bridge, jssdk, app)请求参数,更像一个简单的工具类,不需要依赖access_token

能否继承EasyWeChat\BasicService\Jssdk\Client ,而是作为一个简单类并添加一个 __construct:

namespace EasyWeChat\Payment\Jssdk;

class Client
{
   /**
     * Constructor.
     *
     * @param \EasyWeChat\Payment\Application $app
     */
    public function __construct(Application $app)
    {
        $this->app = $app;
    }

    // ...
}

这样的话,也可以解决这个UnknownIdentifierException

@overtrue
Copy link
Collaborator

overtrue commented Sep 2, 2017

我也希望不依赖 access_token, 但是其中的签名过程是需要 ticket 的,而 ticket 的请求是需要 access_token 的

@xuxucode
Copy link
Contributor Author

xuxucode commented Sep 2, 2017

支付这块好像只有“收货地址共享”需要 access_token, 而且是通过参数传入的(shareAddressConfig),并不需要 Payment 相关的类做处理。这个项目我还没有看完,是不是我有遗漏的地方?

@overtrue
Copy link
Collaborator

overtrue commented Sep 2, 2017

稍等我看一下

@overtrue
Copy link
Collaborator

overtrue commented Sep 2, 2017

刚才看了一下,支付的 jssdk 是继承自基础 jssdk 的,比如 wx.config 是需要 ticket 来签名的,而通常支付的 js 也是需要用到 wx.config 的,所以这里还是需要 access_token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants