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

v3.x Upgrade Guide #127

Open
lokielse opened this issue Mar 30, 2018 · 12 comments
Open

v3.x Upgrade Guide #127

lokielse opened this issue Mar 30, 2018 · 12 comments
Assignees
Labels
精华 Popular issue

Comments

@lokielse
Copy link
Owner

lokielse commented Mar 30, 2018

Upgrade apps from 2.x to 3.x

  • The redirect() method no calls exit() after sending the content. This is up to the developer now.

Upgrade Gateways from 2.x to 3.x

The primary difference is the HTTP Client. We are now using HTTPlug (http://httplug.io/) but rely on our own interface.

Breaking

  • Change typehint from Guzzle ClientInterface to Omnipay\Common\Http\ClientInterface
  • $client->get('..')/$client->post('..') etc are removed, you can call $client->request('GET', '').
  • No need to call $request->send(), requests are sent directly.
  • Instead of $client->createRequest(..) you can create+send the request directly with $client->request(..).
  • When sending a JSON body, convert the body to a string with json_encode() and set the correct Content-Type.
  • The response is a PSR-7 Response object. You can call $response->getBody()->getContents() to get the body as string.
  • $response->json() and $response->xml() are gone, but you can implement the logic directly.
  • An HTTP Client is no longer added by default by omnipay/common, but omnipay/omnipay will add Guzzle.
    Gateways should not rely on Guzzle or other clients directly.
  • $body should be a string (eg. http_build_query($data) or json_encode($data) instead of just $data).
  • The $headers parameters should be an array (not null, but can be empty)

Note: Prior to stable release, the goal is to migrate to PSR-18, once completed.
This will not change the gateway implementations.


总结:

  • 对用使用者而言,接口几乎是兼容的。
  • omnipay/common v3 需要php 7.1以上版本
@lokielse lokielse changed the title v3.0 Upgrade Guide v3.x Upgrade Guide Mar 30, 2018
@lokielse
Copy link
Owner Author

相关问题尽量在此反馈。

@lokielse lokielse added the 精华 Popular issue label Mar 30, 2018
@farmercode
Copy link

ok,已经使用最新版本的master了"lokielse/omnipay-alipay" : "dev-master",问题已经完美解决!

@lokielse lokielse self-assigned this Mar 30, 2018
@php-cpm
Copy link

php-cpm commented Mar 30, 2018

可以可以,点个赞,就是omnipay/common v3 需要php 7.1以上版本坑了,我只能继续用v3.0-alpha.1的omnipay/common 了

@farmercode
Copy link

如果需要固定库的版本,可以将dev-master修改为3.0-alpha.1,这是今天作者的努力成果。点个👍

@yangjiecao
Copy link

yangjiecao commented Apr 10, 2018

$response = $this->httpClient->get($url)->send()->getBody();

需要修改成

$response = $this->httpClient->request('GET', $url, [])->getBody();

Repository owner deleted a comment from yangjiecao Apr 10, 2018
Repository owner deleted a comment from yangjiecao Apr 10, 2018
@lokielse
Copy link
Owner Author

@farmercode 感谢反馈,已修复!

@Jackfinal
Copy link

php7.1.17 composer 安装出现如下报错 laravel5.6
`Your requirements could not be resolved to an installable set of packages.

Problem 1
- omnipay/common v2.3.4 requires guzzle/guzzle ~3.9 -> satisfiable by guzzle/guzzle[v3.9.0, v3.9.1, v3.9.2, v3.9.3].`

@xiaokus
Copy link

xiaokus commented Jul 26, 2018

pc 网站支付 回调 $response = $request->send(); 出错

@laraveler
Copy link
Contributor

@xiaokus 有没有安装guzzle/guzzle包

@xiaokus
Copy link

xiaokus commented Jul 26, 2018

安装了 支付成功了 就回调到这里就报错

@successgo
Copy link
Collaborator

@xiaokus 报错内容贴一下

@maxsky
Copy link
Contributor

maxsky commented May 16, 2019

发邮件给你了,瞧一瞧呀...PR 麻烦看看呢。

@successgo successgo removed their assignment Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
精华 Popular issue
Projects
None yet
Development

No branches or pull requests

9 participants