支付宝IOT蜻蜓设备绑定门店
1,代码我先贴上来,到时候再来写详细步骤,和解释~
//绑定门店 public function grabMachine(Request $request) { $store_id = $request->param('store_id'); $biz_tid = $request->param('biz_tid'); //通过admin_id查找 $admin_id = Db::name('store')->where('store_id', $store_id)->find(); //查找商户ID $merchantid = Db::name('merchant')->where('admin_id', $admin_id['admin_id'])->find(); $wh['merchant_id'] = $merchantid['id']; //商户ID $wh['copy'] = 1; //1是直连 2是间连 $wh['pay_way_id'] = 2; //1微信 2支付宝 6随行付 //直连场景填写商户收单pid $entry = Db::name('merchant_entry')->where($wh)->find(); if (empty($entry)) { return jsonr('400', '该支付通道不是直连or支付宝', []); } //商户pid名下的门店 ID $koubei = Db::name('store_koubei_info')->where(['merchantid' => $merchantid['id'], 'storeid' => $store_id])->find(); //1 $super_id = Db::name('admin')->where('id', $merchantid['agent_id'])->value('super_id'); $system = Db::name('system_config')->where('super_id', $super_id)->find(); //构造支付配置类 vendor('aop.AopClient'); $aop = new \AopClient(); $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; $aop->appId = $system['alipay_appid']; //引用APP $aop->rsaPrivateKey = $system['alipay_private_key']; //支付宝 私钥 $aop->alipayrsaPublicKey = $system['alipay_public_key']; //支付宝 公钥 $aop->apiVersion = '1.0'; $aop->signType = 'RSA2'; $aop->postCharset = 'utf-8'; $aop->format = 'json'; vendor('aop.request.AlipayMerchantIotDeviceBindRequest'); //引进 第三方类 $request = new \AlipayMerchantIotDeviceBindRequest(); $data['device_id_type'] = 'ID'; $data['biz_tid'] = $biz_tid; //设备ID $data['merchant_type'] = 'direct'; //* direct:直连商户; * indirect:间连商户。 $data['pid'] = $entry['ali_pid']; //pid 直连场景下,商户收单ID 【直连场景填写商户收单pid。间连场景填写smid绑定的pid(可通过代运营授权API获取)。[这是支付宝官方解释]】 $data['shop_id'] = $koubei['ali_shop_id']; //shop_id 商户pid名下门店ID $request->setBizContent(json_encode($data)); //json 格式请求 $result = $aop->execute($request); $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; $resultCode = $result->$responseNode->code; if (!empty($resultCode) && $resultCode == 10000) { return jsonr('200', '成功', []); } else { return jsonr('400', '失败', []); } }
- 1 以下是我,顺手截图的,等我过段时间,补上详细步骤,能看的更明白~
祝你开心=.=