Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

feilong pay orderdesc unex

feilong edited this page Feb 27, 2019 · 4 revisions

feilong unex orderdesc

0. 背景

worldpay 显示订单描述

0

1. 普通做法,properties 全局配置

在 provider-unex.properties 中

unex.orderDesc=feilong香港官方網上商店商品

示例:

1

2. 使用 com.feilong.netpay.handler.gotopay.GotopayRequest.setTradeDescription(String) 方法

示例:

GotopayRequest gotopayRequest = new DefaultGotopayRequest();

...
gotopayRequest.setTradeDescription("feilong商城");
...

注意: 这种做法 优先级 高于 第一种

3.多语言

波姐:我的网站有多语言需求, 中文下 要 feilong香港官方網上商店商品 ,英文环境下 要 feilong Hong Kong Official Online Store Product

好问题, 好需求

如此这般


 /** The application context. */
@Resource
protected ApplicationContext applicationContext;
    
    

GotopayRequest gotopayRequest = new DefaultGotopayRequest();

...
String tradeDescription=com.feilong.spring.messagesource.MessageSourceUtil.getMessage(applicationContext, "unex.orderDesc");
gotopayRequest.setTradeDescription(tradeDescription);
...


然后 在 spring i18N 国际化配置文件中 payment_zh_CN.properties, 分别新增 ,

unex.orderDesc=feilong香港官方網上商店商品

以及 paymentType_en_GB.properties

unex.orderDesc=feilong Hong Kong Official Online Store Product

原先 provider-unex.properties 暂时不要删除, 冗余 保底

4.原理

public class DefaultUnexOrderOrderDescBuilder implements UnexOrderOrderDescBuilder{

    public static final UnexOrderOrderDescBuilder INSTANCE = new DefaultUnexOrderOrderDescBuilder();

    @Override
    public String build(GotopayRequest gotopayRequest,UnexGotopayBeanProperty unexGotopayBeanProperty){
        String tradeDescription = gotopayRequest.getTradeDescription();
        if (isNotNullOrEmpty(tradeDescription)){
            return tradeDescription;
        }
        return unexGotopayBeanProperty.getOrderDesc();
    }
}

gotopayRequest.getTradeDescription() 优先于 unexGotopayBeanProperty.getOrderDesc()

🌀 feilong 即时交流

QQ 群 243306798

🐼 About

如果您对本项目有任何建议和批评,可以使用下面的联系方式: