Controller
/** * IAP二次驗(yàn)證 * @param pingPayRequest * @return */ @RequestMapping("iap_verify") public BaseResponse iapVerify(@RequestBody PayRequest payRequest){ Map verifyMap = null; try { verifyMap = IAPVerify.getSecondaryVerify(pingPayRequest.getData(),pingPayRequest.getTp()); } catch (Exception e) { e.printStackTrace(); } log.warn("IAP返回:"+verifyMap); if(null == verifyMap){ return ResponseUtils.returnResponse(ResponseEnum.PING_PAY_REWARD_ERROR); } pingPayRequest.setPingId("");//TODO 蘋果返回id PingPay pingPay_save = pingPayService.save(pingPayRequest); if(null == pingPay_save){ return ResponseUtils.returnResponse(ResponseEnum.PING_PAY_REWARD_ERROR); } if(null != verifyMap){ return ResponseUtils.returnResponse(ResponseEnum.OK,verifyMap); }else { return ResponseUtils.returnResponse(ResponseEnum.PUBLICATION_IAP_V_FAIL); } }
public class IAPVerify { public static Map getSecondaryVerify(String data,String tp) throws Exception { Map verifyMap = new HashMap(); if (data != null && data.equals("") && null !=tp && !tp.equals("")) { URL dataUrl = new URL("https://buy.itunes.apple.com/verifyReceipt"); if(tp.equals("t")){ dataUrl = new URL("https://sandbox.itunes.apple.com/verifyReceipt"); } HttpURLConnection con = (HttpURLConnection) dataUrl.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("content-type", "text/json"); con.setRequestProperty("Proxy-Connection", "Keep-Alive"); con.setDoOutput(true); con.setDoInput(true); OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream()); String str = String.format(Locale.CHINA, "{"receipt-data":"" + data + ""}"); System.out.println(str); out.write(str); out.flush(); out.close(); InputStream is = con.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = null; String result = ""; while ((line = reader.readLine()) != null) { result += line + " "; } org.json.JSONObject j; try { j = new org.json.JSONObject(result); String returnresult = j.get("status").toString(); if (returnresult.equals("0")) { verifyMap.put("status", 0); verifyMap.put("receipt", j.get("receipt")); }else if (returnresult.equals("21002")) { verifyMap.put("status", -6L); verifyMap.put("receipt", j.get("receipt")); } else { verifyMap.put("status", Long.valueOf(returnresult)); verifyMap.put("receipt", j.get("receipt")); } return verifyMap; } catch (Exception e) { System.out.println("接收返回類型:" + e.getMessage()); } } return null; } }
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/67482.html
摘要:有人說(shuō)蘋果的審核人員比較任性,審核通不過(guò)是常事兒。然而這些文章并沒(méi)有在認(rèn)真介紹蘋果審核的注意事項(xiàng)。通過(guò)這張圖對(duì)蘋果的審核項(xiàng)目進(jìn)行梳理,也總結(jié)出了一些信息。 有人說(shuō)蘋果的審核人員比較任性,APP審核通不過(guò)是常事兒。確實(shí),蘋果在行業(yè)里扮演的就是一個(gè)極客的角色,要求多、難應(yīng)付。奈何對(duì)方手里捏了上億的用戶,所以你得把他當(dāng)女神一樣哄著,滿足她各種各樣無(wú)禮的要求。 要問(wèn)起誰(shuí)把這個(gè)女神伺候得最滿意,...
閱讀 2714·2021-11-17 17:01
閱讀 2092·2021-09-28 09:35
閱讀 3600·2021-09-01 11:04
閱讀 859·2020-06-22 14:41
閱讀 2983·2019-08-30 15:55
閱讀 2596·2019-08-30 15:43
閱讀 2319·2019-08-26 13:54
閱讀 2515·2019-08-26 13:48