|
| 1 | +<cfcomponent> |
| 2 | + |
| 3 | +<cffunction name="init" output="no"> |
| 4 | + <cfargument name="gateway"> |
| 5 | + <cfset variables.transactionID = CreateUUID()> |
| 6 | + <cfset variables.gateway = arguments.gateway> |
| 7 | + <cfreturn this> |
| 8 | +</cffunction> |
| 9 | + |
| 10 | +<cffunction name = "setAmount" output="no"> |
| 11 | + <cfargument name="amount"> |
| 12 | + <cfset variables.amount = arguments.amount> |
| 13 | +</cffunction> |
| 14 | + |
| 15 | +<cffunction name = "setVendor" output="no"> |
| 16 | + <cfargument name="vendor"> |
| 17 | + <cfset variables.vendor = arguments.vendor> |
| 18 | +</cffunction> |
| 19 | + |
| 20 | +<cffunction name = "setUsernameAndPassword" output="no"> |
| 21 | + <cfargument name="username"> |
| 22 | + <cfargument name="password"> |
| 23 | + <cfset variables.username = arguments.username> |
| 24 | + <cfset variables.password = arguments.password> |
| 25 | +</cffunction> |
| 26 | + |
| 27 | +<cffunction name = "setCardNumber" output="no"> |
| 28 | + <cfargument name="cardNumber"> |
| 29 | + <cfset variables.cardNumber = arguments.cardNumber> |
| 30 | +</cffunction> |
| 31 | + |
| 32 | +<cffunction name = "setExpirationMonthAndYear" output="no"> |
| 33 | + <cfargument name="month"> |
| 34 | + <cfargument name="year"> |
| 35 | + <cfset variables.expiresMonth = arguments.month> |
| 36 | + <cfset variables.expiresYear = arguments.year> |
| 37 | +</cffunction> |
| 38 | + |
| 39 | +<cffunction name = "authCode" output="no"> |
| 40 | + <cfif isDefined("variables.response.authCode")> |
| 41 | + <cfreturn variables.response.authCode> |
| 42 | + <cfelse> |
| 43 | + <cfreturn ""> |
| 44 | + </cfif> |
| 45 | +</cffunction> |
| 46 | + |
| 47 | +<cffunction name = "pnRef" output="no"> |
| 48 | + <cfif isDefined("variables.response.pnRef")> |
| 49 | + <cfreturn variables.response.pnRef> |
| 50 | + <cfelse> |
| 51 | + <cfreturn ""> |
| 52 | + </cfif> |
| 53 | +</cffunction> |
| 54 | + |
| 55 | +<cffunction name="run" output="no"> |
| 56 | + <cfset var params = structNew()> |
| 57 | + <cfset params.user = variables.username> |
| 58 | + <cfset params.pwd = variables.password> |
| 59 | + <cfset params.partner = "Verisign"> |
| 60 | + <cfset params.vendor = variables.vendor> |
| 61 | + <cfset params.trxtype = "S"> |
| 62 | + <cfset params.tender = "C"> |
| 63 | + <cfset params.amt = variables.amount> |
| 64 | + <cfset params.expdate = formatExpirationDate()> |
| 65 | + <cfset params.acct = "#variables.cardNumber#"> |
| 66 | + <cfset params.comment1 = "SBC#dateFormat(now(), 'mmddyy')#"> |
| 67 | + |
| 68 | + <cfset variables.response = variables.gateway.chargeCard(params, variables.transactionID)> |
| 69 | + |
| 70 | +</cffunction> |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +<cffunction name = "formatExpirationDate" output="no"> |
| 75 | + <cfreturn numberFormat(variables.expiresMonth, "00") & numberFormat(right(variables.expiresYear, 2), "00")> |
| 76 | +</cffunction> |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +<cffunction name = "resultCode" output="no"> |
| 81 | + <cfif isDefined("variables.response.result")> |
| 82 | + <cfreturn variables.response.result> |
| 83 | + <cfelse> |
| 84 | + <cfreturn -1/> |
| 85 | + </cfif> |
| 86 | +</cffunction> |
| 87 | + |
| 88 | +<cffunction name = "responseMessage" output="no"> |
| 89 | + <cfif isDefined("variables.response.respmsg")> |
| 90 | + <cfreturn variables.response.respmsg> |
| 91 | + <cfelse> |
| 92 | + <cfreturn ""/> |
| 93 | + </cfif> |
| 94 | +</cffunction> |
| 95 | + |
| 96 | +<cffunction name = "approved" output="no"> |
| 97 | + <cfreturn 0 eq resultCode()> |
| 98 | +</cffunction> |
| 99 | + |
| 100 | +</cfcomponent> |
| 101 | + |
0 commit comments