Added EastBayNewTech, NCDevCon, phoneGap and RIAUnleashed talks #3

Merged
merged 5 commits into from Apr 26, 2012
Binary file not shown.
@@ -0,0 +1,42 @@
+<cfscript>
+/*
+CallerService.cfc
+This ColdFusion component reused by all sample page to get credential information and
+it has getNVPResponse method which takes nvpString as parameter and return Nvpresponse
+as CF Struct object. using this object we can display the response values
+*/
+component output="false" {
+
+ serverURL = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";
+
+ public any function doHttppost( required struct requestData ) {
+
+ var httpService = new http();
+ httpService.setMethod("post");
+ httpService.setCharset("utf-8");
+ httpService.setUrl(serverURL);
+
+ for (key in requestData)
+ {
+ httpService.addParam(type="formfield",name="#key#",value="#requestData[key]#",encoded="yes");
+ }
+
+ httpService.addParam(type="header",name="X-PAYPAL-SECURITY-USERID",value="sidney_1311957058_biz_api1.x.com",encoded="yes");
+ httpService.addParam(type="header",name="X-PAYPAL-SECURITY-PASSWORD",value="1311957099",encoded="yes");
+ httpService.addParam(type="header",name="X-PAYPAL-SECURITY-SIGNATURE",value="AsWOI0XsYOW6SY4-RFW6nmQX9L2GAx2Dvzlusmnc2lLkNlYS6cilwiEc",encoded="yes");
+ httpService.addParam(type="header",name="X-PAYPAL-DEVICE-IPADDRESS",value="cgi.remote_addr",encoded="yes");
+ httpService.addParam(type="header",name="X-PAYPAL-REQUEST-DATA-FORMAT",value="NV",encoded="yes");
+ httpService.addParam(type="header",name="X-PAYPAL-RESPONSE-DATA-FORMAT",value="JSON",encoded="yes");
+ httpService.addParam(type="header",name="X-PAYPAL-APPLICATION-ID",value="APP-80W284485P519543T",encoded="yes");
+
+ httpService.addParam(type="body",value="&actionType=PAY&trackingID=12345&cancelUrl=http://www.x.com&currencyCode=USD&receiverList.receiver(0).amount=50.00&receiverList.receiver(0).email=nc1_1316197521_per@x.com&receiverList.receiver(1).amount=99.00&receiverList.receiver(1).email=nc2_1316197650_per@x.com&requestEnvelope.errorLanguage=en_US&returnUrl=http://www.x.com/test/return.cfm",encoded="yes");
+
+ var result = httpService.send().getPrefix();
+
+ return deserializeJSON(result.filecontent);
+
+ }
+
+}
+
+</cfscript>
@@ -0,0 +1,136 @@
+<cfscript>
+/**
+@dateCreated "July 18, 2011"
+@hint "You implement methods in Application.cfc to handle ColdFusion application events and set variables in the CFC to configure application characteristics."
+*/
+
+
+component output="false" {
+
+ /* **************************** APPLICATION VARIABLES **************************** */
+ THIS.name = "NCDevConCheckout01";
+ THIS.applicationTimeout = createTimeSpan(0, 2, 0, 0);
+
+
+ customtagpaths = "#getDirectoryFromPath(ExpandPath('../lib/'))#";
+ THIS.customTagPaths = customtagpaths;
+
+ THIS.serverSideFormValidation = true;
+ THIS.sessionManagement = true;
+ THIS.sessionTimeout = createTimeSpan(0, 0, 30, 0);
+
+ THIS.setClientCookies = true;
+ THIS.setDomainCookies = false;
+
+ THIS.scriptProtect = true;
+ THIS.secureJSON = false;
+ THIS.secureJSONPrefix = "";
+
+
+ THIS.enablerobustexception = true;
+
+
+/* **************************** APPLICATION METHODS **************************** */
+
+ public void function onApplicationEnd(struct ApplicationScope=structNew()) {
+
+ return;
+ }
+
+
+ public boolean function onApplicationStart() {
+
+ return true;
+ }
+
+
+
+ public void function onRequestEnd() {
+
+ return;
+ }
+
+
+ public boolean function onRequestStart(required string TargetPage) {
+
+ request.serverURL = "https://api-3t.sandbox.paypal.com/nvp";
+
+ /* SUBJECT to be uncommented for UNIPAY all the other credentials like API username,
+ password,signature can be commented for UNIPAY
+ To enable Payments for Third Party Email whcih will be passed along with Partner's 3token credentials
+ uncomment both subject and 3 token credentials.
+ */
+
+
+ //request.SUBJECT="sidney@x.com";
+
+ APIuserName = "sidney_1311957058_biz_api1.x.com";
+ APIPassword = "1311957099";
+ APISignature = "AsWOI0XsYOW6SY4-RFW6nmQX9L2GAx2Dvzlusmnc2lLkNlYS6cilwiEc";
+
+
+ //condition to check if it is UNIPAY
+ if (isdefined("SUBJECT") && (isdefined("APIuserName") eq "false" && isdefined("APIPassword") eq "false" && isdefined("APISignature") eq "false") )
+ {
+ request.UNIPAYSUBJECT="#SUBJECT#";
+ request.USER = "";
+ request.PWD = "";
+ request.SIGNATURE = "";
+ }
+
+
+
+ //condition to check if it is Payments for Third Party Email
+ if (isdefined("SUBJECT") && isdefined("APIuserName") && isdefined("APIPassword") && isdefined("APISignature"))
+ {
+ request.UNIPAYSUBJECT="#SUBJECT#";
+ request.USER = "#APIuserName#";
+ request.PWD = "#APIPassword#";
+ request.SIGNATURE = "#APISignature#";
+ }
+
+
+ //condition to check if it is 3 token credentials
+ if (isdefined("SUBJECT") eq "false" && isdefined("APIuserName") && isdefined("APIPassword") && isdefined("APISignature") )
+ {
+ request.UNIPAYSUBJECT="";
+ request.USER = "#APIuserName#";
+ request.PWD = "#APIPassword#";
+ request.SIGNATURE = "#APISignature#";
+ }
+
+
+ request.PayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
+ request.version = "78";
+
+ /*
+ By default the API requests doesn't go through proxy. To route the requests through a proxy server
+ set "useProxy" value as "true" and set values for proxyName and proxyPort. Set proxyName with
+ the Host Name or the IP address of the proxy server. proxyPort should be a valid port number.
+ eg:
+ useProxy = "true";
+ proxyName = "127.0.0.1";
+ proxyPort = "8081";
+ */
+
+ request.useProxy = "false";
+ request.proxyName = "";
+ request.proxyPort = "";
+
+ return true;
+ }
+
+
+ public void function onSessionEnd(required struct SessionScope, struct ApplicationScope=structNew()) {
+
+ return;
+ }
+
+
+ public void function onSessionStart() {
+
+ return;
+ }
+
+}
+</cfscript>
@@ -0,0 +1,48 @@
+<html>
+<head>
+ <title>Button Manager</title>
+ <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
+
+ <script>
+ $(document).ready(function() {
+
+
+ $('#createButton').live('click',function(e)
+ {
+
+ $.ajax({
+ url: 'buttonmanager.cfc',
+ data: 'method=BMCreateButton',
+ success: function(data){
+ var obj = $.parseJSON(data);
+ console.log(obj['code']);
+ $('#ppButton').append(obj['code']);
+
+ },
+ error: function(request, textStatus, error){
+
+ }
+ });
+
+ });
+
+ });
+ </script>
+
+
+</head>
+<body>
+
+<a href="#" id="createButton">create button</a>
+<p id="ppButton">
+
+</p>
+
+
+
+<br><br>
+<a href="../index.html">home</a>
+
+
+</body>
+</html>
@@ -0,0 +1,77 @@
+<cfcomponent>
+ <cfscript>
+
+ // create our objects to call methods on
+ caller = createObject("component","lib.services.CallerService");
+ /*
+ serverName = SERVER_NAME;
+ serverPort = CGI.SERVER_PORT;
+ contextPath = GetDirectoryFromPath(#SCRIPT_NAME#);
+ protocol = CGI.SERVER_PROTOCOL;
+ */
+ </cfscript>
+
+ <cffunction name="BMCreateButton" access="remote" returntype="any" returnFormat="JSON">
+
+ <cfscript>
+ var responseStruct="";
+ var returnObj = StructNew();
+
+ try {
+ // create our objects to call methods on
+
+ data = StructNew();
+ data.USER = request.USER;
+ data.PWD = request.PWD;
+ data.SIGNATURE = request.SIGNATURE;
+ data.VERSION = "84";
+
+ data.URLBASE = request.serverURL;
+ data.USEPROXY = false;
+
+ data.METHOD = "BMCreateButton";
+
+ data.BUTTONCODE = "cleartext"; // hosted, encrypted, cleartext
+ data.BUTTONTYPE = "buynow";
+
+ //data.L_BUTTONVAR0 = "business=sidney_1311957058_biz@x.com";
+ data.L_BUTTONVAR1 = "item_name=T-shirt";
+ data.L_BUTTONVAR2 = "amount=20.00";
+ //data.L_BUTTONVAR3 = "no_shipping=1";
+ //data.L_BUTTONVAR4 = "currency_code=USD";
+ //data.L_BUTTONVAR5 = "no_note=1";
+
+ response = caller.doHttppost(data);
+
+ responseStruct = caller.getNVPResponse(#URLDecode(response)#);
+
+ if (responseStruct.Ack is not "Success")
+ {
+ Throw(type="InvalidData",
+ message="Response:#responseStruct.Ack#, ErrorCode: #responseStruct.L_ERRORCODE0#,
+ Message: #responseStruct.L_LONGMESSAGE0#");
+
+ } else {
+ code = responseStruct.websitecode;
+ }
+
+
+ returnObj['success'] = true;
+ returnObj['code'] = code;
+
+ }
+
+ catch(any e)
+ {
+ returnObj['success'] = true;
+ returnObj['error'] = e.message;
+ }
+
+
+ return serializeJSON(returnObj);
+ </cfscript>
+
+ </cffunction>
+
+
+</cfcomponent>
@@ -0,0 +1,68 @@
+<cfoutput>
+<html>
+<head>
+ <title>Subscription process</title>
+ <link href="sdk.css" rel="stylesheet" type="text/css" />
+</head>
+<body>
+<cfscript>
+code = "";
+responseStruct="";
+ try {
+ // create our objects to call methods on
+ caller = createObject("CallerService");
+
+ data = StructNew();
+ data.USER = request.USER;
+ data.PWD = request.PWD;
+ data.SIGNATURE = request.SIGNATURE;
+ data.VERSION = "78";
+
+ data.SERVERURL = request.serverURL;
+ data.USEPROXY = false;
+
+ data.METHOD = "BMCreateButton";
+
+ data.BUTTONCODE = "hosted";
+ data.BUTTONTYPE = "buynow";
+
+ data.L_BUTTONVAR0 = "business=sidney_1311957058_biz@x.com";
+ data.L_BUTTONVAR1 = "item_name=Virtual Cow";
+ data.L_BUTTONVAR2 = "amount=1.50";
+ data.L_BUTTONVAR3 = "no_shipping=1";
+ data.L_BUTTONVAR4 = "currency_code=USD";
+ data.L_BUTTONVAR5 = "no_note=1";
+
+ response = caller.doHttppost(data);
+
+ responseStruct = caller.getNVPResponse(#URLDecode(response)#);
+
+ if (responseStruct.Ack is not "Success")
+ {
+ Throw(type="InvalidData",message="Response:#responseStruct.Ack#, ErrorCode: #responseStruct.L_ERRORCODE0#, Message: #responseStruct.L_LONGMESSAGE0#");
+
+ } else {
+ code = responseStruct.websitecode;
+ }
+
+ }
+
+ catch(any e)
+ {
+ writeOutput("Error: " & e.message);
+ writeDump(responseStruct);
+ }
+
+</cfscript>
+
+
+#code#
+
+
+
+<br><br>
+<a href="../index.html">home</a>
+
+</body>
+</html>
+</cfoutput>
Oops, something went wrong.