Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

.

  • Loading branch information...
commit 3463fad208d631f20de82db0ee015e3187730609 1 parent e901f79
attdevsupport authored
View
3  Payment/Java/app1/CallBack/142464.txt
@@ -0,0 +1,3 @@
+79e89e06-6e28-442f-a684-a2b5c55eb669
+SuccesfulRefund
+7017401752702162
View
16 Payment/Java/app1/getLatestNotifications.jsp
@@ -1,3 +1,10 @@
+<%
+//Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
+//TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
+//Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
+//For more information contact developer.support@att.com
+%>
+
<%@ page contentType="application/json" language="java" %><%@ page import="java.io.*" %><%@ page import="java.util.Arrays" %><%@ page import="java.util.Collections" %><%@ page import="java.util.Comparator" %><%@ include file="config.jsp" %><%
String notificationId = "";
@@ -16,7 +23,6 @@ Collections.reverse(Arrays.asList(files));
if(directory.listFiles().length>0) {
-//if(total> 0) {
int i = 0;
for(File notificationFile : files){
String notificationFileName = notificationFile.getName();
@@ -24,14 +30,14 @@ if(directory.listFiles().length>0) {
notificationId = (inFile1.readLine()).trim();
inFile1.close();
- if((i==directory.listFiles().length-1)) { // || (i==9)
+ if((i==directory.listFiles().length-1)) {
%>{"path":"Notifications/<%=notificationFileName%>","notificationId":"<%=notificationId%>"}]}<%
} else {
%>{"path":"Notifications/<%=notificationFileName%>","notificationId":"<%=notificationId%>"},<%
}
i += 1;
- // if(i==9 )
- // break;
+ if(i==9 )
+ break;
}
}
-%>
+%>
View
11 Payment/Java/app1/getLatestTransactions.jsp
@@ -1,3 +1,10 @@
+<%
+//Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
+//TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
+//Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
+//For more information contact developer.support@att.com
+%>
+
<%@ page contentType="application/json" language="java" %><%@ page import="java.io.*" %><%@ page import="java.util.Arrays" %><%@ page import="java.util.Collections" %><%@ page import="java.util.Comparator" %><%@ include file="config.jsp" %><%
String transactionId = "";
String merchantTransactionId = "";
@@ -49,10 +56,10 @@ if(directory.listFiles().length>0) {
%>{"transactionId":"<%=transactionId%>","merchantTransactionId":"<%=merchantTransactionId%>","transactionAuthCode":"<%=transactionAuthCode%>","consumerId":"<%=consumerId%>"},<%
}
i += 1;
- if(i==5)
+ if(i==9)
break;
}
} else {
%>]}<%
}
-%>
+%>
View
41 Payment/Java/app1/listener.jsp
@@ -15,38 +15,37 @@
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="org.apache.commons.codec.binary.Base64" %>
-<%
+<%@ page import="java.util.regex.*"%>
-LinkedHashMap<String, String> paramLinkedMap = new LinkedHashMap<String, String>();
+<%LinkedHashMap<String, String> paramLinkedMap = new LinkedHashMap<String, String>();
try{
-String data=null;
+ String data=null;
-InputStream is = request.getInputStream();
-ByteArrayOutputStream baos = new ByteArrayOutputStream();
-byte buf[] = new byte[1024];
-int letti;
+ InputStream is = request.getInputStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
-while ((letti = is.read(buf)) > 0)
-baos.write(buf, 0, letti);
+ byte buf[] = new byte[1024];
+ int letti;
-data = new String(baos.toByteArray());
-String notificationId = data.split("<hub:notificationId>")[1].split("</hub:notificationId>")[0].substring(2);
+ while ((letti = is.read(buf)) > 0)
+ {
+ baos.write(buf, 0, letti);
+ }
+ data = new String(baos.toByteArray());
+ String getSplit =data.split("<hub:notificationId>")[1];
+ String notificationId = getSplit.substring(0,36);
-System.out.print("the data is : " + data);
-//String print = data;
+ int random = (int)(Math.random()*10000000);
+ PrintWriter outWrite = new PrintWriter(new BufferedWriter(new FileWriter(application.getRealPath("/Notifications/" + random + ".txt"))), false);
+ String toSave = notificationId;
+ outWrite.write(toSave);
-int random = (int)(Math.random()*10000000);
-
-PrintWriter outWrite = new PrintWriter(new BufferedWriter(new FileWriter(application.getRealPath("/Notifications/" + random + ".txt"))), false);
-String toSave = notificationId;
-outWrite.write(toSave);
-
-outWrite.close();
+ outWrite.close();
}catch(Exception e){
}
-%>
+%>
View
2  Payment/Java/app1/notary.jsp
@@ -166,7 +166,7 @@ Feature 1: Sign Payload</h2>
<div id="footer">
- <div style="float: right; width: 20%; font-size: 9px; text-align: right">Powered by AT&amp;T Virtual Mobile</div>
+ <div style="float: right; width: 20%; font-size: 9px; text-align: right">Powered by AT&amp;T Cloud Architecture</div>
<p>&#169; 2012 AT&amp;T Intellectual Property. All rights reserved. <a href="http://developer.att.com/" target="_blank">http://developer.att.com</a>
<br>
The Application hosted on this site are working examples intended to be used for reference in creating products to consume AT&amp;T Services and not meant to be used as part of your product. The data in these pages is for test purposes only and intended only for use as a reference in how the services perform.
View
222 Payment/Java/app1/singlepay.jsp
@@ -37,6 +37,8 @@
<%@ page import="java.io.*" %>
<%@ page import="java.util.Random" %>
<%@ include file="getToken.jsp" %>
+<%@ page import="java.util.Arrays" %><%@ page import="java.util.Collections" %><%@ page import="java.util.Comparator" %>
+
<%
String newTransaction = request.getParameter("newTransaction");
@@ -263,7 +265,6 @@ if(getTransactionType==3)
url = FQDN + "/rest/3/Commerce/Payment/Transactions/TransactionId/" + trxId;
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
-//method.setQueryString("access_token=" + accessToken);
method.addRequestHeader("Authorization", "Bearer " + accessToken);
method.addRequestHeader("Accept","application/json");
int statusCode = client.executeMethod(method);
@@ -357,7 +358,7 @@ if(true) {
<tr>
<td class="cell" align="right">
<% if(transaction.getString("transactionId").length() > 4)
- { %>
+ { %>
<input type="radio" name="trxIdRefund" value="<%=transaction.getString("transactionId")%>" checked /><%=transaction.getString("transactionId")%>
</td>
<td></td>
@@ -404,7 +405,6 @@ if(true) {
String url = FQDN + "/rest/3/Commerce/Payment/Transactions/" + trxIdRefund;
HttpClient client = new HttpClient();
PutMethod method = new PutMethod(url);
- //method.setQueryString("access_token=" + accessToken + "&Action=refund");
method.addRequestHeader("Authorization", "Bearer " + accessToken);
method.addRequestHeader("Content-Type","application/json");
method.addRequestHeader("Accept","application/json");
@@ -461,30 +461,91 @@ if(true) {
<div id="content">
<h2><br />Feature 4: Notifications</h2>
-
</div>
</div>
-<form method="GET" name="refreshNotifications" >
-<div id="navigation"><br/>
+<form method="post" name="refreshNotifications" action="singlepay.jsp">
+<div id="navigation" align="center">
-<div align="center"><table style="width: 650px" cellpadding="1" cellspacing="1" border="0">
+<table style="width: 750px" cellpadding="1" cellspacing="1" border="0">
<thead>
<tr>
- <th style="width: 100px" class="cell"><strong>Notification ID</strong></th>
- <th style="width: 100px" class="cell"><strong>Notification Type</strong></th>
- <th style="width: 125px" class="cell"><strong>Transaction ID</strong></th>
-
-
-</tr>
+<th class="cell" align="left"><strong>Notification ID</strong></th>
+
+<th class="cell" align="left"><strong>Notification Type</strong></th>
+<th style="width: 100px" class="cell"></th>
+<th class="cell" align="left"><strong>Transaction ID</strong></th>
+
+</td>
+ </tr>
</thead>
- </br>
- </br>
- </br>
<tbody>
<%
-//if(true)
-//{
-//String notificationId = "";
+if(true)
+{
+ File directory = new File(application.getRealPath("/CallBack/"));
+ File[] files = directory.listFiles();
+ Arrays.sort(files, new Comparator<File>(){
+ public int compare(File f1, File f2)
+ {
+ return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
+ } });
+ Collections.reverse(Arrays.asList(files));
+
+ if(directory.listFiles().length>0) {
+ int i = 0;
+
+ String notID="";
+ String notType="";
+ String transID="";
+
+ for(File callbackFile : files){
+ String callbackFileName = callbackFile.getName();
+ RandomAccessFile inFile1 = new RandomAccessFile(application.getRealPath("CallBack/" + callbackFileName),"r");
+ notID = (inFile1.readLine()).trim();
+ notType=(inFile1.readLine()).trim();
+ transID=(inFile1.readLine()).trim();
+
+ inFile1.close();
+ i += 1;
+ %>
+ <tr>
+ <td class="cell" align="left">
+ <%=notID%>
+
+ </td>
+ <td class="cell" align="left">
+ <%=notType%>
+ </td>
+
+ </td>
+ <td></td>
+ <td class="cell" align="left"><%=transID%></td>
+ </tr>
+
+ <%
+
+ if(i==5 ) //Print latest 5 transactions
+ break;
+ }
+ %>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="cell"><button type="submit" name="refreshNotifications" value="refreshNotifications">Refresh</button>
+ </td
+ </tr>
+ </tbody></table>
+
+
+</form>
+</div>
+<br clear="all" />
+</form></div>
+
+<%
+ }
+
String notificationType = "";
String transactionId = "";
@@ -492,116 +553,67 @@ String transactionId = "";
HttpClient client1 = new HttpClient();
GetMethod method1 = new GetMethod(url1);
int statusCode2 = client1.executeMethod(method1);
- //client1.executeMethod(method1);
JSONObject jsonResponse1 = new JSONObject(method1.getResponseBodyAsString());
JSONArray notificationList = new JSONArray(jsonResponse1.getString("notificationList"));
String totalNumberOfNotifications = jsonResponse1.getString("totalNumberOfNotifications");
System.out.println("method1.getResponseBodyAsString()"+method1.getResponseBodyAsString());
- // System.out.println(statusCode2);
-
+
method1.releaseConnection();
-%>
-</tbody>
-</table>
-</div>
-<div id="extra"><br/>
-
-<table border="0" width="100%">
- <tbody>
- <tr>
- <td class="cell"><button type="submit" name="refreshNotifications">Refresh</button>
- </td>
- </tr>
- </tbody></table>
-
-</div>
-<br clear="all" />
-</form></div>
-<%
-String not = "";
+ String not = "";
if(refreshNotifications!=null) {
for(int i=0; i<notificationList.length(); i++)
{
JSONObject notification = new JSONObject(notificationList.getString(i));
- //THE GET REQUEST///////
+
notificationId = notification.getString("notificationId");
not = notificationId.trim();
- String url = FQDN + "/rest/3/Commerce/Payment/Notifications/" + not;
- System.out.println(url);
+
+ String url = FQDN + "/rest/3/Commerce/Payment/Notifications/" + not; //Builds the Get Request
HttpClient clients = new HttpClient();
GetMethod methods = new GetMethod(url);
System.out.println("accessToken"+accessToken);
methods.addRequestHeader("Authorization", "Bearer " + accessToken);
methods.addRequestHeader("Accept", "application/json");
int statusCode = clients.executeMethod(methods);
-
- //JSONObject jsonParams = new JSONObject(methods.getResponseBodyAsString());
-
- //notificationType = jsonParams.getString("NotificationType");
- //transactionId = jsonParams.getString("OriginalTransactionId");
-
-
-
+
+
if (statusCode == 200 || statusCode == 201)
{
- %>
- <div class="successWide">
- <strong>successfull: GETnotification </strong><br />
- <%=methods.getResponseBodyAsString()%>
- </div><br/>
- <%
- }
- else
- {
-
- %>
- <div class="errorWide">
- <strong>fail: Failed to GET notification </strong><br />
- <%=methods.getResponseBodyAsString()%>
- </div><br/>
- <%
- }
-
- //THE PUT/////////
- String url2 = FQDN + "/rest/3/Commerce/Payment/Notifications/" + not;
- System.out.println(url2);
- HttpClient client2 = new HttpClient();
- PutMethod method2 = new PutMethod(url2);
- method2.addRequestHeader("Authorization", "Bearer " + accessToken);
- method2.addRequestHeader("Content-Type", "application/json");
- method2.addRequestHeader("Accept", "application/json");
- int statusCode3 = client2.executeMethod(method2);
-
- if(statusCode3==200 || statusCode3==201) {
-
- %>
- <div class="successWide">
- <strong>successfull: acknowledge </strong><br />
- <%=method2.getResponseBodyAsString()%>
- </div><br/>
- <%
- }
- else
- {
-
- %>
- <div class="errorWide">
- <strong>FAIL: failed to acknowledge notification </strong><br />
- <%=method2.getResponseBodyAsString()%>
- </div><br/>
- <%
-
- }
-
-
- methods.releaseConnection();
- method2.releaseConnection();
+ JSONObject jsonResponse = new JSONObject(methods.getResponseBodyAsString());
+ JSONObject getNotificationResponse = jsonResponse.getJSONObject("GetNotificationResponse");
+
+ String noType = getNotificationResponse.getString("NotificationType");
+ String originalTrxId = getNotificationResponse.getString("OriginalTransactionId");
+
+ int random = (int)(Math.random()*10000000);
+ PrintWriter outWrite = new PrintWriter(new BufferedWriter(new FileWriter(application.getRealPath("/CallBack/" + random + ".txt"))), false); //Print Successfull notification details to a file.
+ outWrite.println(not);
+ outWrite.println(noType);
+ outWrite.println(originalTrxId);
+
+ outWrite.close();
+
+ HttpClient client2 = new HttpClient(); //Acknowledge the notification
+ PutMethod method2 = new PutMethod(url);
+ method2.addRequestHeader("Authorization", "Bearer " + accessToken);
+ method2.addRequestHeader("Content-Type", "application/json");
+ method2.addRequestHeader("Accept", "application/json");
+ int statusCode3 = client2.executeMethod(method2);
+
+ if(statusCode3==200 || statusCode3==201)
+ System.out.println("Acknowlegement success ");
+
+ methods.releaseConnection();
+ method2.releaseConnection();
+ }
+
+ }
}
+
}
-//}
%>
View
74 Payment/Java/app2/getLatestNotifications.jsp
@@ -1,65 +1,43 @@
-<%--
-Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
-Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
-For more information contact developer.support@att.com
---%>
+<%
+//Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
+//TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
+//Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
+//For more information contact developer.support@att.com
+%>
<%@ page contentType="application/json" language="java" %><%@ page import="java.io.*" %><%@ page import="java.util.Arrays" %><%@ page import="java.util.Collections" %><%@ page import="java.util.Comparator" %><%@ include file="config.jsp" %><%
+
String notificationId = "";
-String notificationType = "";
-String transactionId = "";
-String merchantTransactionId = "";
-File directory = new File(application.getRealPath("notifications/"));
+File directory = new File(application.getRealPath("/Notifications/"));
File[] files = directory.listFiles();
-if(files.length>0) {
- Arrays.sort(files, new Comparator<File>(){
- public int compare(File f1, File f2)
- {
- return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
- } });
- Collections.reverse(Arrays.asList(files));
-}
+Arrays.sort(files, new Comparator<File>(){
+ public int compare(File f1, File f2)
+ {
+ return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
+ } });
+Collections.reverse(Arrays.asList(files));
%>{"totalNumberOfNotifications":"<%=directory.listFiles().length%>","notificationList":[<%
+
+
if(directory.listFiles().length>0) {
int i = 0;
- for(File imageFile : files){
- String imageFileName = imageFile.getName();
- RandomAccessFile inFile1 = new RandomAccessFile(application.getRealPath("notifications/" + imageFileName),"r");
- notificationId = inFile1.readLine();
- notificationType = inFile1.readLine();
- transactionId = inFile1.readLine();
- merchantTransactionId = inFile1.readLine();
- if(notificationId==null || notificationId.equalsIgnoreCase("null"))
- notificationId = "";
- if(notificationId.indexOf(194)!=-1)
- notificationId = notificationId.substring(0, notificationId.length()-2);
- if(notificationType==null || notificationType.equalsIgnoreCase("null"))
- notificationType = "";
- if(notificationType.indexOf(194)!=-1)
- notificationType = notificationType.substring(0, notificationType.length()-2);
- if(transactionId==null || transactionId.equalsIgnoreCase("null"))
- transactionId = "";
- if(transactionId.indexOf(194)!=-1)
- transactionId = transactionId.substring(0, transactionId.length()-2);
- if(merchantTransactionId==null || merchantTransactionId.equalsIgnoreCase("null"))
- merchantTransactionId = "";
- if(merchantTransactionId.indexOf(194)!=-1)
- merchantTransactionId = merchantTransactionId.substring(0, merchantTransactionId.length()-2);
+ for(File notificationFile : files){
+ String notificationFileName = notificationFile.getName();
+ RandomAccessFile inFile1 = new RandomAccessFile(application.getRealPath("Notifications/" + notificationFileName),"r");
+ notificationId = (inFile1.readLine()).trim();
inFile1.close();
- if((i==directory.listFiles().length-1) || (i==4)) {
- %>{"notificationId":"<%=notificationId%>","notificationType":"<%=notificationType%>","transactionId":"<%=transactionId%>", "merchantTransactionId":"<%=merchantTransactionId%>"}]}<%
+
+ if((i==directory.listFiles().length-1)) {
+ %>{"path":"Notifications/<%=notificationFileName%>","notificationId":"<%=notificationId%>"}]}<%
} else {
- %>{"notificationId":"<%=notificationId%>","notificationType":"<%=notificationType%>","transactionId":"<%=transactionId%>", "merchantTransactionId":"<%=merchantTransactionId%>"},<%
+ %>{"path":"Notifications/<%=notificationFileName%>","notificationId":"<%=notificationId%>"},<%
}
i += 1;
- if(i==5)
+ if(i==9 )
break;
- }
-} else {
- %>]}<%
+ }
}
%>
View
35 Payment/Java/app2/getLatestTransactions.jsp
@@ -1,16 +1,15 @@
-<%--
-Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
-Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
-For more information contact developer.support@att.com
---%>
+<%
+//Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
+//TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
+//Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
+//For more information contact developer.support@att.com
+%>
<%@ page contentType="application/json" language="java" %><%@ page import="java.io.*" %><%@ page import="java.util.Arrays" %><%@ page import="java.util.Collections" %><%@ page import="java.util.Comparator" %><%@ include file="config.jsp" %><%
String transactionId = "";
String merchantTransactionId = "";
String transactionAuthCode = "";
String consumerId = "";
-String MerchantSubscriptionIdList = "";
File directory = new File(application.getRealPath("/transactionData/"));
File[] files = directory.listFiles();
@@ -34,45 +33,33 @@ if(directory.listFiles().length>0) {
merchantTransactionId = inFile1.readLine();
transactionAuthCode = inFile1.readLine();
consumerId = inFile1.readLine();
- MerchantSubscriptionIdList = inFile1.readLine();
-
if(transactionId==null || transactionId.equalsIgnoreCase("null"))
transactionId = "";
if(transactionId.indexOf(194)!=-1)
transactionId = transactionId.substring(0, transactionId.length()-2);
-
if(merchantTransactionId==null || merchantTransactionId.equalsIgnoreCase("null"))
merchantTransactionId = "";
if(merchantTransactionId.indexOf(194)!=-1)
merchantTransactionId = merchantTransactionId.substring(0, merchantTransactionId.length()-2);
-
if(transactionAuthCode==null || transactionAuthCode.equalsIgnoreCase("null"))
transactionAuthCode = "";
if(transactionAuthCode.indexOf(194)!=-1)
transactionAuthCode = transactionAuthCode.substring(0, transactionAuthCode.length()-2);
-
if(consumerId==null || consumerId.equalsIgnoreCase("null"))
consumerId = "";
if(consumerId.indexOf(194)!=-1)
consumerId = consumerId.substring(0, consumerId.length()-2);
-
- if(MerchantSubscriptionIdList==null || MerchantSubscriptionIdList.equalsIgnoreCase("null"))
- MerchantSubscriptionIdList = "";
- if(MerchantSubscriptionIdList.indexOf(194)!=-1)
- MerchantSubscriptionIdList = MerchantSubscriptionIdList.substring(0, MerchantSubscriptionIdList.length()-2);
-
inFile1.close();
-
- if((i==directory.listFiles().length-1) || (i==5)) {
- %>{"transactionId":"<%=transactionId%>","merchantTransactionId":"<%=merchantTransactionId%>","transactionAuthCode":"<%=transactionAuthCode%>","consumerId":"<%=consumerId%>","MerchantSubscriptionIdList":"<%=MerchantSubscriptionIdList%>"}]}<%
+ if((i==directory.listFiles().length-1) || (i==4)) {
+ %>{"transactionId":"<%=transactionId%>","merchantTransactionId":"<%=merchantTransactionId%>","transactionAuthCode":"<%=transactionAuthCode%>","consumerId":"<%=consumerId%>"}]}<%
} else {
- %>{"transactionId":"<%=transactionId%>","merchantTransactionId":"<%=merchantTransactionId%>","transactionAuthCode":"<%=transactionAuthCode%>","consumerId":"<%=consumerId%>","MerchantSubscriptionIdList":"<%=MerchantSubscriptionIdList%>"},<%
+ %>{"transactionId":"<%=transactionId%>","merchantTransactionId":"<%=merchantTransactionId%>","transactionAuthCode":"<%=transactionAuthCode%>","consumerId":"<%=consumerId%>"},<%
}
i += 1;
- if(i==6)
+ if(i==5)
break;
}
} else {
%>]}<%
}
-%>%>
+%>
View
50 Payment/Java/app2/listener.jsp
@@ -0,0 +1,50 @@
+<%
+//Licensed by AT&T under 'Software Development Kit Tools Agreement.' 2012
+//TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: http://developer.att.com/sdk_agreement/
+//Copyright 2012 AT&T Intellectual Property. All rights reserved. http://developer.att.com
+//For more information contact developer.support@att.com
+%>
+
+<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
+<%@ page import="java.util.*" %>
+<%@ page import="org.apache.commons.fileupload.servlet.*" %>
+<%@ page import="org.apache.commons.fileupload.*" %>
+<%@ page import="org.apache.commons.fileupload.disk.*" %>
+<%@ page import="java.io.*" %>
+<%@ page import="java.net.*" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.*" %>
+<%@ page import="org.apache.commons.codec.binary.Base64" %>
+<%@ page import="java.util.regex.*"%>
+
+<%LinkedHashMap<String, String> paramLinkedMap = new LinkedHashMap<String, String>();
+
+try{
+ String data=null;
+
+ InputStream is = request.getInputStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ byte buf[] = new byte[1024];
+ int letti;
+
+ while ((letti = is.read(buf)) > 0)
+ {
+ baos.write(buf, 0, letti);
+ }
+
+ data = new String(baos.toByteArray());
+ String getSplit =data.split("<hub:notificationId>")[1];
+ String notificationId = getSplit.substring(0,36);
+
+ int random = (int)(Math.random()*10000000);
+ PrintWriter outWrite = new PrintWriter(new BufferedWriter(new FileWriter(application.getRealPath("/Notifications/" + random + ".txt"))), false);
+ String toSave = notificationId;
+ outWrite.write(toSave);
+
+ outWrite.close();
+
+}catch(Exception e){
+
+}
+%>
View
179 Payment/Java/app2/subscription.jsp
@@ -37,6 +37,7 @@
<%@ page import="java.io.*" %>
<%@ page import="java.util.Random" %>
<%@ include file="getToken.jsp" %>
+<%@ page import="java.util.Arrays" %><%@ page import="java.util.Collections" %><%@ page import="java.util.Comparator" %>
<%
String newSubscription = request.getParameter("newSubscription");
@@ -44,6 +45,7 @@ String getSubscriptionStatus = request.getParameter("getSubscriptionStatus");
String getSubscriptionDetails = request.getParameter("getSubscriptionDetails");
String refundSubscription = request.getParameter("refundSubscription");
String refundReasonText = "User did not like product";
+String refreshNotifications = request.getParameter("refreshNotifications");
String trxId = (String) session.getAttribute("trxId");
if(trxId==null || trxId.equalsIgnoreCase("null"))
@@ -51,6 +53,10 @@ if(trxId==null || trxId.equalsIgnoreCase("null"))
String subscriptionId = request.getParameter("subscriptionId");
if(subscriptionId==null || subscriptionId.equalsIgnoreCase("null"))
subscriptionId = "";
+
+String notificationId = request.getParameter("notificationId");
+if(notificationId==null || notificationId.equalsIgnoreCase("null"))
+ notificationId = "";
String merchantTrxId = request.getParameter("merchantTrxId");
if(merchantTrxId==null || merchantTrxId.equalsIgnoreCase("null"))
@@ -614,51 +620,168 @@ if(true) {
<div id="content">
<h2><br />Feature 5: Notifications</h2>
-
</div>
</div>
-<form method="post" name="refreshNotifications" >
-<div id="navigation"><br/>
+<form method="post" name="refreshNotifications" action="subscription.jsp">
+<div id="navigation" align="center">
-<div align="center"><table style="width: 650px" cellpadding="1" cellspacing="1" border="0">
+<table style="width: 750px" cellpadding="1" cellspacing="1" border="0">
<thead>
<tr>
- <th style="width: 100px" class="cell"><strong>Notification ID</strong></th>
- <th style="width: 100px" class="cell"><strong>Notification Type</strong></th>
- <th style="width: 125px" class="cell"><strong>Subscription ID</strong></th>
- <th style="width: 175px" class="cell"><strong>Merchant Subscription ID</strong></th>
+<th class="cell" align="left"><strong>Notification ID</strong></th>
+
+<th class="cell" align="left"><strong>Notification Type</strong></th>
+<th style="width: 100px" class="cell"></th>
+<th class="cell" align="left"><strong>Transaction ID</strong></th>
+
+</td>
</tr>
</thead>
<tbody>
-
-
-
-
-
-
-</tbody>
-</table>
-</div>
-<div id="extra"><br/>
-
-<table border="0" width="100%">
- <tbody>
- <tr>
- <td class="cell"><button type="submit" name="refreshNotifications">Refresh</button>
- </td>
+<%
+if(true)
+{
+ File directory = new File(application.getRealPath("/CallBack/"));
+ File[] files = directory.listFiles();
+ Arrays.sort(files, new Comparator<File>(){
+ public int compare(File f1, File f2)
+ {
+ return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
+ } });
+ Collections.reverse(Arrays.asList(files));
+
+ if(directory.listFiles().length>0) {
+ int i = 0;
+
+ String notID="";
+ String notType="";
+ String transID="";
+
+ for(File callbackFile : files){
+ String callbackFileName = callbackFile.getName();
+ RandomAccessFile inFile1 = new RandomAccessFile(application.getRealPath("CallBack/" + callbackFileName),"r");
+ notID = (inFile1.readLine()).trim();
+ notType=(inFile1.readLine()).trim();
+ transID=(inFile1.readLine()).trim();
+
+ inFile1.close();
+ i += 1;
+ %>
+ <tr>
+ <td class="cell" align="left">
+ <%=notID%>
+
+ </td>
+ <td class="cell" align="left">
+ <%=notType%>
+ </td>
+
+ </td>
+ <td></td>
+ <td class="cell" align="left"><%=transID%></td>
+ </tr>
+
+ <%
+
+ if(i==5 ) //Print latest 5 transactions
+ break;
+ }
+ %>
+ <tr>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td class="cell"><button type="submit" name="refreshNotifications" value="refreshNotifications">Refresh</button>
+ </td
</tr>
</tbody></table>
+
+</form>
</div>
<br clear="all" />
</form></div>
+<%
+ }
+
+String notificationType = "";
+String transactionId = "";
+
+ String url1 = request.getRequestURL().toString().substring(0,request.getRequestURL().toString().lastIndexOf("/")) + "/getLatestNotifications.jsp";
+ HttpClient client1 = new HttpClient();
+ GetMethod method1 = new GetMethod(url1);
+ int statusCode2 = client1.executeMethod(method1);
+ JSONObject jsonResponse1 = new JSONObject(method1.getResponseBodyAsString());
+ JSONArray notificationList = new JSONArray(jsonResponse1.getString("notificationList"));
+ String totalNumberOfNotifications = jsonResponse1.getString("totalNumberOfNotifications");
+ System.out.println("method1.getResponseBodyAsString()"+method1.getResponseBodyAsString());
+
+ method1.releaseConnection();
+
+
+ String not = "";
+ if(refreshNotifications!=null) {
+
+ for(int i=0; i<notificationList.length(); i++)
+ {
+ JSONObject notification = new JSONObject(notificationList.getString(i));
+
+ notificationId = notification.getString("notificationId");
+ not = notificationId.trim();
+
+ String url = FQDN + "/rest/3/Commerce/Payment/Notifications/" + not; //Builds the Get Request
+ HttpClient clients = new HttpClient();
+ GetMethod methods = new GetMethod(url);
+ System.out.println("accessToken"+accessToken);
+ methods.addRequestHeader("Authorization", "Bearer " + accessToken);
+ methods.addRequestHeader("Accept", "application/json");
+ int statusCode = clients.executeMethod(methods);
+
+
+ if (statusCode == 200 || statusCode == 201)
+ {
+ JSONObject jsonResponse = new JSONObject(methods.getResponseBodyAsString());
+ JSONObject getNotificationResponse = jsonResponse.getJSONObject("GetNotificationResponse");
+
+ String noType = getNotificationResponse.getString("NotificationType");
+ String originalTrxId = getNotificationResponse.getString("OriginalTransactionId");
+
+ int random = (int)(Math.random()*10000000);
+ PrintWriter outWrite = new PrintWriter(new BufferedWriter(new FileWriter(application.getRealPath("/CallBack/" + random + ".txt"))), false); //Print Successfull notification details to a file.
+ outWrite.println(not);
+ outWrite.println(noType);
+ outWrite.println(originalTrxId);
+
+ outWrite.close();
+
+ HttpClient client2 = new HttpClient(); //Acknowledge the notification
+ PutMethod method2 = new PutMethod(url);
+ method2.addRequestHeader("Authorization", "Bearer " + accessToken);
+ method2.addRequestHeader("Content-Type", "application/json");
+ method2.addRequestHeader("Accept", "application/json");
+ int statusCode3 = client2.executeMethod(method2);
+
+ if(statusCode3==200 || statusCode3==201)
+ System.out.println("Acknowlegement success ");
+
+ methods.releaseConnection();
+ method2.releaseConnection();
+ }
+
+ }
+ }
+
+}
+
+%>
+
<div id="footer">
- <div style="float: right; width: 20%; font-size: 9px; text-align: right">Powered by AT&amp;T Cloud Architecture</div>
- <p>&#169; 2012 AT&amp;T Intellectual Property. All rights reserved. <a href="http://developer.att.com/" target="_blank">http://developer.att.com</a>
+<div style="float: right; width: 20%; font-size: 9px; text-align: right">Powered by AT&amp;T Cloud Architecture</div>
+ <p>&#169; 2012 AT&amp;T Intellectual Property. All rights reserved. <a href="http://developer.att.com/" target="_blank">http://developer.att.com</a>
<br>
-The Application hosted on this site are working examples intended to be used for reference in creating products to consume AT&amp;T Services and not meant to be used as part of your product. The data in these pages is for test purposes only and intended only for use as a reference in how the services perform.
+The Application hosted on this site are working examples intended to be used for reference in creating products to consume AT&amp;T Services and not meant to be used as part of your product. The data in these pages is for test purposes only and intended only for use as a reference in how the services perform.
<br>
For download of tools and documentation, please go to <a href="https://devconnect-api.att.com/" target="_blank">https://devconnect-api.att.com</a>
<br>
@@ -667,5 +790,3 @@ For more information contact <a href="mailto:developer.support@att.com">develope
</div>
</div>
-</body></html>
-
View
9 Payment/Ruby/app1/views/app1.erb
@@ -295,18 +295,15 @@ For more information contact developer.support@att.com -->
</th><th></th>
<th style="width: 125px" class="cell" align="left">
<strong>Transaction ID</strong>
- </th>
+ </th><th></th>
</tr>
</thead>
<tbody>
<% @notifications.each do |n| %>
<tr>
- <td style="width: 100px" class="cell" align="left">
- <%= n[:notificationId] %></td><td></td>
+ <td style="width: 100px" td class="cell" align="left"><%= n[:notificationId] %></td><td></td>
<td style="width: 100px" td class="cell" align="left"><%= n[:notificationtype]%></td><td></td>
- <td style="width: 100px" td class="cell" align="left">
- <%= n[:original_trxId] %></td>
- <td></td>
+ <td style="width: 100px" td class="cell" align="left"><%= n[:original_trxId] %></td><td></td>
</tr>
<% end %>
<tr>
View
2  Payment/Ruby/app2/views/app2.erb
@@ -386,7 +386,7 @@ For more information contact developer.support@att.com -->
<tbody>
<% @notifications.each do |n| %>
<tr>
- <td style="width: 100px" class="cell" align="left">
+ <td style="width: 100px" td class="cell" align="left">
<%= n[:notificationId] %></td><td></td>
<td style="width: 100px" td class="cell" align="left"><%= n[:notificationtype]%></td><td></td>
<td style="width: 100px" td class="cell" align="left">
Please sign in to comment.
Something went wrong with that request. Please try again.