资源简介
该资源为java接入微信和支付宝支付的后端代码,参考blog:http://blog.csdn.net/lawsonjin/article/details/78732252
代码片段和文件信息
package cn.xcdm.bag.controller;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.JDOMException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradeAppPayModel;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import cn.xcdm.bag.common.SystemValue;
import cn.xcdm.bag.po.Orders;
import cn.xcdm.bag.service.CouponService;
import cn.xcdm.bag.service.OrdersService;
import cn.xcdm.bag.service.UserService;
import cn.xcdm.bag.util.GsonUtils;
import cn.xcdm.bag.util.ResponseUtils;
import cn.xcdm.bag.util.Result;
import cn.xcdm.bag.util.SnowflakeIdWorker;
import cn.xcdm.bag.wechatpay.ConstantUtil;
import cn.xcdm.bag.wechatpay.Md5Util;
import cn.xcdm.bag.wechatpay.PrepayIdRequestHandler;
import cn.xcdm.bag.wechatpay.WXUtil;
import cn.xcdm.bag.wechatpay.xmlUtil;
@Controller
@ResponseBody
@RequestMapping(value = “v1“)
public class PayController {
protected static final Log logger = LogFactory.getLog(PayController.class);
@Autowired
private OrdersService orderService;
@Autowired
private UserService userService;
@Autowired
private CouponService couponService;
/**
* 支付通用接口
*
* @param HowToPay
* @param orderId
* @param forWhat
* @param payMoney
* @param req
* @return
*/
@RequestMapping(value = “/auth/pay/common“)
public String commonPay(@RequestParam(value = “HowToPay“ required = true) String HowToPay
@RequestParam(value = “orderId“ required = false) String orderId
@RequestParam(value = “forWhat“ required = true) String forWhat
@RequestParam(value = “payMoney“ required = false) String payMoney HttpServletRequest req
HttpServletResponse res) {
if (StringUtils.equals(“alipay“ HowToPay)) { // 支付宝 逻辑
Orders orders = new Orders();
Result result = new Result();
String oldPhone = (String) req.getAttribute(“oldPhone“);
if (StringUtils.equals(“bag“ forWhat)) { // 存包逻辑
orders = orderService.selectOrdersInfoByOrderId(orderId);
if (orders == null) {
result.setCode(400);
result.setMsg(“订单号不存在“);
相关资源
- java版本微信公众号开发,可创建菜单
- 微信支付 Java SDK
- java微信支付H5、小程序和SDK
- 微信H5支付 java详细版
- Delphi调用微信AndroidSDK(微信支付)
- Java微信支付-微信App支付服务端源代码
- Android微信支付官方Demo
- 微信支付java V3版本开发demo
- 微信支付 V3 DEMO JAVA 版
- java 微信支付(公众号支付,H5支付,
- jsp 微信支付Demo
- 微信支付demo(php和java版)
- java 最新微信支付Demo
- 微信支付Demo(android+ios+开发文档)
- 微信支付V3 Java jsApi 扫码支付
- Java 微信支付官方SDK源码(已修复XX
- java 微信支付平台
- 微信公众号H5支付demo(Servlet实现)
- java微信开放平台APP支付代码
- 微信支付最新SDK wxpay-sdk-0.0.3
- 微信扫码支付案例Web
- java微信支付源码(WxPayAPI_JAVA_v3)
- java 微信支付工具类
- 微信支付源码(android)
- 简单微信支付和银联支付
- 微信支付,百分百成功
- 微信支付例程
- android 微信支付
- 微信支付appdemo
- android微信支付
评论
共有 条评论