0% found this document useful (0 votes)
13 views

AIRTIME INTEGRATION_Version3 (13)

The document outlines the integration process for partners with Lumitel, detailing pre-requirements, API functionalities, and VPN connection specifications. It includes instructions for checking balances, recharging customer accounts, and retrieving transaction statuses, along with necessary encryption methods and templates for implementation. Partners are required to establish a contract and provide specific information to facilitate the integration.

Uploaded by

Artcal'O
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

AIRTIME INTEGRATION_Version3 (13)

The document outlines the integration process for partners with Lumitel, detailing pre-requirements, API functionalities, and VPN connection specifications. It includes instructions for checking balances, recharging customer accounts, and retrieving transaction statuses, along with necessary encryption methods and templates for implementation. Partners are required to establish a contract and provide specific information to facilitate the integration.

Uploaded by

Artcal'O
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

LUMITEL - VIETTEL BURUNDI S.

AIRTIME INTEGRATION

Bujumbura, 06/2019
Mục lục
I. Pre-requirement.....................................................................................................................3

II. Information For Partner.......................................................................................................3

1. Supply to partner...............................................................................................................3
1.1 Link to connect...........................................................................................................3
1.2 API to check balance..................................................................................................6
1.3 API recharge money to customer...............................................................................7
1.4 API recharge money to customer with Batch of Customer........................................9
1.5 Decribe class TextSecurity.......................................................................................10
1.6 Describe Response of webservice API...........................................................................20
1.7. Template code for integration with these APIs..............................................................24
I. Pre-requirement
 Partner must come BUJUMBURA Branch to make contract about Anypay Account and deposit money
 Send these information: contract, Anypay Account, IP of server to set up VPN connection as below, to IT Team of Lumitel
o Partner must supply Lumitel
 The IP of Partner System: IP of gateway, IP of Server to set up VPN connection as below
 Account of Anypay, the contract

II. Information For Partner


1. Supply to partner
1.1 Link to connect
http://10.225.6.73:8128/BCCSGateway?wsdl

VPN Connection

Contact Information Lumitel Partner

Name Jean Bertrand

Email Address [email protected]

Location Bujumbura

Telephone +257 69381909

Tunnel
Lumitel Partner
Properties
Pre-Shared Key
Authentication
Method
Lumitel@123 Lumitel@123

Encryption
AES
Scheme

Diffie-
Hellman Group 2
Group

Encryption
AES-256
Algorithm

Hashing
SHA 1
Algorithm

Main or
Aggressive Main Mode (IKE v1 preferred)
Mode
Phase 2 IKE (Phase 1)

Lifetime (for
28800 seconds
renegotiation)

Pre-shared key

Encapsulation ESP
(ESP or AH)
Encryption
AES-256
Algorithm

Authentication
SHA 1
Algorithm

Perfect
Forward Disabled
Secrecy

Lifetime (for
N/A
renegotiation)

Lifesize in KB
(for N/A
renegotiation)

VPN Gateway
Lumitel Partner
Device Information

Ex:
Peer IP Address 154.73.104.100
41.79.226.30

VPN Device
FORTIGATE
Description

VPN Device Version 600C

Location BUJUMBURA
Encryption
Domain/Servers 10.225.6.73
(Hosts to be http://10.225.6.73:8128/BCCSGateway?wsdl
encrypted)

Services permitted 8128

1.2 API to check balance


Format WSDL:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.bccsgw.viettel.com/">


<soapenv:Header/>
<soapenv:Body>
<web:gwOperation>
<Input>
<username>e56483efe003feb54ceec2f96a494048</username>
<password>e56483efe003feb5261e23aeccad928e4687ccba21e07165</password>
<wscode>getAccountInfo</wscode>
<!--Zero or more repetitions:-->
<param name="username" value="70ACC60997A82ED41FAB4D452570FA9C"/>
<param name="password" value="70ACC60997A82ED4DAB591426316BCD858993B345C24A122"/>
<param name="data" value="69061690|8925708000280002994|4F3BEEE56B49348D"/>
<!--Optional:-->
<rawData>?</rawData>
</Input>
</web:gwOperation>
</soapenv:Body>
</soapenv:Envelope>

Herein:

 <username -> Lumitel will supply after you have contract


 <password> -> Lumitel will supply after you have contract
 In Param tag:
 Username: -> Lumitel will supply after you have contract
 Password: -> Lumitel will supply after you have contract
 Note: username and password , Lumitel will supply with encryption already
 69061690 -> Your SIM ToolKit number, -> Lumitel will supply after you have contract
 8925708000280002994 -> Your ICCID, -> Lumitel will supply after you have contract
 4F3BEEE56B49348D-> Your PIN of SIM Toolkit -> Lumitel will supply after you have contract

1.3 API recharge money to customer


1.3.1 Format of request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.bccsgw.viettel.com/">
<soapenv:Header/>
<soapenv:Body>
<web:gwOperation>
<Input>
<username>0f0ddb7fef01cc8b</username>
<password>d728e5a7767403390eef71859b1ebf31</password>
<wscode> saleAnypayCustomerV3</wscode>
<!--Zero or more repetitions:-->
<param name="username" value="70ACC60997A82ED41FAB4D452570FA9C "/>
<param name="password" value="70ACC60997A82ED4DAB591426316BCD858993B345C24A122"/>
<param name="data" value="69061690|8925708000280002994|4F3BEEE56B49348D |61000111|BC28D222A9CCF03C"/>
<!--Optional:-->
<rawData>?</rawData>
</Input>
</web:gwOperation>
</soapenv:Body>
</soapenv:Envelope>

 <username -> Lumitel will supply after you have contract


 <password> -> Lumitel will supply after you have contract
In Param tag:
 Username: -> Lumitel will supply after you have contract
 Password: -> Lumitel will supply after you have contract
 Note: username and password , Lumitel will supply with encryption already
 Data is with this format: SOURCE_MSISDN|ICCID|MPIN|TARGET_MSISDN|AMOUNT
o SOURCE_MSISDN -> your sim toolkit number (ex: 69061690)
o TARGET_MSISDN -> your customer’s number who you want to recharge airtime for him (ex: 61000111)
o AMOUNT -> money in FBU, must be encrypted
 Ex: BC28D222A9CCF03C -> 500 FBU
o 69061690 -> Your SIM ToolKit number, -> Lumitel will supply after you have contract
o 8925708000280002994 -> Your ICCID, -> Lumitel will supply after you have contract
o 4F3BEEE56B49348D-> Your PIN of SIM Toolkit -> Lumitel will supply after you have contract

1.3.2 Format of response: refer 1.6 item

1.4 API recharge money to customer with Batch of Customer


Format WSDL
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.bccsgw.viettel.com/">
<soapenv:Header/>
<soapenv:Body>
<web:gwOperation>
<Input>
<username>0f0ddb7fef01cc8b</username>
<password>d728e5a7767403390eef71859b1ebf31</password>
<wscode>saleAnypayBatchV3</wscode>
<!--Optional:-->
<rawData><![CDATA[<ws:saleAnypayBatchV3>
<username>70ACC60997A82ED41FAB4D452570FA9C </username>
<password>70ACC60997A82ED4DAB591426316BCD858993B345C24A122</password>
<data>
<item>69061690|89257080002800029943|4F3BEEE56B49348D |61000111|4F3BEEE56B49348D </item>
<item>69061690|8925708000280002994|4F3BEEE56B49348D |61000111|4F3BEEE56B49348D </item>
<item>69061690|8925708000280002994|4F3BEEE56B49348D |61000111|4F3BEEE56B49348D </item>
</data>
</ws:saleAnypayBatchV3>]]>
</rawData>
</Input>
</web:gwOperation>
</soapenv:Body>
</soapenv:Envelope>

 <username -> Lumitel will supply after you have contract


 <password> -> Lumitel will supply after you have contract
 Username: -> Lumitel will supply after you have contract
 Password: -> Lumitel will supply after you have contract
 Note: username and password , Lumitel will supply with encryption already

In data tag:
 69061690 -> Your SIM ToolKit number, -> Lumitel will supply after you have contract
 8925708000280002994 -> Your ICCID, -> Lumitel will supply after you have contract
 4F3BEEE56B49348D-> Your PIN of SIM Toolkit -> Lumitel will supply after you have contract
 Data item is with this format: SOURCE_MSISDN|ICCID|MPIN|TARGET_MSISDN|AMOUNT
o SOURCE_MSISDN -> your sim toolkit number (ex: 69061690) -> Lumitel will supply after you have contract
o TARGET_MSISDN -> your customer’s number who you want to recharge airtime for him (ex: 61000111)
o AMOUNT -> money in FBU, must be encrypted
 Ex: BC28D222A9CCF03C -> 500 FBU

o 8925708000280002994 -> Your ICCID, -> Lumitel will supply after you have contract
o 4F3BEEE56B49348D-> Your PIN of SIM Toolkit -> Lumitel will supply after you have contract

1.5 API to get Transaction Status


Format WSDL:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.bccsgw.viettel.com/">


<soapenv:Header/>
<soapenv:Body>
<web:gwOperation>
<Input>
<username>e56483efe003feb54ceec2f96a494048</username>
<password>e56483efe003feb5261e23aeccad928e4687ccba21e07165</password>
<wscode>getTransStatus</wscode>
<!--Zero or more repetitions:-->
<param name="username" value="70ACC60997A82ED41FAB4D452570FA9C"/>
<param name="password" value="70ACC60997A82ED4DAB591426316BCD858993B345C24A122"/>
<param name="data" value="69061690|8925708000280002994|4F3BEEE56B49348D| 24136046|2021-10-05|2021-10-06"/>
<!--Optional:-->
<rawData>?</rawData>
</Input>
</web:gwOperation>
</soapenv:Body>
</soapenv:Envelope>

Herein:

 <username -> Lumitel will supply after you have contract


 <password> -> Lumitel will supply after you have contract
 In Param tag:
 Username: -> Lumitel will supply after you have contract
 Password: -> Lumitel will supply after you have contract
 Note: username and password , Lumitel will supply with encryption already
 69061690 -> Your SIM ToolKit number, -> Lumitel will supply after you have contract
 8925708000280002994 -> Your ICCID, -> Lumitel will supply after you have contract
 4F3BEEE56B49348D-> Your PIN of SIM Toolkit -> Lumitel will supply after you have contract
 Data item is with this format: MSISDN|ICCID|MPIN|TRANS_ID|FROM_DATE|TO_DATE
o MSISDN -> your sim toolkit number (ex: 69061690) -> Lumitel will supply after you have contract.
o TRANS_ID -> field <transId>xxx</transId> in response of function saleAnypayCustomerV3 when you sale anypay
customer.
o FROM_DATE -> start time when search transaction(format: yyyy-mm-dd).
o TO_DATE -> end time when search transaction(format: yyyy-mm-dd).
o 8925708000280002994 -> Your ICCID, -> Lumitel will supply after you have contract
o 4F3BEEE56B49348D-> Your PIN of SIM Toolkit -> Lumitel will supply after you have contract
1.6 Decribe class TextSecurity

Code Template

Change name of file: PaywayWS Send Partner.rar_ChangeName to PaywayWS Send Partner.rar -> this is code template

Is used to encrypt mpin, amount

package com.viettel.payway.ws.utils;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.zip.Adler32;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
import org.apache.log4j.Logger;
public class TextSecurity {

private final Logger logger = Logger.getLogger(TextSecurity.class);


// This array is used to convert from bytes to hexadecimal numbers
static private final char[] digits
= {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

private String share_key = null;

public enum CheckSumAlgorithm {

Adler32, CRC32
}

public enum MessageDigestAlgorithm {

MD5, SHA
}

/**
* based on sun link
* https://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html#AppA
* DESede is Tripple DES algorithm
*
* @author xakn1
*
*/
public enum EncryptionAlgorithm {

DES, SHA, DESede, RC2, RC4, RC5


}
public enum EncryptionMode {

NONE, CBC, CFB, ECB, OFB, PCBC


}

public enum EncryptionPadding {

NoPadding, PKCS5Padding, SSL3Padding


}

public void setShareKey(String str) {


share_key = str;
}

/**
*
* @param input
* @param alogorithm e.g MD5, SHA algorithms
*/
public void computeDigest(String input, MessageDigestAlgorithm alogorithm) {

// Generate Des key and vector using MD5, SHA


MessageDigest msgdig;
try {
msgdig = MessageDigest.getInstance(alogorithm.name());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}

msgdig.update(input.getBytes());
byte[] mdbytes = msgdig.digest();
}

/**
*
* @param input
* @param algorthm
* @return
*/
public long computeCheckSum(String input, CheckSumAlgorithm algorithm) {
long sum = -1;

Checksum cs = null;

if (algorithm.equals(CheckSumAlgorithm.Adler32)) {
cs = new Adler32();
} else if (algorithm.equals(CheckSumAlgorithm.CRC32)) {
cs = new CRC32();
}

cs.update(input.getBytes(), 0, input.length());
sum = cs.getValue();
return sum;
}

/**
* hexEncode is create String object which contains hex representation of
* data present in bytes array
*
* @param bytes - input array of bytes to be hex coded
* @return String objecting containing hex representation of bytes in input
* array
*/
public String hexEncode(byte[] bytes) {
StringBuilder buffer = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
byte byteValue = bytes[i];
buffer.append(digits[(byteValue & 0xf0) >> 4]);
buffer.append(digits[byteValue & 0x0f]);
}
return buffer.toString();
}

public byte[] hexStringToByteArray(String s) {


if (s == null || s.isEmpty() == true) {
return null;
}
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i + 1), 16));
}
return data;
}

/**
*
* @param clearText
* @param cipher
* @param secretKey
* @param ivVector Initialization Vector
* @return
* @throws PAPException
*/
public byte[] encrypt(String clearText, Cipher cipher, SecretKey secretKey, IvParameterSpec ivVector) {

byte[] ciphertext = null;


try {
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivVector);
ciphertext = cipher.doFinal(clearText.getBytes());
} catch (Exception e) {
throw new RuntimeException(e);
}
return ciphertext;
}

/**
*
* @param cipherText
* @param cipher
* @param secretKey
* @param ivVector
* @return
* @throws PAPException
*/
public String decrypt(byte[] cipherText, Cipher cipher, SecretKey secretKey, IvParameterSpec ivVector) {
byte[] cleartext = null;
try {
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivVector);
cleartext = cipher.doFinal(cipherText);
} catch (Exception e) {
throw new RuntimeException(e);
}
return new String(cleartext);
}
public byte[] encryptPass2(String pass) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException,
NoSuchPaddingException {
computeDigest("SecretWord", MessageDigestAlgorithm.MD5);
computeDigest("SecretWord", MessageDigestAlgorithm.SHA);
computeCheckSum("SecretWord", CheckSumAlgorithm.Adler32);
computeCheckSum("SecretWord", CheckSumAlgorithm.CRC32);
//uses the first 24 bytes in the secret
// DESedeKeySpec keyspec = new DESedeKeySpec(secret.getBytes());
DESedeKeySpec keyspec
= new DESedeKeySpec(share_key.getBytes());
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance(EncryptionAlgorithm.DESede.name());
SecretKey deskey = keyfactory.generateSecret(keyspec);

// Create an 8-byte initialization vector


byte[] iv = new byte[]{(byte) 0x8E, 0x12, 0x39, (byte) 0x9C, 0x07, 0x72, 0x6F, 0x5A};

IvParameterSpec ivVector = new IvParameterSpec(iv);


Cipher cipher = Cipher.getInstance(EncryptionAlgorithm.DESede.name() + "/" + EncryptionMode.CBC.name() + "/"
+ EncryptionPadding.PKCS5Padding.name());
byte[] ciphertext = null;
try {
cipher.init(Cipher.ENCRYPT_MODE, deskey, ivVector);
ciphertext = cipher.doFinal(pass.getBytes());
} catch (Exception e) {
throw new RuntimeException(e);
}
return ciphertext;
}

public String decryptPass2(byte[] input) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException,


NoSuchPaddingException, UnsupportedEncodingException {
if (input == null || input.length == 0) {
return null;
}
computeDigest("SecretWord", MessageDigestAlgorithm.MD5);
computeDigest("SecretWord", MessageDigestAlgorithm.SHA);

computeCheckSum("SecretWord", CheckSumAlgorithm.Adler32);
computeCheckSum("SecretWord", CheckSumAlgorithm.CRC32);

//-------------- Testing encryption & decryption --------------


DESedeKeySpec keyspec = new DESedeKeySpec(share_key.getBytes());
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance(EncryptionAlgorithm.DESede.name());
SecretKey deskey = keyfactory.generateSecret(keyspec);
// Create an 8-byte initialization vector
byte[] iv = new byte[]{(byte) 0x8E, 0x12, 0x39, (byte) 0x9C, 0x07, 0x72, 0x6F, 0x5A};
IvParameterSpec ivVector = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance(EncryptionAlgorithm.DESede.name() + "/" + EncryptionMode.CBC.name() + "/"
+ EncryptionPadding.PKCS5Padding.name());
byte[] cleartext = null;
try {
cipher.init(Cipher.DECRYPT_MODE, deskey, ivVector);
cleartext = cipher.doFinal(input);
} catch (Exception e) {
logger.error("Exception while decrypting data:" + hexEncode(input) + " Exception:" + e.getMessage());
throw new RuntimeException(e);
}
return new String(cleartext);
}

public String Encrypt(String str) {


String result = "";
try {
result = hexEncode(encryptPass2(str));
} catch (Exception ex) {
logger.error("Error while trying to Encrypt '" + str + "': " + ex.getMessage());
result = "";
}

return result;
}

public String Decrypt(String str) {


String result = "";
try {
result = decryptPass2(hexStringToByteArray(str));
} catch (Exception ex) {
logger.error("Error while trying to Encrypt '" + str + "': " + ex.getMessage());
result = "";
}

return result;
}

private TextSecurity() {

private static TextSecurity mMe = null;

public static TextSecurity getInstance() {


if (mMe == null) {
mMe = new TextSecurity();
mMe.share_key = "IOUHH^*&^%gfgbmds'/.,/)+(38939bvmasbfmGHKGJG823jljbnb2vnb2=//.41,5";
}
return mMe;
}

public void setKey(String key) {


this.share_key = key;
}

public void setDefaultKey() {


this.share_key = "IOUHH^*&^%gfgbmds'/.,/)+(38939bvmasbfmGHKGJG823jljbnb2vnb2=//.41,5";
}

public static void main(String[] args) throws Exception {


TextSecurity sec = TextSecurity.getInstance();
String str1 = "payway";
String str2 = "payway@123";
String str3 = "123456";
String str4 = "100";

String en = sec.Encrypt(str1);
System.out.println("'" + str1 + "' -> '" + en + "'");
String en2 = sec.Encrypt(str2);
System.out.println("'" + str2 + "' -> '" + en2 + "'");
String en3 = sec.Encrypt(str3);
System.out.println("'" + str3 + "' -> '" + en3 + "'");
String en4 = sec.Encrypt(str4);
System.out.println("'" + str4 + "' -> '" + en4 + "'");
}
}
1.6 Describe Response of webservice API
1.6.1 Result of authentication and connection to firewall layer of webservice
error description Example
0 success This is result of calling webservice:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:gwOperationResponse xmlns:ns2="http://webservice.bccsgw.viettel.com/">
<Result>
<error>0</error>
<description>success</description>
<return/>
<original><![CDATA[<?xml version="1.0" ?><S:Envelope
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getAccountInfoResponse
xmlns:ns2="http://ws.payway.viettel.com/"><return><description>Successful</
description><responseCode>0000</responseCode><result><balance>31651011</balance></
result></return></ns2:getAccountInfoResponse></S:Body></S:Envelope>]]></original>
</Result>
</ns2:gwOperationResponse>
</S:Body>
</S:Envelope>
Other Fail This is result of calling webservice:
(6003,
2001…) <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:gwOperationResponse xmlns:ns2="http://webservice.bccsgw.viettel.com/">
<Result>
<error>6003</error>
<description>Login failed. Please check user name, password and your IP Address and
contact the administrator</description>
</Result>
</ns2:gwOperationResponse>
</S:Body>
</S:Envelope>

1.6.2 Result of execute webservice

responseCode description Example


0000 success This is result of calling webservice:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:gwOperationResponse xmlns:ns2="http://webservice.bccsgw.viettel.com/">
<Result>
<error>0</error>
<description>success</description>
<return/>
<original><![CDATA[<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body>
<ns2:getAccountInfoResponse xmlns:ns2="http://ws.payway.viettel.com/"><return>
<description>Successful</description>
<responseCode>0000</responseCode>
<result><balance>31651011</balance></result>
</return></ns2:getAccountInfoResponse></S:Body>
</S:Envelope>]]></original>
</Result>
</ns2:gwOperationResponse>
</S:Body>
</S:Envelope>
-5 Fail Source Msisdn is invalid
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:gwOperationResponse xmlns:ns2="http://webservice.bccsgw.viettel.com/">
<Result>
<error>0</error>
<description>success</description>
<return/>
<original><![CDATA[<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/
soap/envelope/"><S:Body>
<ns2:getAccountInfoResponse xmlns:ns2=
"http://ws.payway.viettel.com/">
<return><description>Msisdn invalid 61008422</description>
<responseCode>-5</responseCode>
</return></ns2:getAccountInfoResponse>
</S:Body></S:Envelope>]]></original>
</Result>
</ns2:gwOperationResponse>
</S:Body>
</S:Envelope>
-1 Fail Login information is not correct

<error>0</error
<description>Login information is not correct</description><responseCode>-1</responseCode>
1 Fail Target Msisdn invalid

<error>0</error
<description>Msisdn invalid 824857 </description><responseCode>1</responseCode>
3 Fail <error>0</error>
<description>ICCID is incorrect</description><responseCode>3</responseCode>
11 Fail <error>0</error> <responseCode>1</responseCode>
<description>Charge unsuccessful Can not find target ISDN: 62227460</description>
12 Fail <error>0</error> <responseCode>3</responseCode>
<description>Unsuccessful! You have not had anypay account</description>
13 Fail <error>0</error> <responseCode>13</responseCode>
<description>Unsuccessful! You do not have enough money in anypay account</description>
14 Fail Reason: amount is not correct format
- It is integer number, example: 100 or 200, not 200.5, 200.0
- Amount is between 1 and 1000000

Response:
<error>0</error> <responseCode>3</responseCode>
<description>Amount must be equal or larger than 1 BIF and less than or equal 1 000 000
BIF</description>
1111 Fail Reason: System is overload
<error>0</error> <responseCode>1111</responseCode>
<description>Unsucessful</description>

1.6.3 Conclusion about result of calling webservice


Result totally error responseCode
Success 0 0000
Fail Other Any value
(6003, 2001…)
Fail Any value Other
(-5, -6, ..)
1.7. Template code for integration with these APIs

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package qrcode;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.openide.util.Exceptions;

/**
*
* @author Administrator
*/
public class AnypayPubClient {

static Logger logger = Logger.getLogger(AnypayPubClient.class);


static String XML_REQUEST = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:web=\"http://webservice.bccsgw.viettel.com/\">\n"
+ " <soapenv:Header/>\n"
+ " <soapenv:Body>\n"
+" <web:gwOperation>\n"
+" <Input>\n"
+" <username>%s</username>\n"
+ "<password>%s</password>\n"
+" <wscode>%s</wscode>\n"
+" <param name=\"username\" value=\"%s\"/>\n"
+ "<param name=\"password\" value=\"%s\"/>\n"
+" <param name=\"data\" value=\"%s\"/>\n"
+" <!--Optional:-->\n"
+" <rawData>?</rawData>\n"
+" </Input>\n"
+" </web:gwOperation>\n"
+ " </soapenv:Body>\n"
+ "</soapenv:Envelope>";

public static String callWsClient() {


String username = "fdsafdklsgjfdjskglfds";
String password = "jhgfjgy5ytghfrghf";
String wscode = "getAccountInfo";
String p_username = "8DSFSDFDSKFJS";
String p_password = "5KLJFDSFSD";
String data = "61002422|8925708000289021520|F9743F2A674BF0D3";
String req = String.format(XML_REQUEST, username, password, wscode, p_username, p_password, data);
logger.info(req);
StringBuffer line = new StringBuffer();
try {

//Create socket
String hostname = "10.225.6.73";
int port = 8128;
InetAddress addr = InetAddress.getByName(hostname);
Socket sock = new Socket(addr, port);
sock.setSoTimeout(5 * 60 * 1000);
//Send header
String path = "/BCCSGateway?wsdl";
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(), "UTF-8"));
// You can use "UTF8" for compatibility with the Microsoft virtual machine.
wr.write("POST " + path + " HTTP/1.0\r\n");
wr.write("Host: " + hostname + "\r\n");
wr.write("Content-Length: " + req.length() + "\r\n");
wr.write("Content-Type: text/xml; charset=\"utf-8\"\r\n");
wr.write("\r\n");

//Send data
wr.write(req);
wr.flush();
// Response
BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String strtemp = "";
while ((strtemp = rd.readLine()) != null) {
line.append(strtemp);
}
} catch (Exception e) {
e.printStackTrace();
}

String rs = line.toString();
rs = htmlspecialcharsDecode(rs);
logger.info(rs);
return rs;
}

public static void main(String arg[]) {


try {
String KEY_SUCCESSFULL_AUTHEN = "<error>0</error>";
String KEY_SUCCESSFULL_EXECUTE = "<responseCode>0000</responseCode>";
int retry = 0;
while (retry < 10) {
String rs = callWsClient();
//This case is success
if (rs.contains(KEY_SUCCESSFULL_AUTHEN) && rs.contains(KEY_SUCCESSFULL_EXECUTE)) {
return;//Success and Finish call webservice
} else { //in case of fail
retry++;
Thread.sleep(2 * 1000); //try again in 2 seconds
}
}
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}

}
static Map<String, String> html_specialchars_table = new Hashtable<String, String>();

static {
html_specialchars_table.put("&lt;", "<");
html_specialchars_table.put("&gt;", ">");
html_specialchars_table.put("&amp;", "&");
html_specialchars_table.put("&quot;", "\"");
html_specialchars_table.put("&apos;", "'");
}

static String htmlspecialcharsDecode(String s) {


Set<String> en = html_specialchars_table.keySet();
for (String key : en) {
String val = html_specialchars_table.get(key);
s = s.replaceAll(key, val);
}
return s;
}
}

You might also like