ZOLOZ API獨立於程式設計語言並由網關服務對外開放。在接入ZOLOZ API之前,您需要確保可以與ZOLOZ網關服務進行通訊。本文介紹使用Java庫接入ZOLOZ API的方法。
前提條件
接入方法
要實現與網關服務通訊,一是可以整合已有的網關協議庫,二是自行實現網關協議。
ZOLOZ為您提供以下庫:
Java庫:當您的程式設計語言是Java時使用此庫,請參見添加Java庫。
Authentication test API說明
本文使用Authentication test API進行示範。Authentication test API是一個特殊的API,與特定產品無關,用於身分識別驗證測試。Authentication test API支援所有有效JSON對象,並返回相同的JSON對象,類似echo命令。
和其他API 一樣,Authentication test API也建立在網關服務之上,當您成功地調用Authentication test API後,整合其他API將非常簡單。
操作步驟
下面介紹使用Java庫接入ZOLOZ API的配置步驟。
添加Java庫
ZOLOZ Java庫發布在Maven中央存放庫中。以下介紹如何使用公用Java庫與網關服務互動並調用ZOLOZ API。
引入API SDK。
在專案的POM檔案中添加以下依賴項,將庫引入專案中。如需擷取最新版本的依賴項,請單擊這裡。
<dependency> <groupId>com.zoloz.api.sdk</groupId> <artifactId>zoloz-api-sdk</artifactId> <version>1.0.2</version></dependency>匯入OpenApiClient類。
import com.zoloz.api.sdk.client.OpenApiClient;執行個體化並配置OpenApiClient類。
//Set proper values to following vairablesString clientId = "<Client ID>";
String zolozPublicKey = "<ZOLOZ's public key content encoded in base64>";
String merchantPrivateKey = "<The merchant's private key content encoded in base64>";
//Instantiate an OpenApiClient object with signature validation and encryption both enabled by defaultOpenApiClient client = new OpenApiClient();
client.setHostUrl("<ZOLOZ gateway URL>");
client.setClientId(clientId);
client.setMerchantPrivateKey(merchantPrivateKey);
client.setOpenApiPublicKey(zolozPublicKey);
//NOTE: uncomment the following line if you want to skip signature validation for response//client.setSigned(false); //NOTE: uncomment the following line if you want to disable encryption//client.setEncrypted(false); 您需要將代碼中的以下欄位替換成您的真實資訊。如需擷取clientId、zolozPublicKey、merchantPrivateKey,請參見擷取API憑證。
clientId:客戶ID。
zolozPublicKey:ZOLOZ交易公開金鑰,採用Base64編碼格式。
merchantPrivateKey:商戶交易私密金鑰,採用Base64編碼格式。
setHostUrl:ZOLOZ網關URL,如需擷取ZOLOZ網關URL,請參見選擇網站和環境。
調用ZOLOZ API。
//Set the name of authentication test API String apiName = "v3.aml.nss.screen";
//Set the request, a simple JSON objectString request = "{\"bizCode\":\"ONBOARDING_PERSON_DEFAULT\",\"person\":{\"personName\":\"peter\"},\"customerId\":\"test_customer\",\"subjectType\":\"PERSON\"}";
//Call the API, the response is expected to be a JSON string of the same JSON objectString response = client.callOpenApi(apiName, request);接收來自API的響應。
{
"decision": "REVIEW",
"bizCode": "ONBOARDING_PERSON_DEFAULT",
"hitResults": [
{
"scanArgs": "[{\"disableSearch\":false,\"groupName\":\"GROUP1\",\"requestArgMap\":{\"BIRTHDAY\":\"19660510\",\"CITIZENSHIP\":\"\",\"PERSON_NAME\":\"John Doe\",\"ID\":\"\",\"GENDER\":\"\"},\"watchlistGroups\":[\"DEMO_PERSON_SANCTION\"]}]",
"scanResult": "review",
"hitReason": {
"engineType": "SANCTION",
"hitType": "name_match",
"paramMatch": "John Doe",
"recordMatch": "John Doe",
"matchRate": 100,
"matchStrategy": "s_person_name_common_src_full_name_similar" },
"hitRecord": {
"id": "example_12345",
"origin": "DOWJONES",
"type": "Person",
"activeStatus": "Active",
"nameDetails": [
{
"nameType": "Primary Name",
"nameValueList": [
{
"firstName": "John",
"surname": "Doe" }
]
}
],
"descriptions": [
{
"description1": "3",
"description2": "1" }
],
"dateDetails": [
{
"dateType": "Date of Birth",
"dateValueList": [
{
"day": "10",
"month": "May",
"year": "1966" }
]
}
],
"sanctionsReferences": [
{
"toDay": "10",
"toMonth": "Sep",
"toYear": "2019",
"value": "Sanctioned for financial crimes" }
],
"countryDetails": [
{
"countryType": "Citizenship",
"countryValueList": [
{
"code": "example_country_code" }
]
}
]
}
}
],
"totalHits": 1,
"rcrrRiskLevel": "",
"eventId": "6728d09e2113b33b6cc7e47a361c****",
"result": {
"resultCode": "SUCCESS",
"resultMsg": "success",
"resultStatus": "S" }
}相關資料
JAR和ZOLOZ輔助指令碼在Github上已開源,您可以通過下方連結擷取原始碼。