com.alipay.api.domain.AlipayFundTransToaccountTransferModel Java Examples

The following examples show how to use com.alipay.api.domain.AlipayFundTransToaccountTransferModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AliPayService.java    From java-pay with Apache License 2.0 5 votes vote down vote up
/**
 * 支付宝提现
 *
 * @param orderId
 */
public Result deposit(Long orderId) {
    // 校验订单信息
    Order order = orderService.findOne(orderId);
    if (order.getStatus() != OrderStatus.CREATE.getStatus()) {
        log.error(ExceptionMessage.ORDER_STATUS_INCORRECTNESS + " orderId: {}", orderId);
        throw new ValidateException(ExceptionMessage.ORDER_STATUS_INCORRECTNESS);
    }

    AlipayFundTransToaccountTransferModel transferModel = new AlipayFundTransToaccountTransferModel();

    transferModel.setOutBizNo(1 + RandomUtil.randomNum(15));
    transferModel.setAmount(order.getTotalFee().toString());
    transferModel.setPayeeAccount("real account");
    transferModel.setPayeeRealName("real name");
    transferModel.setPayerShowName("from name");
    transferModel.setRemark("remark");
    transferModel.setPayeeType("ALIPAY_LOGONID");
    try {
        AlipayFundTransToaccountTransferRequest request = new AlipayFundTransToaccountTransferRequest();
        request.setBizModel(transferModel);
        AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        log.info("ali deposit error message:{}", e.getMessage());
        return Result.success(ExceptionMessage.ALI_DEPOSIT_SUCCESS);
    }
    return Result.error(ExceptionMessage.ALI_DEPOSIT_FAILED);
}