Skip to content
/ lol Public

lol is a collection of common service components

License

Notifications You must be signed in to change notification settings

jifuwei/lol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LOL Project

LOL项目使用Java开发,可以帮助你轻松快速集成市面上主流支付、消息模块,可直接用于生产环境。

已接入支付渠道:支付宝、微信、银联
已接入消息渠道:微信公众号、短信通道

Architecture

lol
├── doc
├── lib-util                        基础包-工具类
├── notice                          
│   ├── notice-component-sms        通知-短信
│   └── notice-component-wechat     通知-微信
└── pay
    ├── pay-component-alipay        支付-支付宝
    ├── pay-component-unionpay      支付-银联
    └── pay-component-wechatpay     支付-微信

详细信息请参考关于LOL项目

各项目下README.md有详细说明文档,如需集成,请仔细查看

Features

  • 可插拔、可定制,方便快速集成
  • 详细注解,二次开发方便

Getting started

我将以如何集成银联支付组件为例,其它基础包参考即可

git clone https://github.com/jifuwei/lol.git
cd lol

mvn clean install

必备依赖

银联支付只需要依赖如下component包即可

<dependencies>
    <dependency>
        <groupId>com.github</groupId>
        <artifactId>pay-component-unionpay</artifactId>
        <version>${latest.version}</version>
    </dependency>
</dependencies>

创建支付实现并使用

快速集成

public class App {
    public static void main(String[] args) {
        UnionpayConfig config = new UnionpayConfig();
        
        new CacheUnionpayProductFactory(config).produce(UnionpayProductEnum.GATEWAY.name());
    }
}

spring集成

@Configuration
public class UnionpayConfiguration {
    
    @Bean
    public UnionpayConfig unionpayConfig() {
        return UnionpayConfig.builder()
                .version(UnionpayConstant.VERSION_5_1_0)
                .encoding(UnionpayConstant.UTF_8_ENCODING)
                // 此处省略必备配置 具体参照字段注解
                .build();
    }
    
    @Bean
    public CacheUnionpayProductFactory unionpayProductFactory(
            @Qualifier("unionpayConfig") UnionpayConfig unionpayConfig) {
        return new CacheUnionpayProductFactory(unionpayConfig);
    }
}


@Service
public class UnionpayGatewayService {
    @Autowired
    IProductFactory unionpayProductFactory;
    
    public void gatewayConsume() {
        // 具体使用哪种产品,见方法注释
        IUnionpayGatewayClient gatewayClient = (IUnionpayGatewayClient) 
            unionPayProductFactory.produce(UnionpayProductEnum.GATEWAY.name());
        
        // 具体字段规则,参考各个model字段定义及api规则
        GatewayConsumeReq gatewayConsumeReq = GatewayConsumeReq.of(config)
                        .orderId(SimpleOrderIdGenerator.get(UnionpayProductEnum.GATEWAY.name()))
                        .txnTime(DateTime.now().toString(DEFAULT_DATE_TIME_FORMAT))
                        .txnAmt("10000000")
                        .frontUrl("http://www.lol.com/gateway/frontback")
                        .backUrl("http://www.lol.com/gateway/callback")
                        .payTimeout(new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT)
                                .format(new Date().getTime() + 15 * 60 * 1000))
                        .build();
        
        FormReq formReq = gatewayClient.consume(gatewayConsumeReq);
    }
}

Building

如果你想尝试最新的功能,可以使用如下命令构建

注意:jdk需要 1.8+ 分支:master

mvn clean install

Contact

License

LOL Project is under the MIT license. See the LICENSE file for details.

About

lol is a collection of common service components

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages