Overview: RECENTLY IN the development of a cashier software, need to use scan bai payment, so I step on the pit to share with you

To prepare data

  • Merchants,
  • Terminal no.
  • access_token
  • www.lcsw.cn/doc/api/pay… (Sobai official website payment API)
  • www.lcsw.cn/fusesdk.htm… (Sobai official website SDK)

Study the official WEBSITE API

  • Request to clear the bai path
  • Note that the port on the path is 8045. The port on the official website is 8010, and the port on the technical staff is 8045. test.lcsw.cn:8045/lcsw
  • Generate signatures (note the concatenation order of parameters)

  • This development is payment code payment

  • So request and bai server address for the test. The LCSW. Cn: 8045 / LCSW/pay / 10…
  • Pay special attention to the meaning and usage of each parameter

The Java signature generation algorithm is as follows

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jjmy.entity.PosPrepayRe;
import com.jjmy.utils.MD5;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
@RestController
@RequestMapping("/pay") public class PayController {// version public static String pay_ver ="100"; Public static String pay_type ="000"; // Interface type public static String service_id ="010"; Public static String merchant_no ="Sweep and officially give."; Public static String terminal_id ="Sweep and officially give."; Public static String terminal_trace = getMasterId(); Public static String terminal_time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    public static String access_token = "Sweep and officially give."; // Request server interface public static String prePay_url ="http://test.lcsw.cn:8045/lcsw/pay/100/barcodepay";


    @RequestMapping(value = "/barCodePay"Public static PosPrepayRe barCodePay(@param () public static PosPrepayRe barCodePay(@param ())"auth_no") String auth_no,
                                         @Param("total_fee") String total_fee) {

        System.out.println(terminal_trace + "Refund Order Number");
        System.out.println(terminal_time + "Refund time stamp"); PosPrepayRe = new PosPrepayRe(); try { JSONObject jsonParam = new JSONObject(); jsonParam.put("pay_ver", pay_ver);
            jsonParam.put("pay_type", pay_type);
            jsonParam.put("service_id", service_id);
            jsonParam.put("merchant_no", merchant_no);
            jsonParam.put("terminal_id", terminal_id);
            jsonParam.put("terminal_trace", terminal_trace);
            jsonParam.put("terminal_time", terminal_time);
            jsonParam.put("auth_no", auth_no);
            jsonParam.put("total_fee", total_fee); //TODO: signature encryption String key_sign = md5.sign ("pay_ver=" + pay_ver + "&pay_type=" + pay_type + "&service_id=" + service_id + "&merchant_no=" + merchant_no + "&terminal_id=" + terminal_id + "&terminal_trace=" + terminal_trace + "&terminal_time=" + terminal_time + "&auth_no=" + auth_no + "&total_fee=" + total_fee + "&access_token=" + access_token, "UTF-8");
            System.out.println(key_sign + "Refund Signature");
            jsonParam.put("key_sign", key_sign);
            System.out.println(prePay_url + "");
            String xmlText = tojson(prePay_url, jsonParam.toJSONString());
            posPrePayRe = (PosPrepayRe) JSON.parseObject(xmlText, PosPrepayRe.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        returnposPrePayRe; }}Copy the code
  • The signature can refer to the algorithm of the official SDK

Interface for sending parameters to scan service POST

The PostMan test interfaces are as follows