Search in sources :

Example 1 with AlipayTradePayRequest

use of com.alipay.api.request.AlipayTradePayRequest in project leopard by tanhaichao.

the class AlipayClientImpl method micropay.

@Override
public AlipayTradePayResponse micropay(String outTradeNo, String scene, String authCode, String subject, double amount, String spbillCreateIp) throws AlipayApiException {
    AlipayTradePayModel model = new AlipayTradePayModel();
    model.setOutTradeNo(outTradeNo);
    model.setScene(scene);
    model.setAuthCode(authCode);
    model.setSubject(subject);
    model.setTotalAmount(Double.toString(amount));
    System.err.println("authCode:" + authCode);
    System.err.println("totalAmount:" + amount);
    AlipayTradePayRequest request = new AlipayTradePayRequest();
    request.setBizModel(model);
    return alipayClient.execute(request);
// if (response.isSuccess()) {
// System.out.println("调用成功");
// }
// else {
// System.out.println("调用失败");
// }
// return response.getCode() + ":" + response.getSubCode() + ":" + response.getSubMsg();
// return AliPayApi.tradePay(model, notifyUrl);
}
Also used : AlipayTradePayModel(com.alipay.api.domain.AlipayTradePayModel) AlipayTradePayRequest(com.alipay.api.request.AlipayTradePayRequest)

Example 2 with AlipayTradePayRequest

use of com.alipay.api.request.AlipayTradePayRequest in project ballcat by ballcat-projects.

the class AliPay method codePay.

/**
 * 付款码支付-复杂支付
 * @author lingting 2021-01-25 09:56
 */
public AlipayTradePayResponse codePay(AlipayTradePayModel model, String notifyUrl) throws AlipayApiException {
    AlipayTradePayRequest request = new AlipayTradePayRequest();
    request.setBizModel(model);
    // 付款码场景固定
    model.setScene("bar_code");
    request.setNotifyUrl(notifyUrl);
    return client.execute(request);
}
Also used : AlipayTradePayRequest(com.alipay.api.request.AlipayTradePayRequest)

Example 3 with AlipayTradePayRequest

use of com.alipay.api.request.AlipayTradePayRequest in project GMall by 18391713434.

the class PaymentController method alipay.

@RequestMapping("/alipay/submit")
@LoginRequired(loginSuccess = true)
@ResponseBody
public String alipay(String outTradeNo, BigDecimal totalAmount, HttpServletRequest request, ModelMap modelMap) {
    String form = null;
    AlipayTradePayRequest alipayTradePayRequest = new AlipayTradePayRequest();
    // 回调函数地址
    alipayTradePayRequest.setReturnUrl(AlipayConfig.return_payment_url);
    alipayTradePayRequest.setNotifyUrl(AlipayConfig.notify_payment_url);
    Map<String, Object> map = new HashMap<>();
    map.put("out_trade_no", outTradeNo);
    map.put("product_code", "FAST_INSTANT_TRADB_PAY");
    map.put("total_amount", totalAmount);
    map.put("subject", "华为p40徕卡八摄影");
    String mapJSONStr = JSON.toJSONString(map);
    alipayTradePayRequest.setBizContent(mapJSONStr);
    // 获得一个支付宝请求客户端(它并不是一个连接,而是一个封装号的http的表单请求)
    try {
        form = alipayClient.pageExecute(alipayTradePayRequest).getBody();
    } catch (AlipayApiException e) {
        e.printStackTrace();
    }
    // 生成并保存用户的支付信息
    OmsOrder omsOrder = orderService.getOrderByOutTradeNo(outTradeNo);
    PaymentInfo paymentInfo = new PaymentInfo();
    paymentInfo.setCreateTime(new Date());
    paymentInfo.setOrderId(omsOrder.getId().toString());
    paymentInfo.setPaymentStatus("未付款");
    paymentInfo.setSubject("GMALL商城商品一件");
    paymentInfo.setTotalAmount(totalAmount);
    paymentService.savePaymentInfo(paymentInfo);
    // 向消息中间件发送一个检查支付状态(支付服务消费)的延迟消息队列
    paymentService.sendDelayPaymentCheckQueue(outTradeNo, 5);
    return form;
}
Also used : PaymentInfo(com.xatu.gmall.entity.PaymentInfo) HashMap(java.util.HashMap) OmsOrder(com.xatu.gmall.entity.OmsOrder) AlipayApiException(com.alipay.api.AlipayApiException) AlipayTradePayRequest(com.alipay.api.request.AlipayTradePayRequest) Date(java.util.Date) LoginRequired(com.xatu.gmall.annotations.LoginRequired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AlipayTradePayRequest (com.alipay.api.request.AlipayTradePayRequest)3 AlipayApiException (com.alipay.api.AlipayApiException)1 AlipayTradePayModel (com.alipay.api.domain.AlipayTradePayModel)1 LoginRequired (com.xatu.gmall.annotations.LoginRequired)1 OmsOrder (com.xatu.gmall.entity.OmsOrder)1 PaymentInfo (com.xatu.gmall.entity.PaymentInfo)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1