|
|
@@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
+import com.github.kevinsawicki.http.HttpRequest;
|
|
|
import com.huifu.adapay.core.AdapayCore;
|
|
|
import com.huifu.adapay.core.util.AdapaySign;
|
|
|
import com.izouma.nineth.config.AlipayProperties;
|
|
|
@@ -15,6 +16,7 @@ import com.izouma.nineth.enums.PayMethod;
|
|
|
import com.izouma.nineth.service.AssetService;
|
|
|
import com.izouma.nineth.service.GiftOrderService;
|
|
|
import com.izouma.nineth.service.OrderService;
|
|
|
+import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
@@ -107,6 +109,29 @@ public class OrderNotifyController {
|
|
|
return WxPayNotifyResponse.success("OK");
|
|
|
}
|
|
|
|
|
|
+ @PostMapping(value = "/order/iap")
|
|
|
+ @ResponseBody
|
|
|
+ public String iap(@RequestParam String receiptData, @RequestParam Long orderId) {
|
|
|
+ String data = "{\"receipt-data\":\"" + receiptData + "\"}";
|
|
|
+ String body = HttpRequest.post("https://buy.itunes.apple.com/verifyReceipt")
|
|
|
+ .contentType("application/json")
|
|
|
+ .send(data)
|
|
|
+ .body();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(body);
|
|
|
+ int status = jsonObject.getInteger("status");
|
|
|
+ if (status == 21007) {
|
|
|
+ jsonObject = JSON.parseObject(HttpRequest.post("https://sandbox.itunes.apple.com/verifyReceipt")
|
|
|
+ .contentType("application/json")
|
|
|
+ .send(data)
|
|
|
+ .body());
|
|
|
+ status = jsonObject.getInteger("status");
|
|
|
+ }
|
|
|
+ if (status == 0) {
|
|
|
+ orderService.notifyOrder(orderId, PayMethod.WEIXIN, new SnowflakeIdWorker(0, 0).nextId() + "");
|
|
|
+ }
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/adapay/order/{orderId}")
|
|
|
@ResponseBody
|
|
|
public void adapayNotify(@PathVariable Long orderId, HttpServletRequest request) {
|