-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Refactoring payment #972
Merged
Merged
Refactoring payment #972
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Payment\Base; | ||
|
||
use EasyWeChat\Payment\Kernel\BaseClient; | ||
|
||
class Client extends BaseClient | ||
{ | ||
/** | ||
* Pay the order. | ||
* | ||
* @param array $attributes | ||
* | ||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | ||
*/ | ||
public function pay(array $attributes) | ||
{ | ||
return $this->request('pay/micropay', $attributes); | ||
} | ||
|
||
/** | ||
* Get openid by auth code. | ||
* | ||
* @param string $authCode | ||
* | ||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | ||
*/ | ||
public function authCodeToOpenId(string $authCode) | ||
{ | ||
return $this->request('tools/authcodetoopenid', ['auth_code' => $authCode]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Payment\Base; | ||
|
||
use Pimple\Container; | ||
use Pimple\ServiceProviderInterface; | ||
|
||
/** | ||
* Class ServiceProvider. | ||
* | ||
* @author overtrue <[email protected]> | ||
*/ | ||
class ServiceProvider implements ServiceProviderInterface | ||
{ | ||
/** | ||
* {@inheritdoc}. | ||
*/ | ||
public function register(Container $app) | ||
{ | ||
$app['base'] = function ($app) { | ||
return new Client($app); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Payment\Bill; | ||
|
||
use EasyWeChat\Kernel\Http\StreamResponse; | ||
use EasyWeChat\Payment\Kernel\BaseClient; | ||
|
||
class Client extends BaseClient | ||
{ | ||
/** | ||
* Download bill history as a table file. | ||
* | ||
* @param string $date | ||
* @param string $type | ||
* | ||
* @return \EasyWeChat\Kernel\Http\StreamResponse|\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | ||
*/ | ||
public function download(string $date, string $type = 'ALL') | ||
{ | ||
$params = [ | ||
'bill_date' => $date, | ||
'bill_type' => $type, | ||
]; | ||
|
||
$response = $this->requestRaw('pay/downloadbill', $params); | ||
|
||
if (strpos($response->getBody()->getContents(), '<xml>') === 0) { | ||
return $this->resolveResponse($response, $this->app['config']->get('response_type', 'array')); | ||
} | ||
|
||
return StreamResponse::buildFromPsrResponse($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Payment\Bill; | ||
|
||
use Pimple\Container; | ||
use Pimple\ServiceProviderInterface; | ||
|
||
/** | ||
* Class ServiceProvider. | ||
* | ||
* @author overtrue <[email protected]> | ||
*/ | ||
class ServiceProvider implements ServiceProviderInterface | ||
{ | ||
/** | ||
* {@inheritdoc}. | ||
*/ | ||
public function register(Container $app) | ||
{ | ||
$app['bill'] = function ($app) { | ||
return new Client($app); | ||
}; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openid 现在已经是一个词了,与 web 类似
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,稍后改