Compare commits

...

9 Commits

Author SHA1 Message Date
ch4o5
999f3633a5 chore(release): 1.0.0-alpha.8 2023-09-22 10:23:09 +00:00
李东云
6431fc010f fix(order): 修复类型错误的问题 2023-09-22 18:22:59 +08:00
ch4o5
cb0b3a3548 chore(release): 1.0.0-alpha.7 2023-09-22 09:41:40 +00:00
李东云
b8ebebde3c perf(callback): 增加了共用的通知业务系统的方法 2023-09-22 17:41:32 +08:00
ch4o5
1dba3b84a4 chore(release): 1.0.0-alpha.6 2023-09-22 08:15:10 +00:00
李东云
6cecc96c5f build(composer): 兼容 hyperf 的 RequestInterface 2023-09-22 16:15:01 +08:00
ch4o5
448569583c chore(release): 1.0.0-alpha.5 2023-09-22 07:43:53 +00:00
李东云
99af043376 feat(stripe): 增加 callback 对请求的转化 2023-09-22 15:42:22 +08:00
李东云
90dde97bc9 build(composer): 增加 hyperf/contract 包,更新依赖 2023-09-22 15:39:42 +08:00
7 changed files with 597 additions and 143 deletions

View File

@@ -1,4 +1,37 @@
# 版本更新日志
## [1.0.0-alpha.8](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2023-09-22)
### 🐛 Bug Fixes | Bug 修复
* **order:** 修复类型错误的问题 ([6431fc0](http://124.126.16.154:8888/singularity/hdk-pay/commit/6431fc010fe3e989773b84506df62d3c8f7ffc81))
## [1.0.0-alpha.7](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2023-09-22)
### ⚡ Performance Improvements | 性能优化
* **callback:** 增加了共用的通知业务系统的方法 ([b8ebebd](http://124.126.16.154:8888/singularity/hdk-pay/commit/b8ebebde3c5835bb0abc6e5078517c82341db95f))
## [1.0.0-alpha.6](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2023-09-22)
### 📦‍ Build System | 打包构建
* **composer:** 兼容 hyperf 的 RequestInterface ([6cecc96](http://124.126.16.154:8888/singularity/hdk-pay/commit/6cecc96c5ffc223a1a72df6abd1f07d54cb7953d))
## [1.0.0-alpha.5](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2023-09-22)
### 📦‍ Build System | 打包构建
* **composer:** 增加 hyperf/contract 包,更新依赖 ([90dde97](http://124.126.16.154:8888/singularity/hdk-pay/commit/90dde97bc90d33917eb2c1a4d09779dd45776d30))
### ✨ Features | 新功能
* **stripe:** 增加 callback 对请求的转化 ([99af043](http://124.126.16.154:8888/singularity/hdk-pay/commit/99af043376c4b44412a275d1b778e3e3584f5f96))
## [1.0.0-alpha.4](http://124.126.16.154:8888/singularity/hdk-pay/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2023-09-20)

View File

@@ -20,8 +20,10 @@
"moneyphp/money": "^4.1",
"singularity/hdk-core": "^1.0.0",
"hyperf/contract": "~3.0.0",
"hyperf/constants": "3.0.*",
"hyperf/config": "~3.0.0",
"hyperf/di": "~3.0.0"
"hyperf/di": "~3.0.0",
"hyperf/http-server": "3.0.*"
},
"require-dev": {
"cooper/hyperf-pest": "^1.1",
@@ -61,5 +63,5 @@
"url": "https://mirrors.cloud.tencent.com/composer/"
}
},
"version": "1.0.0-alpha.4"
"version": "1.0.0-alpha.8"
}

611
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@
namespace Singularity\HDK\Pay\Resource;
use Hyperf\Resource\Json\JsonResource;
use Money\Currency;
use Money\Money;
use Singularity\HDK\Pay\Enum\OrderStatus;
@@ -45,7 +46,10 @@ class Order extends JsonResource
'orderNo' => $this->resource['orderNo'],
'transactionId' => $this->resource['transactionId'],
'goodsName' => $this->resource['goodsName'],
'amount' => new Money($this->resource['amount']['amount'], $this->resource['amount']['currency']),
'amount' => new Money(
$this->resource['amount']['amount'],
new Currency($this->resource['amount']['currency'])
),
'state' => OrderStatus::from($this->resource['state']),
'uid' => $this->resource['uid'],
'payment' => $this->resource['payment'],

View File

@@ -14,13 +14,15 @@ namespace Singularity\HDK\Pay\Sdk;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\RequestOptions;
use Hyperf\Codec\Json;
use Hyperf\HttpServer\Contract\RequestInterface;
use Money\Money;
use Singularity\HDK\Core\Http\RequestService;
use Singularity\HDK\Core\Http\RequestServiceFactory;
use Singularity\HDK\Pay\Resource\Order;
use Singularity\HDK\Pay\Resource\StripeConfiguration;
use Singularity\HDK\Pay\Trait\WebhooksNotificationHandler;
use function Hyperf\Config\config;
/**
@@ -32,6 +34,8 @@ use function Hyperf\Config\config;
*/
final class StripeRpc
{
use WebhooksNotificationHandler;
private RequestService $requestService;
public function __construct(?string $baseUrl = null)
@@ -75,10 +79,13 @@ final class StripeRpc
'amount' => $money->getAmount(),
'currency' => $money->getCurrency(),
'uid' => $uid,
'goodsDetail' => array_replace($goodsDetail, [
'id' => $goodsId,
'goodsName' => $goodsName,
]),
'goodsDetail' => array_replace(
$goodsDetail,
[
'id' => $goodsId,
'goodsName' => $goodsName,
]
),
],
);

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* WechatRpc.php@Pay
@@ -11,15 +12,14 @@ declare(strict_types=1);
namespace Singularity\HDK\Pay\Sdk;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\RequestOptions;
use Hyperf\Codec\Json;
use Hyperf\Di\Annotation\Inject;
use Lmc\HttpConstants\Header;
use Money\Money;
use Psr\Http\Message\RequestInterface;
use Singularity\HDK\Core\Http\RequestService;
use Singularity\HDK\Core\Http\RequestServiceFactory;
use Singularity\HDK\Pay\Trait\WebhooksNotificationHandler;
use function Hyperf\Config\config;
@@ -32,14 +32,16 @@ use function Hyperf\Config\config;
*/
final class WechatRpc
{
private RequestService $requestService;
use WebhooksNotificationHandler;
private string $baseUrl;
private RequestService $requestService;
public function __construct(?string $baseUrl = null)
{
$this->requestService = RequestServiceFactory::make();
$this->baseUrl = $baseUrl ?? config('payment.base_uri');
$this->requestService = RequestServiceFactory::make([
'base_uri' => $baseUrl ?? config('payment.base_uri'),
RequestOptions::ALLOW_REDIRECTS => true,
]);
}
/**
@@ -58,23 +60,24 @@ final class WechatRpc
Money $money,
string $uid
): array {
$url = $this->baseUrl . '/rpc/v1/wechat/qrcode';
$data = [
'service' => config('payment.sp_id'),
'amount' => (int)$money->getAmount(),
'fileType' => $type,
'uid' => $uid,
'goods_detail' => [
'goods_name' => $goodsName,
],
];
$response = $this->requestService
->setOptions([
'headers' => [
Header::ACCEPT => $request->getHeader(Header::ACCEPT),
],
])
->requestPost($url, $data);
->requestPost(
url: '/rpc/v1/wechat/qrcode',
data: [
'service' => config('payment.sp_id'),
'amount' => (int)$money->getAmount(),
'fileType' => $type,
'uid' => $uid,
'goods_detail' => [
'goods_name' => $goodsName,
],
]
);
$content = $response->getBody()->getContents();
return Json::decode($content);

View File

@@ -0,0 +1,28 @@
<?php
/**
* Webhooks.php@Pay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/9/22
*/
namespace Singularity\HDK\Pay\Trait;
use Hyperf\HttpServer\Contract\RequestInterface;
use Singularity\HDK\Pay\Resource\Order;
/**
* Singularity\HDK\Pay\Trait\Webhooks@Pay
*
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
* Powered by PhpStorm
* Created on 2023/9/22
*/
trait WebhooksNotificationHandler
{
public function callback(RequestInterface $request): Order
{
return Order::make($request->post());
}
}