Skip to content

Commit 15641b6

Browse files
committed
Merge pull request #1 from binaryminds/master
Adjustments to handle Void and Credit actions
2 parents 8435174 + 9d38cf7 commit 15641b6

File tree

3 files changed

+94
-14
lines changed

3 files changed

+94
-14
lines changed

HTTPPayFlowProGateway.cfc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
15+
16+
17+
18+
PayFlowPro Components for ColdFusion
19+
20+
Changes:
21+
9/5/2012 Pawel Dulak: changed "chargeCard" function name to "executeTransaction"
22+
1523
--->
1624

1725
<cfcomponent>
@@ -37,7 +45,7 @@
3745
</cffunction>
3846

3947

40-
<cffunction name = "chargeCard">
48+
<cffunction name = "executeTransaction">
4149
<cfargument name="params">
4250
<cfargument name="transactionID">
4351

@@ -49,7 +57,7 @@
4957

5058
<cfreturn parseURLData(CFHTTP.FileContent)>
5159
</cffunction>
52-
60+
5361
<cffunction name = "encodeURLData" output="no">
5462
<cfargument name="params">
5563
<cfset var key = 0>

PayFlowProTransaction.cfc

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
15+
16+
17+
Changes:
18+
9/5/2012 Pawel Dulak: added "credit", "void", "setBaseParams", "setReferenceTransaction" functions and a possibility to use Reference Transaction ID in "run"
19+
1520
--->
1621

1722
<cfcomponent>
@@ -20,6 +25,7 @@
2025
<cfargument name="gateway">
2126
<cfset variables.transactionID = CreateUUID()>
2227
<cfset variables.gateway = arguments.gateway>
28+
<cfset variables.origID = "">
2329
<cfreturn this>
2430
</cffunction>
2531

@@ -45,6 +51,11 @@
4551
<cfset variables.cardNumber = arguments.cardNumber>
4652
</cffunction>
4753

54+
<cffunction name = "setReferenceTransaction" output="no">
55+
<cfargument name="pnref">
56+
<cfset variables.origid = arguments.pnref>
57+
</cffunction>
58+
4859
<cffunction name = "setExpirationMonthAndYear" output="no">
4960
<cfargument name="month">
5061
<cfargument name="year">
@@ -59,32 +70,58 @@
5970
<cfreturn "">
6071
</cfif>
6172
</cffunction>
62-
73+
6374
<cffunction name = "pnRef" output="no">
6475
<cfif isDefined("variables.response.pnRef")>
6576
<cfreturn variables.response.pnRef>
6677
<cfelse>
6778
<cfreturn "">
6879
</cfif>
6980
</cffunction>
70-
71-
<cffunction name="run" output="no">
81+
82+
<cffunction name="setBaseParams" output="no">
7283
<cfset var params = structNew()>
7384
<cfset params.user = variables.username>
7485
<cfset params.pwd = variables.password>
7586
<cfset params.partner = "Verisign">
7687
<cfset params.vendor = variables.vendor>
77-
<cfset params.trxtype = "S">
7888
<cfset params.tender = "C">
89+
<cfreturn params>
90+
</cffunction>
91+
92+
<cffunction name="run" output="no">
93+
<cfset params = setBaseparams()>
94+
<cfset params.trxtype = "S">
7995
<cfset params.amt = variables.amount>
80-
<cfset params.expdate = formatExpirationDate()>
81-
<cfset params.acct = variables.cardNumber>
82-
83-
<cfset variables.response = variables.gateway.chargeCard(params, variables.transactionID)>
84-
96+
<cfif variables.origID NEQ "">
97+
<cfset params.origID = variables.origID>
98+
<cfelse>
99+
<cfset params.expdate = formatExpirationDate()>
100+
<cfset params.acct = variables.cardNumber>
101+
</cfif>
102+
103+
<cfset variables.response = variables.gateway.executeTransaction(params, variables.transactionID)>
104+
105+
</cffunction>
106+
107+
<cffunction name="credit" output="no">
108+
<cfset params = setBaseparams()>
109+
<cfset params.trxtype = "C">
110+
<cfset params.amt = variables.amount>
111+
<cfset params.origID = variables.origID>
112+
113+
<cfset variables.response = variables.gateway.executeTransaction(params, variables.transactionID)>
114+
85115
</cffunction>
86116

117+
<cffunction name="void" output="no">
118+
<cfset params = setBaseparams()>
119+
<cfset params.trxtype = "V">
120+
<cfset params.origID = variables.origID>
121+
122+
<cfset variables.response = variables.gateway.executeTransaction(params, variables.transactionID)>
87123

124+
</cffunction>
88125

89126
<cffunction name = "formatExpirationDate" output="no">
90127
<cfreturn numberFormat(variables.expiresMonth, "00") & numberFormat(right(variables.expiresYear, 2), "00")>
@@ -111,6 +148,13 @@
111148
<cffunction name = "approved" output="no">
112149
<cfreturn 0 eq resultCode()>
113150
</cffunction>
114-
115-
</cfcomponent>
116151

152+
<cffunction name = "transactionID" output="no">
153+
<cfif isDefined("variables.transactionID")>
154+
<cfreturn variables.transactionID>
155+
<cfelse>
156+
<cfreturn -1/>
157+
</cfif>
158+
</cffunction>
159+
160+
</cfcomponent>

readme.txt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,32 @@ Result Code: #transaction.resultCode()#<br>
1919
Response Message: #transaction.responseMessage()#<br>
2020
Auth code: #transaction.authCode()#<br>
2121
PNREF: #transaction.pnRef()#
22-
</cfoutput>
22+
</cfoutput>
23+
24+
Another execution possibilities:
25+
26+
Charge Using Reference Transaction:
27+
28+
<cfset transaction = gateway.createTransaction()>
29+
<cfset transaction.setVendor(vendor)>
30+
<cfset transaction.setUsernameAndPassword(username,password)>
31+
<cfset transaction.setReferenceTransaction(pnref)>
32+
<cfset transaction.setAmount(amount_to_charge)>
33+
<cfset transaction.run()>
34+
35+
Credit Using Reference Transaction:
36+
37+
<cfset transaction = gateway.createTransaction()>
38+
<cfset transaction.setVendor(vendor)>
39+
<cfset transaction.setUsernameAndPassword(username,password)>
40+
<cfset transaction.setReferenceTransaction(pnref)>
41+
<cfset transaction.setAmount(amount_to_credit)>
42+
<cfset transaction.credit()>
43+
44+
Void Transaction Using Reference Transaction:
45+
46+
<cfset transaction = gateway.createTransaction()>
47+
<cfset transaction.setVendor(vendor)>
48+
<cfset transaction.setUsernameAndPassword(username,password)>
49+
<cfset transaction.setReferenceTransaction(pnref)>
50+
<cfset transaction.void()>

0 commit comments

Comments
 (0)