Exemplo n.º 1
0
 public function yinlian()
 {
     include_once '../vendor/yinlian_sdk/acp_service.php';
     if (isset($_POST['signature'])) {
         if (\AcpService::validate($_POST) && ($_POST['respCode'] == '00' || $_POST['respCode'] == 'A6')) {
             $order = Order::where('out_trade_no', $_POST['orderId'])->first();
             if ($order != null) {
                 $orderId = $order->id;
                 $order->status = 1;
                 $time = date("Y-m-d H:i:s", time());
                 $order->payment_time = $time;
                 $order->payment_way = 3;
                 $order->save();
                 $useCouponRecords = UseCouponRecords::where('order_id', $orderId)->first();
                 if ($useCouponRecords != null) {
                     $useCouponRecords->status = 2;
                     //礼券金额
                     $apiParam = ['accessToken' => $useCouponRecords->access_token, 'coupon' => $useCouponRecords->coupon, 'orderId' => $_POST['orderId']];
                     $res = $this->post('/zhmf/member/consumerCoupon/useCoupon', $apiParam);
                     $res = json_decode($res);
                     if ($res->Code == 0) {
                         $useCouponRecords->status = 1;
                     }
                     $useCouponRecords->save();
                 }
                 echo 'success';
             }
         } else {
             @header('HTTP/1.1 500 Internal Server Error');
         }
     } else {
         @header('HTTP/1.1 500 Internal Server Error');
     }
 }
Exemplo n.º 2
0
 /**
  * 解析customerInfo。
  * 为方便处理,encryptedInfo下面的信息也均转换为customerInfo子域一样方式处理,
  * @param unknown $customerInfostr
  * @return array形式ParseCustomerInfo
  */
 static function parseCustomerInfo($customerInfostr)
 {
     $customerInfostr = base64_decode($customerInfostr);
     $customerInfostr = substr($customerInfostr, 1, strlen($customerInfostr) - 2);
     $customerInfo = parseQString($customerInfostr);
     if (array_key_exists("encryptedInfo", $customerInfo)) {
         $encryptedInfoStr = $customerInfo["encryptedInfo"];
         unset($customerInfo["encryptedInfo"]);
         $encryptedInfoStr = AcpService::decryptData($encryptedInfoStr);
         $encryptedInfo = parseQString($encryptedInfoStr);
         foreach ($encryptedInfo as $key => $value) {
             $customerInfo[$key] = $value;
         }
     }
     return $customerInfo;
 }
Exemplo n.º 3
0
 /**
  *
  * @SWG\Api(
  *   path="/orders/get_pay_info",
  *   @SWG\Operation(
  *     method="GET", summary="支付字符串", notes="支付字符串",type="string",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="out_trade_no",
  *         description="订单号",
  *         paramType="query",
  *         required=true,
  *         type="string"
  *     ),
  *     @SWG\Parameter(
  *         name="type",
  *         description="支付方式0-->支付宝,1--->微信,2--->银联",
  *         paramType="query",
  *         required=true,
  *         type="string"
  *     )
  *   )
  * )
  */
 public function getPayInfo(Request $request)
 {
     $response = new BaseResponse();
     $out_trade_no = $request->input('out_trade_no');
     $type = $request->input('type', 0);
     if ($out_trade_no == null || $type == null) {
         $response->Code = BaseResponse::CODE_ERROR_CHECK;
         $response->Message = '缺少参数';
         return $response->toJson();
     }
     if ($type == 0) {
         $data['payInfo'] = $this->getPayInfoStr($out_trade_no);
     } else {
         if ($type == 1) {
             $t = $this->generateWeiXinPrepayOrder($out_trade_no);
             if ($t == false) {
                 $response->Code = BaseResponse::CODE_ERROR_CHECK;
                 $response->Message = '服务器内部错误,错误码:108';
                 return $response->toJson();
             }
             $data['weixinPayInfo'] = $this->getWeiXinPayParameter($t['responseObj']->prepay_id);
         } else {
             include_once '../vendor/yinlian_sdk/acp_service.php';
             $order = Order::where('out_trade_no', $out_trade_no)->first();
             $params = array('version' => '5.0.0', 'encoding' => 'utf-8', 'txnType' => '01', 'txnSubType' => '01', 'bizType' => '000201', 'frontUrl' => SDK_FRONT_NOTIFY_URL, 'backUrl' => SDK_BACK_NOTIFY_URL, 'signMethod' => '01', 'channelType' => '08', 'accessType' => '0', 'currencyCode' => '156', 'merId' => '777290058125654', 'orderId' => $out_trade_no, 'txnTime' => date('YmdHis', time()), 'txnAmt' => $order->total_fee * 100);
             \AcpService::sign($params);
             // 签名
             $url = SDK_App_Request_Url;
             $result_arr = \AcpService::post($params, $url);
             if (count($result_arr) <= 0) {
                 //没收到200应答的情况
                 $response->Code = BaseResponse::CODE_ERROR_CHECK;
                 $response->Message = '服务器内部错误,错误码:108';
                 return $response->toJson();
             }
             //printResult ($url, $params, $result_arr ); //页面打印请求应答数据
             if (!\AcpService::validate($result_arr)) {
                 $response->Code = BaseResponse::CODE_ERROR_CHECK;
                 $response->Message = '应答报文验签失败';
                 return $response->toJson();
             }
             if ($result_arr["respCode"] == "00") {
                 //成功
                 //TODO
                 //var_dump(gettype($result_arr["tn"]));exit;
                 $data["yinlianPayInfo"] = "" . (string) $result_arr["tn"] . "";
             } else {
                 $response->Code = BaseResponse::CODE_ERROR_CHECK;
                 $response->Message = '服务器内部错误,错误码:108';
                 return $response->toJson();
             }
         }
     }
     $response->Data = $data;
     return $response->toJson();
 }