| | |
| | | import org.yeshi.utils.exception.WXOrderException;
|
| | | import org.yeshi.utils.exception.WXPlaceOrderParamsException;
|
| | | import org.yeshi.utils.wx.WXPayUtil;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.shop.BanLiShopOrderUtil;
|
| | |
| | | * @param money
|
| | | * @return
|
| | | */
|
| | | public static String getWXH5PayUrl(String orderNo, String ip, String goodsName, BigDecimal money) {
|
| | | public static String getWXH5PayUrl(String orderNo, String ip, String goodsName, BigDecimal money, String platform) {
|
| | | String wxOrderNo = BanLiShopOrderUtil.getWXPayOrderNo(orderNo);
|
| | | WXPlaceOrderParams params = new WXPlaceOrderParams();
|
| | | params.setBody(goodsName);
|
| | |
| | | params.setTradeType("MWEB");
|
| | | try {
|
| | | Map<String, String> map = WXPayUtil.produceOrder(params);
|
| | | return map.get("mweb_url") + "&redirect_url=" + URLEncoder
|
| | | .encode("http://test.banliapp.com/flqFront/AppInside/shop/wx_pay_success.html", "UTF-8");
|
| | | if ("ios".equalsIgnoreCase(platform))
|
| | | return map.get("mweb_url") + "&redirect_url="
|
| | | + URLEncoder.encode("shop.banliapp.com://shop.banliapp.com/wx_pay_finish.html", "UTF-8");
|
| | | else
|
| | | return map.get("mweb_url") + "&redirect_url="
|
| | | + URLEncoder.encode("http://shop.banliapp.com/wx_pay_finish.html", "UTF-8");
|
| | | |
| | | |
| | | } catch (WXPlaceOrderParamsException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | |
| | | public static boolean refund(String orderNo, BigDecimal money) throws WXOrderException {
|
| | | boolean success = WXPayUtil.refund(BanLiShopOrderUtil.getWXPayOrderNo(orderNo), money, money, null,
|
| | | new WXAPPInfo(Constant.getWXAccount(null, null).getGzAppId(),
|
| | | Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY), MCH_ID, BanLiShopWXPayUtil.class.getClassLoader().getResourceAsStream(MCH_CERT_PATH));
|
| | | Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY),
|
| | | MCH_ID, BanLiShopWXPayUtil.class.getClassLoader().getResourceAsStream(MCH_CERT_PATH));
|
| | | return success;
|
| | | }
|
| | |
|
| | |
| | | Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否支付成功
|
| | | * |
| | | * @param orderNo
|
| | | * @return
|
| | | * @throws WXOrderException
|
| | | */
|
| | | public static boolean isPaySuccess(String orderNo) throws WXOrderException {
|
| | | return WXPayUtil.isPaySuccess(BanLiShopOrderUtil.getWXPayOrderNo(orderNo),
|
| | | new WXAPPInfo(Constant.getWXAccount(null, null).getGzAppId(),
|
| | | Constant.getWXAccount(null, null).getGzAppSecret(), MCH_ID, MCH_KEY));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 签名是否正确
|
| | | * |
| | | * @param params
|
| | | * @param sign
|
| | | * @return
|
| | | */
|
| | | public static boolean signIsRight(Map<String, String> params, String sign) {
|
| | | String newSign = WXUtil.getSignMD5(params, MCH_KEY);
|
| | | return newSign.equalsIgnoreCase(sign);
|
| | | }
|
| | |
|
| | | }
|