微商城付款-->支付宝

public String aliPay(String out_trade_no, String subject, String total_amount, String notify_url, String return_url) {
        AlipayClient alipayClient = new DefaultAlipayClient(AliPayConfigs.getGateWay(),
                                                            AliPayConfigs.getAppID(),
                                                            AliPayConfigs.getPrivateKey(),
                                                            AliPayConfigs.FORMAT ,//json
                                                            AliPayConfigs.CHARSET,//utf-8
                                                            AliPayConfigs.getAliPublicKey(),
                                                            AliPayConfigs.SIGNTYPE);//"RSA2"
        AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
        request.setReturnUrl(return_url);
        request.setNotifyUrl(notify_url);//在公共参数中设置回跳和通知地址
        // 封装请求支付信息
        AlipayTradeWapPayModel model=new AlipayTradeWapPayModel();
        model.setOutTradeNo(out_trade_no);//订单号
        model.setSubject(subject);//订单标题	
        model.setTotalAmount(total_amount);//订单金额
        model.setBody("");
        model.setTimeoutExpress("2m");
        model.setProductCode("QUICK_WAP_WAY");
        request.setBizModel(model);
        String form = null;
        try {
            form = alipayClient.pageExecute(request,"GET").getBody();
        } catch (AlipayApiException e) {
            logger.error(e);
        }
        return form;
    }

你可能感兴趣的:(java基础)