code-lives / kuaishou
快手小程序(支付、手机号解密、获取Token、模版消息、支付异步通知、退款、订单查询)
1.0.2
2024-07-06 05:57 UTC
README
安装
composer require code-lives/kuaishou 1.0.0
⚠️ 注意
金额单位分 100=1 元
返回结果 array 由开发者自行判断
预下单
//引入命名空间 use Applet\Assemble\Kuaishou; // 小程序下单 $pay= Kuaishou::init($config)->set("订单号","金额","描述",'openid', 'access_token')->getParam();
Token
$code=""; $data= Kuaishou::init($config)->getToken();
Config
Openid
$code=""; $data= Kuaishou::init($config)->getOpenid($code);
解密手机号
$data= Kuaishou::init($config)->decryptPhone($session_key, $iv, $encryptedData); echo $phone['phoneNumber'];
订单查询
$data = Kuaishou::init($config)->findOrder("订单号",$access_token);
退款
$orders = [ 'out_order_no' => $order['out_order_no'], 'out_refund_no' => $order['out_refund_no'], 'reason' => $order['reason'], 'attach' => $order['attach'], ]; $data= Kuaishou::init($config)->applyOrderRefund($order);
结算
//注意 需要设置回调 notify_url 在config 设置 settle_url 如果没有 默认为 notify_url $orders = [ 'out_order_no' => $order['out_order_no'], 'out_settle_no' => $order['out_settle_no'], 'reason' => $order['reason'], 'attach' => $order['attach'], ]; $data= Kuaishou::init($config)->settle($order,$access_token);
订单信息同步
$order = [ 'out_biz_order_no' => '', 'out_order_no' => '', 'open_id' => '', 'order_create_time' => time(), 'order_status' => 6, 'order_path' => '', 'product_cover_img_id' =>'', ]; $data = Kuaishou::init($config)->synchronousOrder($order, $token);
图片上传(订单信息同步)
$data = Kuaishou::init($config)->imgUpload('图片路径', $token);
模版消息
$data = [ "open_id" => "", "tpl_id" => "", "page" => "pages/index/index", "data" => [ 'key1' => "第一个", 'key2' => "第二个", 'key3' => "第三个", ] ]; $data= Kuaishou::init($config)->sendMsg($data,$token); $data=[ "err_no" => 1001, "err_tips" => "该用户未订阅" ]
支付回调
$pay = Kuaishou::init($config); $status = $pay->notifyCheck(); //验证 if ($status) { $order = $pay->getNotifyOrder(); //订单数据 //$order['data']['out_order_no']//平台订单号 echo json_encode(['result' => 1, 'message_id' => $order['message_id']]);exit; }