Compare commits
No commits in common. "b77c99a9ba3240cc2c72d62d4bca3358deb1602c" and "8744ceb2a5612d804a58d052dcd35ebc881fc252" have entirely different histories.
b77c99a9ba
...
8744ceb2a5
@ -15,15 +15,18 @@ class Controller extends BaseController
|
|||||||
|
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
$trade_no1 = UtilService::getTradeNo();
|
$trade_no = UtilService::getTradeNo();
|
||||||
$trade_no2 = UtilService::getTradeNo();
|
|
||||||
|
|
||||||
$scene_id = config("wechatpay.screen.commission");
|
$scene_id = config("wechatpay.screen.commission");
|
||||||
$openid = "oPC_2vneOWpQbicNZQAUCxuwZ4mw";
|
$openid = "oPC_2vneOWpQbicNZQAUCxuwZ4mw";
|
||||||
$amount = 1;
|
$amount = 100;
|
||||||
$remark = "测试";
|
$remark = "测试";
|
||||||
// $res = WechatPayService::transferBatches($trade_no1, $trade_no2, $openid, $amount, $remark);
|
$res = WechatPayService::officialUserTransfer($trade_no, $scene_id, $openid, $amount, $remark);
|
||||||
$res = WechatPayService::mchTransfer($trade_no1, $scene_id, $openid, $amount, $remark);
|
dd($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWechatplatformcCert()
|
||||||
|
{
|
||||||
|
$res = WechatPayService::getPlatformCert();
|
||||||
dd($res);
|
dd($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class WechatPayService
|
|||||||
// 从本地文件中加载「微信支付平台证书」,可由内置CLI工具下载到,用来验证微信支付应答的签名
|
// 从本地文件中加载「微信支付平台证书」,可由内置CLI工具下载到,用来验证微信支付应答的签名
|
||||||
$platformCertificateFilePath = 'file://' . config("wechatpay.payment.platform_cert_path");
|
$platformCertificateFilePath = 'file://' . config("wechatpay.payment.platform_cert_path");
|
||||||
$onePlatformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
|
$onePlatformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
|
||||||
|
Log::info($onePlatformPublicKeyInstance);
|
||||||
|
|
||||||
// 「微信支付平台证书」的「平台证书序列号」
|
// 「微信支付平台证书」的「平台证书序列号」
|
||||||
// 可以从「微信支付平台证书」文件解析,也可以在 商户平台 -> 账户中心 -> API安全 查询到
|
// 可以从「微信支付平台证书」文件解析,也可以在 商户平台 -> 账户中心 -> API安全 查询到
|
||||||
@ -55,11 +56,30 @@ class WechatPayService
|
|||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPlatformCert()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$instance = $this->newClient();
|
||||||
|
$resp = $instance->chain('v3/certificates')->get(
|
||||||
|
/** @see https://docs.guzzlephp.org/en/stable/request-options.html#debug */
|
||||||
|
// ['debug' => true] // 调试模式
|
||||||
|
);
|
||||||
|
return $resp->getBody();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 进行异常捕获并进行错误判断处理
|
||||||
|
Log::info($e->getMessage());
|
||||||
|
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
|
||||||
|
return $resp->getBody();
|
||||||
|
}
|
||||||
|
return $e->getTraceAsString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商家转账
|
* 转账零钱
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function mchTransfer(string $trade_no, string $scene_id, string $openid, int $amount, string $remark, array $transfer_scene_report_infos = []): array
|
public function officialUserTransfer(string $trade_no, string $scene_id, string $openid, int $amount, string $remark, array $transfer_scene_report_infos = []): array
|
||||||
{
|
{
|
||||||
// 发送请求
|
// 发送请求
|
||||||
if (empty(count($transfer_scene_report_infos))) {
|
if (empty(count($transfer_scene_report_infos))) {
|
||||||
@ -105,51 +125,6 @@ class WechatPayService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 商家批量转账到零钱
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function transferBatches(string $trade_no, string $trade_no2, string $openid, int $amount, string $remark): array
|
|
||||||
{
|
|
||||||
// try {
|
|
||||||
$appid = config("wechat.official_account.default.app_id");
|
|
||||||
$data = [
|
|
||||||
"appid" => $appid,
|
|
||||||
"out_batch_no" => $trade_no,
|
|
||||||
"batch_name" => $remark,
|
|
||||||
"batch_remark" => $remark,
|
|
||||||
"total_amount" => $amount,
|
|
||||||
"total_num" => 1,
|
|
||||||
"transfer_detail_list" => [
|
|
||||||
[
|
|
||||||
"out_detail_no" => $trade_no2,
|
|
||||||
"transfer_amount" => $amount,
|
|
||||||
"transfer_remark" => $remark,
|
|
||||||
"openid" => $openid,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
Log::info("转账到零钱数据", $data);
|
|
||||||
$instance = $this->newClient();
|
|
||||||
$resp = $instance->chain('v3/transfer/batches')->post([
|
|
||||||
"json" => $data
|
|
||||||
]);
|
|
||||||
$res = json_decode($resp->getBody(), true);
|
|
||||||
dd($res);
|
|
||||||
// } catch (\Exception $e) {
|
|
||||||
// // 进行异常捕获并进行错误判断处理
|
|
||||||
// Log::info($e->getMessage());
|
|
||||||
// if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
|
|
||||||
// $r = $e->getResponse();
|
|
||||||
// $res = json_decode($r->getBody());
|
|
||||||
// return ["code" => 1, "err_msg" => $r->getBody()];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return ["code" => 1, "err_msg" => $e->getMessage()];
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转账银行卡
|
* 转账银行卡
|
||||||
* @return void
|
* @return void
|
||||||
|
|||||||
@ -7,7 +7,9 @@ use Illuminate\Support\Facades\Route;
|
|||||||
|
|
||||||
//ueditor上传
|
//ueditor上传
|
||||||
Route::prefix("upload")->group(function () {
|
Route::prefix("upload")->group(function () {
|
||||||
Route::match(["get", "post"], '/ueditor', [CommonController::class, "upload"]);
|
Route::get('/ueditor', [CommonController::class, "upload"]);
|
||||||
|
Route::post('/ueditor', [CommonController::class, "upload"]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//微信转账
|
//微信转账
|
||||||
@ -19,3 +21,4 @@ Route::prefix("transfer")->group(function () {
|
|||||||
|
|
||||||
Route::get("test", [Controller::class, "test"]);
|
Route::get("test", [Controller::class, "test"]);
|
||||||
|
|
||||||
|
Route::get("wechat/platform/cert", [Controller::class, "getWechatplatformcCert"]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user