银行支付测试

This commit is contained in:
mkm 2023-06-02 17:00:16 +08:00
parent 7819033c4e
commit e09c7bb693
2 changed files with 372 additions and 20 deletions

View File

@ -43,6 +43,7 @@ use think\facade\Db;
use think\facade\Log; use think\facade\Log;
use think\facade\Queue; use think\facade\Queue;
use crmeb\jobs\SendSmsJob; use crmeb\jobs\SendSmsJob;
use app\controller\api\Ceshi;
/** /**
* Class Auth * Class Auth
@ -54,6 +55,32 @@ class Auth extends BaseController
{ {
public function test() public function test()
{ {
$type = $this->request->param('type');
$res=[];
switch ($type) {
case 1:
$res = (app()->make(Ceshi::class))->Merchant_reconciliation_download();
break;
case 2:
$res = (app()->make(Ceshi::class))->Pay();
break;
case 3:
$res = (app()->make(Ceshi::class))->SettlementQuery();
break;
case 4:
$res = (app()->make(Ceshi::class))->OrderClosure();
break;
case 5:
$res = (app()->make(Ceshi::class))->OrderQuery();
break;
case 6:
$res = (app()->make(Ceshi::class))->refund();
break;
case 7:
$res = (app()->make(Ceshi::class))->NoticeSettlement();
break;
}
return app('json')->success(json_decode($res, true));
// $data = [ // $data = [
// 'tempId' => '', // 'tempId' => '',
// 'id' => '', // 'id' => '',
@ -171,7 +198,7 @@ class Auth extends BaseController
$data['mer_info'] = []; $data['mer_info'] = [];
// 判断是否是商户,并且有没有完善信息 // 判断是否是商户,并且有没有完善信息
//这里有点小问题以后要修改 //这里有点小问题以后要修改
$store_service = Db::name('store_service')->where('uid', $data['uid'])->where('is_del', 0)->find(); $store_service = Db::name('store_service')->where('uid', $data['uid'])->find();
if ($store_service) { if ($store_service) {
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->where('status', 1)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name')->find(); $mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->where('status', 1)->field('type_id,mer_avatar,mer_banner,mer_info,category_id,service_phone,mer_address,uid,mer_name')->find();
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') { if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {

View File

@ -0,0 +1,325 @@
<?php
namespace app\controller\api;
use Guzzle\Http\Exception\RequestException;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use think\App;
use GuzzleHttp\Psr7\Request;
class Ceshi
{
public function Merchant_reconciliation_download()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560202000200000100",
"version": "1.0.0"
},
"body": {
"mchtNo": "129765100270890",
"settleDate": "20200820",
"reqTime": "20200816153647",
"reqSsn": "c7c12347878pca8b5555d8d3630553as"
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
public function Pay()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560202000200000500",
"version" :"1.0.0"
},
"body": {
"charset": "UTF-8",
"orderType": "01",
"orderNumber": "f7c646fd1d8pca8b5555d8d363075392",
"orderCurrency": "01",
"subject": "测试商品",
"channel": "02",
"orderSendTime": "20200713093647",
"orderAmt": "10",
"version": "1.0.0",
"payAmt": "10",
"backEndUrl": "http://www.testpay.com/backEndU",
"frontEndUrl": "http://www.testpay.com/frontEndUrl",
"merId": "129765100270890",
"orderDetailList": {
"payType": "",
"merLst": [
{
"subOrderAmt": "10",
"orderNumber": "f7c646fd1d8pca8b5555d8d363075392",
"merId": "129765100270890",
"subPayAmt": "10",
"autoSettleFlag": "0",
"goodsInfo": [
{
"goodsSubject": "测试商品",
"goodsPrice": "10",
"goodsUnit": "",
"goodsNum": "1",
"goodsTotalAmt": "10",
"goodsSpec": "10"
}
]
}
],
"orderAmt": "10",
"payAmt": "10"
}
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
public function SettlementQuery()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560202000200000200",
"version" :"1.0.0"
},
"body": {
"charset": "UTF-8",
"orderNumber": "f7jugi1dlhna8b5555d8d363075392",
"subOrderNumber":"f7jugi1dlhna8b5555d8d363075392",
"settleMerNo":"129765100270890",
"merId":"129765100270890",
"version":"V5.0.0"
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
public function OrderClosure()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560102000200000100",
"version" :"1.0.0"
},
"body": {
"orderNumber":"b16808d20c4e4e9eb7224e49756d456f",
"merId":"129765100278888"
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
public function OrderQuery()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560202000200000000",
"version" :"1.0.0"
},
"body": {
"charset":"UTF-8",
"orderNumber":"f7c646fd1d8pca8b5555d8d363075393",
"merId":"129765100270890",
"version":"v5.0.0",
"tranType":"04"
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
public function refund()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560202000200000400",
"version" :"1.0.0"
},
"body": {
"charset":"UTF-8",
"orderNumber":"f7c646mlkd8pca8b5555d8d363075abc",
"merNo":"129765100270890",
"channel":"02",
"oriSubOrderNumber":"f7jugi1d8pca8b5555d8d363075392",
"merId":"129765100270890",
"orderSendTime":"20200713093647",
"orderAmt":"10",
"oriOrderNumber":"f7jugi1d8pca8b5555d8d363075392",
"version":"V5.0.0",
"backEndUrl":"https://www.testpay.com/refund"
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
public function NoticeSettlement()
{
$headers = [
'Content-Type' => 'application/json',
'Accept' => '*/*',
'Host' => '127.0.0.1:23552',
'Connection' => 'keep-alive'
];
$body = '{
"header": {
"appId": "000000000010012",
"appSecret": "8c76d098-ce22-4df8-a01d-ea6f5502e5ec",
"openEPubK": "3A743B476533D137EAA130F266501CAAE6D0870B1CAF0934D1CA5566F90B763F5B11C4A57B402C102C956ADF0DFDA3BD91F2843C648EAF159A9B08C0C8ACF541",
"appDPriK": "7D0B1F1BAFAE24436AD322EF35A6784B264700B9402C33F9CA2C6BB7FE325AF9",
"openVPubK": "7EAFB55A843DCBB33E07E4E59D3AF14216768CC0C8055985633AC753E29F9A5C07586CDBC9806CD31F66B17B12B07193B3C471C3A707C07E793D42B676AF80B1",
"appSPriK": "E8E0A7F49E2EC0E0C45352BDD4D8579FAC73A258FEDFF919B334DA2103EB32B7",
"httpDomainName": "https://open-test.scrcu.com:9051/open-gate",
"apiUrl": "/onlinepay/OPC321560202000200000400",
"version" :"1.0.0"
},
"body": {
"charset":"UTF-8",
"orderNumber":"f7c646mlkd8pca8b5555d8d363075abc",
"merNo":"129765100270890",
"channel":"02",
"oriSubOrderNumber":"f7jugi1d8pca8b5555d8d363075392",
"merId":"129765100270890",
"orderSendTime":"20200713093647",
"orderAmt":"10",
"oriOrderNumber":"f7jugi1d8pca8b5555d8d363075392",
"version":"V5.0.0",
"backEndUrl":"https://www.testpay.com/refund"
}
}';
$client = new Client(['base_uri' => 'http://127.0.0.1:23552']);
$request = new Request('POST', 'http://127.0.0.1:23552/sdk/doApi', $headers, $body);
try {
$res = $client->send($request);
} catch (GuzzleException $e) {
halt($e);
}
return $res->getBody()->getContents();
}
}