-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactoring payment module. * Fix tests.
- Loading branch information
Showing
56 changed files
with
1,980 additions
and
2,226 deletions.
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.