Skip to content

Commit 6bc462d

Browse files
author
Mohit Goyal
committed
v1.0 release commit
0 parents  commit 6bc462d

453 files changed

Lines changed: 40754 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.iml
2+
*.DS_Store
3+
*.idea/

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Visa Developer Platform - Java Sample Code
2+
3+
This repository hosts the Java sample code for the [Visa Developer Platform](https://developer.visa.com/).
4+
5+
If you are new to the Visa Developer Platform, please take a look at our [Getting Started Guide](https://developer.visa.com/vdpguide#get-started-overview) which walks you through the steps to make a basic helloworld API call.
6+
7+
Once you are comfortable with the same and have also explored the documentation to know about the various API that Visa exposes, you can then use the Java sample code on this site as a starting point in your journey towards building your application.
8+
9+
Sample code is available for the following capabilities:
10+
11+
* [Visa Direct](https://developer.visa.com/capabilities/visa_direct)
12+
* [Visa Merchant Offers Resource Center](https://developer.visa.com/capabilities/vmorc)
13+
* [Merchant Search](https://developer.visa.com/capabilities/merchant_search)
14+
15+
## Getting Started
16+
17+
The instructions will guide you make the first call to VDP from your local machine for development and testing purposes
18+
19+
### Prerequisites
20+
21+
* Java JDK: ([Version 1.8.0 or above](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html))
22+
* Build Tools: Maven ([Version 3.0.5 or above](https://maven.apache.org/download.cgi))
23+
24+
### Setup & Installation
25+
26+
* Configure the credentials required
27+
28+
Edit the file /Samples/src/main/resources/auth_config.xml to set the fields shown below. Refer the [Getting Started Guide](https://developer.visa.com/vdpguide#get-started-overview) to get the credentials.
29+
30+
```
31+
<username></username>
32+
<password></password>
33+
<keystore_path></keystore_path>
34+
<keystore_password></keystore_password>
35+
<private_key_password></private_key_password>
36+
```
37+
* You can also follow the below steps for quickly getting the credentials:
38+
* Login to https://developer.visa.com
39+
* Navigate to https://developer.visa.com/portal/#console
40+
* Click on create new project
41+
* Enter the project name and select the following products:
42+
* Visa Direct
43+
* Visa Merchant Offers Resource Center
44+
* Merchant Search
45+
* Click on create project
46+
* A pop-up will appear, click continue
47+
* Click on Download/Copy Certificate Private Key to download the key (From here on referred as **privateKey.pem**)
48+
* After the download is complete, confirm that the keys are downloaded and continue
49+
* Once redirected to the application page, do the following:
50+
* Under User ID and Password section, Note down the User ID (**USERNAME**)
51+
* Under User ID and Password section, Note down the Password (**PASSWORD**)
52+
* Under Certificates section, download the certification with the same name as that of the application (From here on referred as cert.pem)
53+
* Under Certificates section, download the Visa Development Platform Certificate (From here on referred as VDPCA-SBX.pem)
54+
* Move to your download folder (**KEYSTORE_PATH**) and perform the following actions to generate the jks file:
55+
* openssl pkcs12 -export -in cert.pem -inkey "privateKey.pem" -certfile cert.pem -out key.p12
56+
* Note the password asked in above step (X)
57+
* keytool -importkeystore -srckeystore key.p12 -srcstoretype PKCS12 -destkeystore key.jks
58+
* Enter the destination key store password and note it. (**KYESTORE_PASSOWORD**)
59+
* When asked for source key store password enter X.
60+
* keytool -import -alias ejbca -keystore key.jks -file VDPCA-SBX.pem -storepass <password>
61+
* Note the password entered in the above step. (**PRIVATE_KEY_PASSWORD**)
62+
63+
64+
* Run the below command to install and resolve all dependencies
65+
```
66+
mvn clean install
67+
```
68+
69+
## Running the tests
70+
```
71+
mvn test -pl Samples
72+
```
73+
74+
## Built With
75+
76+
* [Maven](https://maven.apache.org/) - Dependency Management
77+
78+
79+
## Versioning
80+
81+
**1.0.0**
82+
83+
For the versions available, see the [releases on this repository](https://github.com/visa/java-sample-code/releases).
84+
85+
## Authors
86+
87+
**Visa Developer Platform**
88+
89+
See also the list of [contributors](https://github.com/visa/java-sample-code/graphs/contributors) who participated in this project.
90+
91+
92+
## Acknowledgments
93+
94+
* The following repository only serves the need of calling VDP API's from Java as sample code.

Samples/pom.xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>Samples</groupId>
7+
<packaging>jar</packaging>
8+
<artifactId>Samples</artifactId>
9+
<version>1.0.0</version>
10+
<dependencies>
11+
<dependency>
12+
<groupId>com.visa</groupId>
13+
<artifactId>vdp-sample-java-funds-transfer</artifactId>
14+
<version>1.0.0-SNAPSHOT</version>
15+
</dependency>
16+
<dependency>
17+
<groupId>com.visa</groupId>
18+
<artifactId>vdp-sample-java-merchant-search</artifactId>
19+
<version>1.0.0-SNAPSHOT</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>com.visa</groupId>
23+
<artifactId>vdp-sample-java-mvisa</artifactId>
24+
<version>1.0.0-SNAPSHOT</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>com.visa</groupId>
28+
<artifactId>vdp-sample-java-offers-data-api</artifactId>
29+
<version>1.0.0-SNAPSHOT</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>com.visa</groupId>
33+
<artifactId>vdp-sample-java-query</artifactId>
34+
<version>1.0.0-SNAPSHOT</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>com.visa</groupId>
38+
<artifactId>vdp-sample-java-reference-data-api</artifactId>
39+
<version>1.0.0-SNAPSHOT</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.visa</groupId>
43+
<artifactId>vdp-sample-java-refund-api</artifactId>
44+
<version>1.0.0-SNAPSHOT</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.visa</groupId>
48+
<artifactId>vdp-sample-java-reports-api</artifactId>
49+
<version>1.0.0-SNAPSHOT</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>com.visa</groupId>
53+
<artifactId>vdp-sample-java-storm-api</artifactId>
54+
<version>1.0.0-SNAPSHOT</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.visa</groupId>
58+
<artifactId>vdp-sample-java-ws</artifactId>
59+
<version>1.0.0-SNAPSHOT</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.visa</groupId>
63+
<artifactId>vdp-sample-java-linked-api</artifactId>
64+
<version>1.0.0-SNAPSHOT</version>
65+
</dependency>
66+
<dependency>
67+
<groupId>junit</groupId>
68+
<artifactId>junit</artifactId>
69+
<version>4.11</version>
70+
</dependency>
71+
</dependencies>
72+
</project>

Samples/src/main/java/Auth.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.io.IOException;
2+
import java.util.*;
3+
import java.io.File;
4+
import javax.xml.parsers.*;
5+
6+
import org.w3c.dom.*;
7+
import org.xml.sax.SAXException;
8+
9+
public class Auth {
10+
public HashMap<String, String> getAuthCreds() throws IOException {
11+
HashMap<String, String> authInstance = new HashMap<String, String>();
12+
try {
13+
ClassLoader classLoader = this.getClass().getClassLoader();
14+
File authFile = new File(classLoader.getResource("auth_config.xml").getFile());
15+
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
16+
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
17+
Document doc = dBuilder.parse(authFile);
18+
doc.getDocumentElement().normalize();
19+
authInstance.put("username", doc.getElementsByTagName("username").item(0).getTextContent());
20+
authInstance.put("password", doc.getElementsByTagName("password").item(0).getTextContent());
21+
authInstance.put("keystore_path", doc.getElementsByTagName("keystore_path").item(0).getTextContent());
22+
authInstance.put("keystore_password", doc.getElementsByTagName("keystore_password").item(0).getTextContent());
23+
authInstance.put("private_key_password", doc.getElementsByTagName("private_key_password").item(0).getTextContent());
24+
return authInstance;
25+
} catch (Exception e) {
26+
System.out.println(e.getStackTrace());
27+
throw new IOException("Failed to load Auth Config File");
28+
}
29+
}
30+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.*;
2+
import java.io.IOException;
3+
import com.visa.developer.sample.mvisa.*;
4+
import com.visa.developer.sample.mvisa.api.*;
5+
6+
public class cash_in_push_paymentsPOST {
7+
8+
public static int main(String[] args) throws IOException, ApiException {
9+
HashMap<String,String> auth = new Auth().getAuthCreds();
10+
MvisaApi api = new MvisaApi(auth);
11+
String payload = "{"
12+
+" \"transactionIdentifier\": \"381228649430015\","
13+
+" \"transactionCurrencyCode\": \"USD\","
14+
+" \"systemsTraceAuditNumber\": \"313042\","
15+
+" \"senderReference\": \"1234\","
16+
+" \"senderName\": \"Mohammed Qasim\","
17+
+" \"senderAccountNumber\": \"4541237895236\","
18+
+" \"retrievalReferenceNumber\": \"430000367618\","
19+
+" \"recipientPrimaryAccountNumber\": \"4123640062698797\","
20+
+" \"merchantCategoryCode\": \"4829\","
21+
+" \"localTransactionDateTime\": \"2017-10-13T08:18:50\","
22+
+" \"cardAcceptor\": {"
23+
+" \"name\": \"Card Accpector ABC\","
24+
+" \"idCode\": \"ID-Code123\","
25+
+" \"address\": {"
26+
+" \"country\": \"IND\","
27+
+" \"city\": \"Bangalore\""
28+
+" }"
29+
+" },"
30+
+" \"businessApplicationId\": \"CI\","
31+
+" \"amount\": \"124.05\","
32+
+" \"acquiringBin\": \"400171\","
33+
+" \"acquirerCountryCode\": \"643\""
34+
+"}";
35+
String response = api.cashInPushPayments(payload);
36+
System.out.print(response);
37+
return 0;
38+
}
39+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.*;
2+
import java.io.IOException;
3+
import com.visa.developer.sample.mvisa.*;
4+
import com.visa.developer.sample.mvisa.api.*;
5+
6+
public class cash_in_push_payments_getGET {
7+
8+
public static int main(String[] args) throws IOException, ApiException {
9+
HashMap<String,String> auth = new Auth().getAuthCreds();
10+
MvisaApi api = new MvisaApi(auth);
11+
String statusIdentifier = "21042016";
12+
String response = api.cashInPushPaymentsGet(statusIdentifier);
13+
System.out.print(response);
14+
return 0;
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.*;
2+
import java.io.IOException;
3+
import com.visa.developer.sample.mvisa.*;
4+
import com.visa.developer.sample.mvisa.api.*;
5+
6+
public class cash_out_payments_getGET {
7+
8+
public static int main(String[] args) throws IOException, ApiException {
9+
HashMap<String,String> auth = new Auth().getAuthCreds();
10+
MvisaApi api = new MvisaApi(auth);
11+
String statusIdentifier = "21042016";
12+
String response = api.cashOutPaymentsGet(statusIdentifier);
13+
System.out.print(response);
14+
return 0;
15+
}
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.*;
2+
import java.io.IOException;
3+
import com.visa.developer.sample.mvisa.*;
4+
import com.visa.developer.sample.mvisa.api.*;
5+
6+
public class cash_out_push_payments_postPOST {
7+
8+
public static int main(String[] args) throws IOException, ApiException {
9+
HashMap<String,String> auth = new Auth().getAuthCreds();
10+
MvisaApi api = new MvisaApi(auth);
11+
String payload = "{"
12+
+" \"transactionIdentifier\": \"381228649430015\","
13+
+" \"transactionCurrencyCode\": \"USD\","
14+
+" \"systemsTraceAuditNumber\": \"567889\","
15+
+" \"senderReference\": \"REFNUM123\","
16+
+" \"senderName\": \"Mohammed Qasim\","
17+
+" \"senderAccountNumber\": \"456789123456\","
18+
+" \"retrievalReferenceNumber\": \"412123412878\","
19+
+" \"recipientPrimaryAccountNumber\": \"4123640062698797\","
20+
+" \"merchantCategoryCode\": \"6012\","
21+
+" \"localTransactionDateTime\": \"2017-10-13T08:18:50\","
22+
+" \"cardAcceptor\": {"
23+
+" \"name\": \"mVisa cashout\","
24+
+" \"idCode\": \"CA-IDCode-77765\","
25+
+" \"address\": {"
26+
+" \"country\": \"IND\","
27+
+" \"city\": \"mVisa cashout\""
28+
+" }"
29+
+" },"
30+
+" \"businessApplicationId\": \"CO\","
31+
+" \"amount\": \"124.05\","
32+
+" \"acquiringBin\": \"400171\","
33+
+" \"acquirerCountryCode\": \"643\""
34+
+"}";
35+
String response = api.cashOutPushPaymentsPost(payload);
36+
System.out.print(response);
37+
return 0;
38+
}
39+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.*;
2+
import java.io.IOException;
3+
import com.visa.developer.sample.mvisa.*;
4+
import com.visa.developer.sample.mvisa.api.*;
5+
6+
public class merchant_push_payment_getGET {
7+
8+
public static int main(String[] args) throws IOException, ApiException {
9+
HashMap<String,String> auth = new Auth().getAuthCreds();
10+
MvisaApi api = new MvisaApi(auth);
11+
String statusIdentifier = "21042016";
12+
String response = api.merchantPushPaymentGet(statusIdentifier);
13+
System.out.print(response);
14+
return 0;
15+
}
16+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import java.util.*;
2+
import java.io.IOException;
3+
import com.visa.developer.sample.mvisa.*;
4+
import com.visa.developer.sample.mvisa.api.*;
5+
6+
public class merchant_push_payments_postPOST {
7+
8+
public static int main(String[] args) throws IOException, ApiException {
9+
HashMap<String,String> auth = new Auth().getAuthCreds();
10+
MvisaApi api = new MvisaApi(auth);
11+
String payload = "{"
12+
+" \"transactionIdentifier\": \"381228649430015\","
13+
+" \"transactionCurrencyCode\": \"INR\","
14+
+" \"systemsTraceAuditNumber\": \"451035\","
15+
+" \"senderReference\": \"\","
16+
+" \"senderName\": \"Jasper\","
17+
+" \"senderAccountNumber\": \"4027290077881587\","
18+
+" \"secondaryId\": \"123TEST\","
19+
+" \"retrievalReferenceNumber\": \"412770451035\","
20+
+" \"recipientPrimaryAccountNumber\": \"4123640062698797\","
21+
+" \"recipientName\": \"Jasper\","
22+
+" \"purchaseIdentifier\": {"
23+
+" \"type\": \"1\","
24+
+" \"referenceNumber\": \"REF_123456789123456789123\""
25+
+" },"
26+
+" \"localTransactionDateTime\": \"2017-10-13T08:18:50\","
27+
+" \"feeProgramIndicator\": \"123\","
28+
+" \"cardAcceptor\": {"
29+
+" \"name\": \"Visa Inc. USA-Foster City\","
30+
+" \"idCode\": \"CA-IDCode-77765\","
31+
+" \"address\": {"
32+
+" \"country\": \"IND\","
33+
+" \"city\": \"KOLKATA\""
34+
+" }"
35+
+" },"
36+
+" \"businessApplicationId\": \"MP\","
37+
+" \"amount\": \"124.05\","
38+
+" \"acquiringBin\": \"408972\","
39+
+" \"acquirerCountryCode\": \"356\""
40+
+"}";
41+
String response = api.merchantPushPaymentsPost(payload);
42+
System.out.print(response);
43+
return 0;
44+
}
45+
}

0 commit comments

Comments
 (0)