# 客户端SDK

# JAVA版

欢迎使用 TripLink SDK For Java ,代码地址GitHub Code (opens new window)

TripLink SDK For Java 让您更轻松方便对接TripLink开发接口,可以自动帮您满足能力调用过程中所需的参数校验、加签、数据解密、发送HTTP请求等非功能性要求。

这里向您介绍如何获取 TripLink SDK For Java 并开始调用。 如果您在使用 TripLink SDK For Java 的过程中遇到任何问题,欢迎在当前 GitHub 提交 Issues (opens new window)

# 环境要求

  1. 使用 TripLink SDK For Java 之前 ,您需要先前往TripLink文档中心-准备工作完成开发者接入的一些准备工作,包括RSA公钥、DES密钥、商户账号等。

# 安装依赖

推荐通过Maven来管理项目依赖,您只需在项目的pom.xml文件中声明如下依赖

<dependency>
  <groupId>io.github.ctripcorp</groupId>
  <artifactId>triplink-api</artifactId>
  <version>1.0.6</version>
</dependency>
1
2
3
4
5

# 使用说明

TripLink SDK For Java 支持您扩展自己的Http请和日志实现。

1.HttpClient

TripLink SDK For Java 的Https请求使用的Java原生的方法,您可以自己实现 HttpClient 接口,重写 post 方法

import com.ctrip.ccard.creditcard.vcc.exception.HttpException;

public class OkhttpClient implements HttpClient{
    //requestJson 请求入参  url 请求地址
    publick String post(String requestJson,String url){
        //自己的实现
        return null;
    }
    
}
1
2
3
4
5
6
7
8
9
10

2.日志实现

TripLink SDK For Java 引用了slf4j日志标准,您可以根据自己应用选择具体的实现,slf4j-simplelogbacklog4j都可以实现。示例:

使用logback处理日志添加如下依赖

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>${ch.qos.logback.version}</version>
</dependency>
1
2
3
4
5

使用slf4j-simple处理日志添加如下依赖

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>${org.slf4j.version}</version>
</dependency>
1
2
3
4
5

使用log4j处理日志添加如下依赖

<dependency>
    <groupId>log4j</groupId>
    <artifactId>logback-classic</artifactId>
    <version>${log4j.version}</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>${org.slf4j.version}</version>
</dependency>
1
2
3
4
5
6
7
8
9
10
11

# 快速使用

以下这段代码示例向您展示了使用TripLink SDK For Java调用一个API的3个主要步骤:

  1. 创建HttpClient实例
  2. 创建TripLinkBiz实例
  3. 创建TripLinkApi实例
  4. 创建使用Open Api 对应的请求参数
  5. 接口请求响应处理
import com.ctrip.ccard.creditcard.vcc.api.TripLinkApiImpl;
import com.ctrip.ccard.creditcard.vcc.bean.CreateCardInfo;
import com.ctrip.ccard.creditcard.vcc.bean.CreateRequest;
import com.ctrip.ccard.creditcard.vcc.bean.CreateResponse;
import com.ctrip.ccard.creditcard.vcc.biz.TripLinkBizImpl;
import org.junit.Assert;

import java.math.BigDecimal;

/**
 * Description:
 */
public class TestApi {
    
    private final Logger logger = LoggerFactory.getLogger(TestApi.class);

    private static final String DES = "Wa8Nw*Ei";

    private static final String URL = "https://openpci.fws.ctripqa.com/restful/soa2/18375/json";

    private static final String  PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKpQrSAzyJV0MfBN7qKvE8d73phdredNhF3cKm3IWKFlCWg/3alVWI6GE462rPc5A4T+shYcvzqhV5wSOS0QMfj9VfLPqUT+xggFcCQ48mbeX4Jy/N5QZB3RZuQu+YbmQT6f54h2sJvhqLurvE7sgW4qL7r6AaJfDsvYPjKSezYXAgMBAAECgYA32EY8Jd6iarwpMFSMEV4p7craKPVpv3gkkply79tn6EpCXZaf/HUSHpJxHCLw2Uf3JtBcAccOQXMJoMwQo5vOoMVl5nk+EZN//MB8Re8r/7GQV8E+myHdlntMjxOf38PGn9z8Ze0Q020fZwGjA6egBFcU/ld1lCcI0TAj3cZDcQJBANS9UOC3J5njhnuzACjQ1qTTXuv6hr2lbglr2za4Ju9xFJUkKXy2LBAp2LlakXZXDhf7lsqmwZg5BvOBK6DPl18CQQDM8tqqOr4LRJRhq2bqBx398IqtyoZpMshpzBXLr7bdhp7FR2N4AEoAGaa5hS5k3z5SYNLEGKFhRM+sFJBQjnRJAkBnq647I+YffxotM8jTGxpOjlbGhnqc9n4OB0p3evw2WRPfrhStmpUUd2AOy4zxb3EFzOvp66OSC9BQX9Uj86XfAkEAouGbgVDgOupNFvZ2+yWe43Ppc0eS3UZ72wFUjSXgKlzUECu1VOi95yh7xdOf1JFL4YKL30dH8psShUtuimc86QJAeBXASabJBcHAIisPkODvsciiz1pzm1WSuXRUxnuis0TRTRs7+2KEnWE4UV3jxehxkc1RAgteYosWXg5TWQgiUg==";

    public static void main(String[] args) {
        //1:创建HttpClient实例
        TripLinkHttpClient tripLinkHttpClient = new TripLinkHttpClient();
        //2:创建TripLinkBiz实例
        TripLinkBizImpl tripLinkBiz = new TripLinkBizImpl(PRIVATE_KEY,DES,URL,tripLinkHttpClient);
        //3:创建TripLinkApi实例
        TripLinkApiImpl tripLinkApi = new TripLinkApiImpl(tripLinkBiz);
        //4:创建使用Open Api 对应的请求参数
        CreateRequest request = getCreateParams();
        //5:接口请求响应处理
        try{
            CreateResponse response = tripLinkApi.create(request);
            Assert.assertNotNull(response);
        }catch(IllegalArgumentException e){
            //参数异常
            logger.error("参数异常,异常信息",e.getMessage());
        }catch(HttpException e){
             //https请求发生的异常
            //如果使用SDK的HttpClient实现类发送的请求,只要响应码不是200,都会抛 HttpException
            logger.error("接口请求发送异常,异常信息",e.getMessage());
        }
    }

    private static CreateRequest getCreateParams(){
        CreateRequest createRequest = new CreateRequest();
        createRequest.setRequestId("2021000000001");
        createRequest.setRequestTime("20210728102355");
        createRequest.setMerchantName("TEST");
        createRequest.setChannelType("TEST_CFNC_VCC");
        createRequest.setOperator("max");
        createRequest.setRequestSource("order");
        CreateCardInfo createCardInfo = new CreateCardInfo();
        createCardInfo.setLocalCurrency("USD");
        createCardInfo.setBillCurrency("USD");
        createCardInfo.setStartActiveDate("2021-07-28");
        createCardInfo.setEndCloseDate("2023-07-28");
        createCardInfo.setCreditLimitAmt(new BigDecimal(1200.00));
        createCardInfo.setMinAuthAmt(new BigDecimal(0.00));
        createCardInfo.setMaxAuthAmt(new BigDecimal(1200.00));
        createCardInfo.setEnableMutilUse("1");
        createCardInfo.setClosePercentage(100);
        createCardInfo.setEnable3DS("0");
        createCardInfo.setEnaleCVVCheck("0");
        createCardInfo.setEnableCurrencyCheck("0");
        createCardInfo.setMerchantCategoryName("0011");
        createCardInfo.setUserDefineInfo("{\"BookingNumber\":\"205D140D5-01DFFS\"}");
        createRequest.setCardInfo(createCardInfo);
        return createRequest;
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

# PHP版

欢迎使用 TripLink SDK For PHP,代码地址GitHub Code (opens new window)

TripLink SDK For PHP 让您更轻松方便对接TripLink开发接口,可以自动帮您满足能力调用过程中所需的参数校验、加签、数据解密、发送HTTP请求等非功能性要求。

这里向您介绍如何获取 TripLink SDK For PHP并开始调用。 如果您在使用 TripLink SDK For PHP的过程中遇到任何问题,欢迎在当前 GitHub 提交 Issues (opens new window)

# 环境要求

  1. 使用 TripLink SDK For PHP之前 ,您需要先前往TripLink文档中心-准备工作完成开发者接入的一些准备工作,包括RSA公钥、DES密钥、商户账号等。

# 快速使用

以下这段代码示例向您展示了使用TripLink SDK For PHP 调用API的示例:

  1. 创建卡 (opens new window)
  2. 更新卡 (opens new window)
  3. 关闭卡 (opens new window)
  4. 卡信息查询 (opens new window)
  5. 商户信息查询 (opens new window)
  6. 授权交易 (opens new window)
  7. 清算交易 (opens new window)

# 接口状态码

resultRespCode resultRespMsg
CCS000000 Success
CCF000003 Request Error
CCF000004 Request Type Un-Know
CCF000005 Sub Request Type Un-Know
CCE000006 System Error
200001 ActiveDate must be greater than current date
200002 Both MCC, MCC groups and [acquirerId,merchantId] are all empty
200003 Customer info not find
200004 Not find the mapping between clearing currency and open card currency
200005 Contract expiration
200006 Insufficient credit limit
200007 Global parameter not find
200008 InactiveDate must be greater than activeDate
200009 Effective mccGroup not find
200010 Mcc is incorrect
200011 Generate cvv error
200012 Invoke pci error
200013 Not find the mapping between the cardCurrency and settlementCurrency
200014 AcquirerId/mid must not be empty
200015 Not find card
200016 Card status is clop or clos
200017 Update card : cvv2 parameter is incorrect
200018 Get account info error
200019 Update card limit is less than the amount of used card
200022 SeqNbrMaxTemp error
200023 Card not exist
200033 Not find requestId
200035 Not find cardLogId
200036 Card bin not support