封账lakalaSDK
This commit is contained in:
parent
608e3bcae4
commit
62bbef0ed2
@ -46,8 +46,89 @@ class Demo extends Api
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
\think\Queue::push(DemoJob::class, ["name"=>"hello world!"], "school");
|
||||
$this->success('返回成功', $this->request->param());
|
||||
|
||||
$lakala = lakala_sdk();
|
||||
$tradeLocationInfo = new \Lakala\OpenAPISDK\V3\Model\TradeLocationInfo($lakala->getClientIp());
|
||||
|
||||
// 主扫交易Api
|
||||
$api = $lakala->v3(\Lakala\OpenAPISDK\V3\Api\TransPreorderApi::class);
|
||||
|
||||
// 主扫交易参数
|
||||
$request = new \Lakala\OpenAPISDK\V3\Model\TransPreorderRequest();
|
||||
// 必填参数
|
||||
$request->setMerchantNo('822290059430BFA');
|
||||
$request->setTermNo('D9261078');
|
||||
$request->setOutTradeNo(date('YmdHis', time()));
|
||||
$request->setAccountType('WECHAT');
|
||||
$request->setTransType('71');
|
||||
$request->setTotalAmount('100'); // 单位分
|
||||
$request->setLocationInfo($tradeLocationInfo);
|
||||
$request->setSubject('通过微信支付');
|
||||
|
||||
// 非必填参数
|
||||
// $request->setBusiMode('');
|
||||
// $request->setPayOrderNo('');
|
||||
$request->setNotifyUrl('https://www.test.com/lakela_order_payment_callback.php');
|
||||
// $request->setSettleType('');
|
||||
// $request->setRemark('');
|
||||
// $request->setPromoInfo('');
|
||||
// $request->setOutOrderNo('');
|
||||
// $request->setPnrInsIdCd('');
|
||||
|
||||
// 微信主扫场景 - 账户端业务信息
|
||||
$acc_busi_fields = new \Lakala\OpenAPISDK\V3\Model\TradePreorderWechaAccBusiFields();
|
||||
// $acc_busi_fields->setTimeoutExpress('');
|
||||
$acc_busi_fields->setSubAppid('wxd7e2deffbaa22254');
|
||||
$acc_busi_fields->setUserId('ohjUL7XWERU9rDfeNdvbxxil8jZY');
|
||||
// $acc_busi_fields->setDetail('');
|
||||
// $acc_busi_fields->setGoodsTag('');
|
||||
// $acc_busi_fields->setAttach('');
|
||||
// $acc_busi_fields->setDeviceInfo('');
|
||||
// $acc_busi_fields->setLimitPay('');
|
||||
// $acc_busi_fields->setSceneInfo('');
|
||||
// $acc_busi_fields->setLimitPayer('');
|
||||
|
||||
$detail = new \Lakala\OpenAPISDK\V3\Model\TradePreorderWechaDetail;
|
||||
// $detail->setCostPrice('1.00');
|
||||
// $detail->setReceiptId('');
|
||||
|
||||
$goods_detail = new \Lakala\OpenAPISDK\V3\Model\TradePreorderWechaGoodsDetail;
|
||||
$goods_detail->setGoodsId('3452234');
|
||||
// $goods_detail->setWxpayGoodsId('');
|
||||
// $goods_detail->setGoodsName('测试商品1');
|
||||
$goods_detail->setQuantity(1.0);
|
||||
$goods_detail->setPrice(1.0);
|
||||
|
||||
// $detail->setGoodsDetail([$goods_detail]);
|
||||
//
|
||||
// $acc_busi_fields->setDetail($detail);
|
||||
//
|
||||
//// 账户端业务信息
|
||||
$request->setAccBusiFields($acc_busi_fields);
|
||||
|
||||
try {
|
||||
$response = $api->transPreorder($request);
|
||||
if ($response->getRespData()) {
|
||||
print_r($response->getRespData());
|
||||
print_r($response->getAccRespFields());
|
||||
}
|
||||
else {
|
||||
print_r($response);
|
||||
}
|
||||
echo $response->getCode();
|
||||
|
||||
# 响应头信息
|
||||
print_r($response->getHeaders());
|
||||
|
||||
# 响应原文
|
||||
echo $response->getOriginalText();
|
||||
} catch (\Lakala\OpenAPISDK\V3\ApiException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
//
|
||||
//// \think\Queue::push(DemoJob::class, ["name"=>"hello world!"], "school");
|
||||
// $this->success('返回成功', $this->request->param());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,8 +157,8 @@ class Demo extends Api
|
||||
// file_put_contents("test.txt",$num."\r\n",FILE_APPEND);
|
||||
|
||||
// 实例对应的接口对象
|
||||
$scheme = new \WeMini\Total(Service::wechatConfig());
|
||||
$res= $scheme->create($q_params);
|
||||
// $scheme = new \WeMini\Total(Service::wechatConfig());
|
||||
// $res= $scheme->create($q_params);
|
||||
|
||||
|
||||
}catch (\Throwable $e){
|
||||
|
@ -614,3 +614,16 @@ if (!function_exists('repeat_filter')) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('lakala_sdk')) {
|
||||
|
||||
/**
|
||||
* 包装的lakalasdk函数
|
||||
* @return \bw\lakala\LakalaService
|
||||
*/
|
||||
function lakala_sdk()
|
||||
{
|
||||
return \bw\lakala\LakalaService::getInstance();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -3,13 +3,31 @@
|
||||
namespace bw\lakala;
|
||||
|
||||
/**
|
||||
* 拉卡拉服务
|
||||
* 拉卡拉服务工厂
|
||||
*/
|
||||
class LakalaService
|
||||
{
|
||||
//编写单例模式
|
||||
private static $instance;
|
||||
private $config;
|
||||
private $lakalaconfig;
|
||||
private $plantform_data;
|
||||
|
||||
private $sm4 = 'none';
|
||||
|
||||
private $host_pro = 'https://s2.lakala.com';
|
||||
private $host_test = 'https://test.wsmsd.cn/sit';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getClientIp()
|
||||
{
|
||||
return request()->ip();
|
||||
}
|
||||
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->init();
|
||||
@ -27,10 +45,78 @@ class LakalaService
|
||||
}
|
||||
public function init()
|
||||
{
|
||||
$this->config = [
|
||||
'merId' => '100000000000000',
|
||||
'merKey' => '12345678901234567890123456789012',
|
||||
];
|
||||
|
||||
|
||||
$site = config("site");
|
||||
$lakala_test_switch = config("site.lakala_test_switch");
|
||||
|
||||
|
||||
$this->plantform_data["lakala_apply_name"] = $site["lakala_apply_name"];
|
||||
|
||||
if(config("site.lakala_test_switch")){
|
||||
$this->plantform_data["lakala_partner_id"] = $site["test_lakala_partner_id"];
|
||||
|
||||
//沙箱测试环境
|
||||
$this->config = [
|
||||
'app_id' => $site["test_lakala_apply_id"],
|
||||
'serial_no' =>$site["test_lakala_serial_no"],
|
||||
'sm4_key' =>$site["test_lakala_sm4_secret_key"],
|
||||
//当前根目录下放置公钥文件
|
||||
"merchant_private_key_path" => ROOT_PATH . 'public' . $site["test_lakala_app_private_key"],
|
||||
"lkl_certificate_path"=> ROOT_PATH . 'public' . $site["test_lakala_plantform_public_k"],
|
||||
];
|
||||
if($this->config["sm4_key"]) $this->sm4 = $site["test_lakala_encryption_mode"];
|
||||
|
||||
}else{
|
||||
$this->plantform_data["lakala_partner_id"] = $site["lakala_partner_id"];
|
||||
//正式环境
|
||||
$this->config = [
|
||||
'app_id' => $site["lakala_apply_id"],
|
||||
'serial_no' => $site["lakala_serial_no"],
|
||||
'sm4_key' =>$site["lakala_sm4_secret_key"],
|
||||
"merchant_private_key_path" => ROOT_PATH . 'public' . $site["lakala_app_private_key"],
|
||||
"lkl_certificate_path"=> ROOT_PATH . 'public' . $site["lakala_plantform_public_key"],
|
||||
];
|
||||
if($this->config["sm4_key"]) $this->sm4 = $site["lakala_encryption_mode"];
|
||||
|
||||
}
|
||||
$this->config["app_debug"] = $lakala_test_switch ? true:false;
|
||||
$this->config["host_pro"] = $this->host_pro;
|
||||
$this->config["host_test"] = $this->host_test;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**v2api 接口
|
||||
* @param $api_model
|
||||
* @return \Lakala\OpenAPISDK\V2\Api\V2LakalaApi
|
||||
*/
|
||||
public function v2($api_model_class = null){
|
||||
$config = new \Lakala\OpenAPISDK\V2\V2Configuration($this->config);
|
||||
if($api_model_class){
|
||||
$api = new $api_model_class($config,$this->sm4);
|
||||
}else{
|
||||
$api = new \Lakala\OpenAPISDK\V2\Api\V2LakalaApi($config,$this->sm4);
|
||||
}
|
||||
return $api;
|
||||
}
|
||||
|
||||
/** v3api 接口
|
||||
* @param $api_model
|
||||
* @return void
|
||||
*/
|
||||
public function v3($api_model_class = null){
|
||||
// var_dump($this->config);die;
|
||||
|
||||
$config = new \Lakala\OpenAPISDK\V3\Configuration($this->config);
|
||||
if($api_model_class){
|
||||
$api = new $api_model_class($config,$this->sm4);
|
||||
}else{
|
||||
$api = new \Lakala\OpenAPISDK\V3\Api\LakalaApi($config,$this->sm4);
|
||||
}
|
||||
return $api;
|
||||
}
|
||||
|
||||
}
|
40686
public/api.html
40686
public/api.html
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user