- Spooky Emails About your Domain Name
-
You get messages about the status of your domain name, or threats about its future. Some are real and others are fake.
- Home
- ⇒ Portfolio
- ⇒ Projects
- ⇒ E-Commerce
E-Commerce
PayPal PayFlow Gateway Component (ColdFusion)
<cfcomponent displayname="ppgateway" hint="PayPal payment gateway" output="false">
<cffunction name="doHttppost" access="public" returntype="struct" hint="credit card charge for structure input">
<cfargument name="requestData" type="struct" required="yes" >
<cfargument name="isTest" type="numeric" required="yes" hint="1=test 0=live" >
<cfargument name="pay_partner" type="string" required="yes" hint="See PayPal Payflow documentation" >
<cfargument name="pay_vendor" type="string" required="yes" hint="See PayPal Payflow documentation" >
<cfargument name="pay_user" type="string" required="yes" hint="See PayPal Payflow documentation" >
<cfargument name="pay_pwd" type="string" required="yes" >
<cfargument name="pay_useavs" type="string" required="no" hint="currently unused" >
<cfset var isThisAttemptOK = 0>
<cfset var struReturn = structNew()>
<cfset struReturn.success = 1>
<cfset struReturn.approved = 999>
<cfset struReturn.approval = "">
<cfset struReturn.attemptsMax = 4>
<cfset struReturn.attemptsMade = 0>
<cfset struReturn.attemptTimeOutSec = 10>
<cfset struReturn.attemptsID = dateFormat(now(),"YYYYMMDD")&timeFormat(now(),"HHmmssll")>
<cfset struReturn.request = arguments.requestData>
<cfset struReturn.sysMessage = "">
<cfset struReturn.gatewayURL = "https://payflowpro.paypal.com">
<cfif arguments.isTest>
<cfset struReturn.gatewayURL = "https://pilot-payflowpro.paypal.com">
</cfif>
<cfset struReturn.isTest = arguments.isTest>
<cfset credentials = structNew()>
<cfset credentials.partner = arguments.pay_partner>
<cfset credentials.vendor = arguments.pay_vendor>
<cfset credentials.user = arguments.pay_user>
<cfset credentials.pwd = "hidden|" & len(arguments.pay_pwd)>
<cfset struReturn.credentials = credentials>
<cfset sResult = structNew()>
<cfloop from="1" to="#struReturn.attemptsMax#" index="thisAttempt">
<cfset struReturn.attemptsMade = thisAttempt>
<cftry>
<cfset isThisAttemptOK = 1>
<cfset struReturn.success = 1>
<CFHTTP URL="#struReturn.gatewayURL#" port="443" METHOD="POST" timeout="#val(struReturn.attemptTimeOutSec)+2#" resolveurl="false" >
<cfhttpparam type="Header" name="charset" value="utf-8">
<cfhttpparam type="Header" name="Accept-Encoding" value="deflate;q=0">
<cfhttpparam type="Header" name="TE" value="deflate;q=0">
<cfhttpparam type="header" name="X-VPS-REQUEST-ID" value="#struReturn.attemptsID#">
<cfhttpparam type="header" name="X-VPS-CLIENT-TIMEOUT" value="#struReturn.attemptTimeOutSec#">
<cfhttpparam type="header" name="X-VPS-VIT-INTEGRATION-PRODUCT" value="ColdFusion">
<cfhttpparam type="header" name="X-VPS-VIT-INTEGRATION-VERSION" value="#listFirst(server.ColdFusion.ProductVersion)#">
<cfhttpparam type="formfield" name="PARTNER" value="#arguments.pay_partner#">
<cfhttpparam type="formfield" name="VENDOR" value="#arguments.pay_vendor#">
<cfhttpparam type="formfield" name="USER" value="#arguments.pay_user#">
<cfhttpparam type="formfield" name="PWD" value="#arguments.pay_pwd#">
<cfloop collection=#arguments.requestData# item="key">
<CFHTTPPARAM NAME="#key#[#len(arguments.requestData[key])#]" VALUE="#arguments.requestData[key]#" TYPE="FormField" encoded="false">
</cfloop>
</CFHTTP>
<cfif left(cfhttp.statusCode,3) eq "200">
<cfset sResult = getNVPResponse(cfhttp.FileContent)>
<cfif sResult.result eq "11">
<cfset isThisAttemptOK = 0>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,sResult.respmsg,'|')>
</cfif>
<cfif sResult.result eq "0">
<cfset struReturn.approved = 1>
<cfset struReturn.approval = sResult.authCode>
</cfif>
<cfif StructKeyExists(sResult,'DUPLICATE')>
<cfif sResult.DUPLICATE eq "-1">
<cfset isThisAttemptOK = 1>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,"paypals duplicate check database is down",'|')>
</cfif>
</cfif>
<cfelse>
<cfset isThisAttemptOK = 0>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,cfhttp.statusCode,'|')>
</cfif>
<cfcatch>
<cfset struReturn.success = 0>
<cfset isThisAttemptOK = 0>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,cfcatch.Message & ": " & cfcatch.Detail,'|')>
</cfcatch>
</cftry>
<cfif isThisAttemptOK>
<cfbreak />
</cfif>
</cfloop>
<cfif StructKeyExists(struReturn.request,'ACCT')>
<cfif len(struReturn.request.ACCT) gt 4>
<cfset struReturn.request.ACCT = "hidden|" & right(struReturn.request.ACCT,4)>
</cfif>
</cfif>
<cfset struReturn.response = sResult>
<cfreturn struReturn>
</cffunction>
<cffunction name="getNVPResponse" access="public" returntype="struct">
<cfargument name="nvpString" type="string" required="yes" >
<cfset var responseStruct = StructNew()>
<cfset var keyValStruct = StructNew()>
<cfset var keys = "">
<cfset var Values = "">
<cfset nvpArray = ArrayNew(1) >
<cfset keyArray = ArrayNew(1) >
<cfset valueArray = ArrayNew(1) >
<cfset key = "">
<cfset value = "">
<cfset currentValue = "">
<cfset tempVal = "">
<cfset count = 1 >
<cfset tempvalue = "">
<cfset lennvp = 0>
<cfloop from="1" to="#len(nvpString)#" index="i">
<cfset lennvp = lennvp + 1>
<cfset index = 1>
<cfif #Mid(nvpString, i, 1)# is not "&">
<cfset tempVal = tempVal & #Mid(nvpString, i, 1)#>
</cfif>
<cfif #Mid(nvpString, i, 1)# is "&" OR "#lennvp#" is "#len(nvpString)#">
<cfset nvpArray[count] = #trim(tempVal)#>
<cfset count = count + 1>
<cfset tempVal = "">
</cfif>
</cfloop>
<cfloop from="1" to="#ArrayLen(nvpArray)#" index="i">
<cfset currentValue = #nvpArray[i]#>
<cfloop from="1" to= "#len(currentValue)#" index="i">
<cfif #Mid(currentValue, i, 1)# is "=">
<cfbreak>
<cfelse>
<cfset tempValue = tempValue & #Mid(currentValue, i, 1)#>
</cfif>
</cfloop>
<cfset keyArray[index] = #trim(tempValue)#>
<cfset index = #index# + 1>
<cfset tempValue = "">
</cfloop>
<cfset vals = "">
<cfset key = "">
<cfloop from="1" to="#ArrayLen(nvpArray)#" index="i">
<cfset vals = #nvpArray[i]# >
<cfset key = #keyArray[i]#>
<cfset value = #RemoveChars(vals ,1, (len(key) +1))#>
<cfset valueArray[i] = value>
<cfset x = StructInsert(responseStruct,#trim(key)#,#trim(value)#)>
</cfloop>
<cfreturn responseStruct>
</cffunction>
</cfcomponent>
Secure Trading (UK) XPay Gateway Component (ColdFusion)
<cfcomponent displayname="Secure Trading" hint="for the SecureTrading.com xPay system in the UK" output="false">
<cffunction name="doHttppost" access="public" returntype="struct" hint="credit card charge for structure input">
<cfargument name="requestData" type="struct" required="yes" >
<cfargument name="isTest" type="numeric" required="yes" hint="1=test 0=live" >
<cfargument name="pay_partner" type="string" required="yes" hint="Not used by xPay" >
<cfargument name="pay_vendor" type="string" required="yes" hint="Not used by xPay" >
<cfargument name="pay_user" type="string" required="yes" hint="SecureTrading login" >
<cfargument name="pay_pwd" type="string" required="yes" >
<cfargument name="pay_useavs" type="string" required="no" hint="currently unused" >
<cfset var isThisAttemptOK = 0>
<cfset var struReturn = structNew()>
<cfset struReturn.success = 1>
<cfset struReturn.approved = 999>
<cfset struReturn.approval = "">
<cfset struReturn.request = arguments.requestData>
<cfset struReturn.sysMessage = "">
<cfset struReturn.isTest = arguments.isTest>
<cfset credentials = structNew()>
<cfset credentials.partner = arguments.pay_partner>
<cfset credentials.vendor = arguments.pay_vendor>
<cfset credentials.user = arguments.pay_user>
<cfset credentials.pwd = arguments.pay_pwd>
<cfif arguments.isTest>
<cfset credentials.user = "[username]">
<cfset credentials.pwd = "[password]">
</cfif>
<cfset sResult = structNew()>
<cfif listLen(struReturn.request.AMT,".") neq 2>
<cfset struReturn.success = 0>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,"[examweb gateway_xpay4]: Amount "& struReturn.request.AMT &" is not in the format 999.00",'|')>
</cfif>
<cfif struReturn.success>
<cfset xml = composeXpay4XML(arguments.requestData,credentials)>
<cftry>
<cfset struReturn.success = 1>
<cfset struReturn.gatewayUrl = "http://127.0.0.1/">
<cfhttp method="post" url="#struReturn.gatewayUrl#" port="5000">
<cfhttpparam encoded="No" TYPE="cgi" NAME="xpay" VALUE="#xml#">
</cfhttp>
<cfif left(cfhttp.statusCode,3) eq "200">
<cfset struReturn.xpayResults = getSTResponse(cfhttp.FileContent)>
<!--- translate xPay result into buy gateway result --->
<cfset sResult.PNREF = struReturn.xpayResults.transactionReference>
<cfset sResult.RESPMSG = struReturn.xpayResults.message>
<cfset sResult.result = 999>
<cfset sResult.authCode = "">
<cfset struReturn.approved = 0>
<cfif struReturn.xpayResults.result eq "1">
<cfset struReturn.approved = 1>
<cfset struReturn.approval = trim(replaceNocase(struReturn.xpayResults.authCode,"AUTH CODE:",""))>
<cfset sResult.authCode = trim(replaceNocase(struReturn.xpayResults.authCode,"AUTH CODE:",""))>
<cfset sResult.result = 0> <!--- our gateway reponse is 0 = good (like paypal's) --->
<cfelse>
<!--- todo: test codes to set this number --->
<cfif find("(3100)",sResult.RESPMSG)>
<cfset sResult.result = 1> <!--- programming problem on our end --->
</cfif>
<cfif struReturn.xpayResults.result eq "2">
<cfset sResult.result = 12> <!--- declined --->
</cfif>
<cfif find("(5000)",sResult.RESPMSG)>
<cfset sResult.result = 10> <!--- transport error --->
</cfif>
</cfif>
<cfelse>
<cfset struReturn.success = 0>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,cfhttp.statusCode,'|')>
<cfif isDefined("cfhttp.ErrorDetail")>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,cfhttp.ErrorDetail,'|')>
</cfif>
</cfif>
<cfcatch>
<cfset struReturn.success = 0>
<cfset struReturn.sysMessage = listAppend(struReturn.sysMessage,cfcatch.Message & ": " & cfcatch.Detail,'|')>
</cfcatch>
</cftry>
<cfif StructKeyExists(struReturn.request,'ACCT')>
<cfif len(struReturn.request.ACCT) gt 4>
<cfset struReturn.request.ACCT = "hidden|" & right(struReturn.request.ACCT,4)>
</cfif>
</cfif>
<cfset struReturn.response = sResult>
<cfset credentials.pwd = "hidden|" & len(credentials.pwd)>
<cfset struReturn.credentials = credentials>
</cfif>
<cfreturn struReturn>
</cffunction>
<cffunction name="composeXpay4XML" access="private" returntype="string" hint="create the xml request in xpay format">
<cfargument name="gatewayRequestData" type="struct" required="true" hint="structure passed to doHttppost as requestData ">
<cfargument name="gatewayCredentialData" type="struct" required="true" hint="structure created within doHttppost as credentials ">
<cfcontent type="text/xml; charset=utf-16">
<cfxml variable="xmlobject" casesensitive="true">
<cfif ucase(arguments.gatewayRequestData.TRXTYPE) eq "S">
<cfoutput>
<RequestBlock Version="3.51">
<Request Type="AUTH">
<Operation>
<Amount>#replace(arguments.gatewayRequestData.AMT,'.','')#</Amount> <!--- xpay does not want decimal points 10.00 s/b 1000 --->
<Currency>#arguments.gatewayRequestData.CURRENCYCODE#</Currency>
<SiteReference>#arguments.gatewayCredentialData.user#</SiteReference>
<SettlementDay>1</SettlementDay>
</Operation>
<CustomerInfo>
<Postal>
<Name>
<NamePrefix></NamePrefix>
<FirstName>#arguments.gatewayRequestData.FIRSTNAME#</FirstName>
<MiddleName></MiddleName>
<LastName>#arguments.gatewayRequestData.LASTNAME#</LastName>
<NameSuffix></NameSuffix>
</Name>
<Company></Company>
<Street>#arguments.gatewayRequestData.STREET#</Street>
<City>#arguments.gatewayRequestData.CITY#</City>
<StateProv>#arguments.gatewayRequestData.STATE#</StateProv>
<PostalCode>#arguments.gatewayRequestData.ZIP#</PostalCode>
<CountryCode>#arguments.gatewayRequestData.COUNTRYCODE#</CountryCode>
</Postal>
<Telecom>
<Phone>#arguments.gatewayRequestData.PHONE#</Phone>
</Telecom>
<Online>
<Email>#arguments.gatewayRequestData.EMAIL#</Email>
</Online>
</CustomerInfo>
<PaymentMethod>
<CreditCard>
<Type>#arguments.gatewayRequestData.CCTYPE#</Type>
<Number>#arguments.gatewayRequestData.ACCT#</Number>
<Issue>#arguments.gatewayRequestData.ISSUE#</Issue>
<StartDate>#Left(arguments.gatewayRequestData.STARTDATE,2)#/#Right(arguments.gatewayRequestData.STARTDATE,2)#</StartDate>
<SecurityCode>#arguments.gatewayRequestData.CVV2#</SecurityCode>
<ExpiryDate>#Left(arguments.gatewayRequestData.EXPDATE,2)#/#Right(arguments.gatewayRequestData.EXPDATE,2)#</ExpiryDate>
</CreditCard>
</PaymentMethod>
<Order>
<OrderReference></OrderReference>
<OrderInformation>#arguments.gatewayRequestData.DESCRIP#</OrderInformation>
</Order>
</Request>
<Certificate>#arguments.gatewayCredentialData.user#</Certificate>
</RequestBlock>
</cfoutput>
</cfif>
</cfxml>
<cfreturn xmlobject>
</cffunction>
<cffunction name="getSTResponse" access="public" returntype="struct">
<cfargument name="xmlString" type="string" required="yes" >
<cfset var struReturn = structNew()>
<cfset xPayResults = xmlparse(arguments.xmlString)>
<cfset struReturn.live = xPayResults.ResponseBlock.XmlAttributes.Live>
<cfset struReturn.version = xPayResults.ResponseBlock.XmlAttributes.Version>
<cfset OperationResponse = xPayResults.ResponseBlock.Response.OperationResponse.xmlChildren>
<cfset struReturn.result = 0>
<cfset struReturn.message = "">
<cfset struReturn.transactionreference = "">
<cfset struReturn.authCode = "">
<cfloop from="1" to="#ArrayLen(OperationResponse)#" index="responseItem">
<cfif lcase(OperationResponse[responseItem].XMLName) eq "result">
<cfset struReturn.result = OperationResponse[responseItem].XmlText>
</cfif>
<cfif lcase(OperationResponse[responseItem].XMLName) eq "message">
<cfset struReturn.message = OperationResponse[responseItem].XmlText>
</cfif>
<cfif lcase(OperationResponse[responseItem].XMLName) eq "transactionreference">
<cfset struReturn.transactionReference = OperationResponse[responseItem].XmlText>
</cfif>
<cfif lcase(OperationResponse[responseItem].XMLName) eq "authcode">
<cfset struReturn.authCode = OperationResponse[responseItem].XmlText>
</cfif>
</cfloop>
<cfreturn struReturn>
</cffunction>
</cfcomponent>
Simple PayPal Form (ColdFusion)
<cfif mode eq "payPal">
<script type="text/javascript">
// use existing jQuery $method to submit the form below after the page is loaded (ready)
$(document).ready(function() {
document.payPalForm.submit();
});
</script>
<h2>Sending you to PayPal</h2>
<p>One moment please...</p>
<form name="payPalForm" action="#paypalURL#" onsubmit="return formSubmit()" method="post">
<input type="hidden" name="cmd" value="#paypalCommand#">
<input type="hidden" name="business" value="#receiver_email#">
<input type="hidden" name="item_name" value="#item_name#">
<input type="hidden" name="item_number" value="#listRequestID#">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="amount" value="#numberformat(pmtRequested)#">
<input type="hidden" name="invoice" value="#form.invno#">
<input type="hidden" name="return" value="#good_href#">
<input type="hidden" name="cancel_return" value="#prob_href#">
<input type="hidden" name="notify_url" value="#notify_url#">
</form>
</cfif>