支付SDK - 支付宝/微信

sodo-pay-dep

该项目中已经引入了“支付宝”、“快钱”、“财付通”、“微信支付”所需java文件。并且已经完成了对各支付服务器的回调进行了解析,预留了接口可以让业务系统更新数据。

1.在Maven的Pom.xml中引入pay-dep项目。

<dependency>
    <groupId>com.shuodao</groupId>
    <artifactId>sodo-pay-dep</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

2.继承、实现相应虚类和接口。

在无权限验证的Controller下继承AbsPayController(com.shuodao.paydep.controller.abs.AbsPayController)类。预留的支付后通知接口可以使用继承了AbsPayController的类去实现SellerPayService (com.shuodao.paydep.model.SellerPayService)接口,或者使用@Service的服务类实现。

例如:

public class PayController extends AbsPayController implements SellerPayService {

    private static final Logger LOGGER = LoggerFactory.getLogger(PayController.class);

    @Resource
    private PayRecordManager payRecordManager;

    @Resource
    private SystemConfig sysConfig;

    @Override
    public PayConfig getPayConfig(String seller) {
        return sysConfig;
    }

    private static final String paySuccessRedirect = "redirect:/user_admin/module_manage/order_manage";

    @Override
    public String handlePayResult(String remoteDealId, String localOrderId, PayType payType, 
                                    int totalFee, PayConfig payConfig, Model model) {
        LOGGER.info(String.format("%s pay result, tradeNo: %s, orderId: %s, handleSuccess: %d",
                payType.name(), remoteDealId, localOrderId, 
                payRecordManager.handlePaySuccess(localOrderId, remoteDealId, payType)));
        return paySuccessRedirect;
    }

    @Override
    public boolean handlePayNotify(String remoteDealId, String localOrderId, PayType payType, 
                                    int totalFee, PayConfig payConfig) {
        boolean handResult = payRecordManager.handlePaySuccess(localOrderId, remoteDealId, payType);
        LOGGER.info(String.format("%s pay notify, tradeNo: %s, orderId: %s, handleSuccess: %d",
                payType.name(), remoteDealId, localOrderId, handResult));
        return handResult;
    }
}
Copyright © Sodo Tech 2014-2018 all right reserved,powered by Gitbook最后更新: 2017-12-21 15:40

results matching ""

    No results matching ""