[paypal_payflowpro]

Description

Link: [paypal_payflowpro]
Author: Jason Huck
Category: Utility
Version: 8.5.x
License: Public Domain
Posted: Oct. 25, 2007
Updated: May. 15, 2009
More by this author...

Version 4 of the Payflow Pro interface now allows direct communication with the Payflow servers over HTTPS, without going through the Java or .NET SDK's. This tag is a wrapper for [include_url] that constructs the appropriate request headers for that communication and submits parameters in NVP format. Returns a map of parameters provided in the response.

In addition to the tag-specific parameters listed below, consult the Payflow Pro documentation for a complete list of supported options.

Parameters

-appid string, required Unique ID for the application using the tag. Should never be changed.
-requestid string, optional Unique ID for the given transaction. Should only be supplied when re-trying a previously failed transaction.
-test boolean, optional If true, use the test servers instead of the live servers. Defaults to false.

Sample Usage

paypal_payflowpro(
	-test=true,
	-appid='xxxxxxxx',
	-trxtype='S', 
	-tender='C', 
	-partner='paypal', 
	-vendor='xxxxxxxx', 
	-user='xxxxxxxx', 
	-pwd='xxxxxxxx', 
	-acct='5555555555554444',
	-cvv2='111',
	-expdate='0308',
	-amt='75.00',
	-street='1234 This Way',
	-zip='90210',
	-name='Joe Schmoe'
);

-> map: (RESPMSG)=(Approved), (IAVS)=(N), (AVSZIP)=(N), 
(POSTFPSMSG)=(No Rules Triggered), (PREFPSMSG)=(No Rules Triggered), 
(CVV2MATCH)=(Y), (AUTHCODE)=(xxxxx), (PNREF)=(xxxxxxxx), 
(RESULT)=(0), (AVSADDR)=(Y)
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
define_tag(
	'payflowpro',
	-namespace='paypal_',
	-req='appid',
	-opt='requestid',
	-opt='test', -type='boolean',
	-priority='replace',
	-encodenone,
	-description='Wrapper for PayPal Payflow Pro direct HTTPS integration.'
);
	// submit to the test server or the production server?
	!local_defined('test') ? local('test') = false;
	local('url') = 'https://' + (#test ? 'pilot-') + 'payflowpro.paypal.com';	

	// assign a unique id for this transaction unless re-trying
	!local_defined('requestid') ? local('requestid') = lasso_uniqueid;

	// assemble the body of the post from the given params
	local('body') = string;

	// exclude params passed just for the tag
	local('extraparams') = (: '-test', '-requestid', '-appid');
	
	iterate(params, local('i'));
		if(#extraparams !>> #i->first);
			local('n') = string(#i->first)->removeleading('-')&uppercase&;
			local('v') = string(#i->second)->replace('"','')&;
			(: '&','=') >> #v ? #n += '[' + #v->size + ']';
			#body += #n + '=' + #v + '&';
		/if;
	/iterate;
	
	#body->removetrailing('&');
	
	// assemble extra MIME headers
	local('lassoversion') = decimal(lasso_version( -lassoversion))->setformat( -precision=1)&;
			
	local('headers') = (:
		'Content-Type'						=	'text/namevalue',
		'Content-Length'						=	#body->size,
		'X-VPS-REQUEST-ID'					=	#requestid,
		'X-VPS-CLIENT-TIMEOUT'				=	'45',
		'X-VPS-VIT-CLIENT-CERTIFICATION-ID'	=	#appid,
		'X-VPS-VIT-INTEGRATION-PRODUCT'		=	'Lasso Professional Server',
		'X-VPS-VIT-INTEGRATION-VERSION'		=	#lassoversion,
		'X-VPS-VIT-OS-NAME'					=	lasso_version( -lassoplatform),
		// 'X-VPS-VIT-OS-VERSION'			=	'',
		'X-VPS-VIT-RUNTIME-VERSION'			=	#lassoversion
	);
	
	// submit the transaction
	local('response') = string;
	
	protect;
		#response = include_url(
			#url,
			-sendmimeheaders=#headers,
			-postparams=#body,
			-timeout=30
		);
	/protect;
	
	// parse the response
	!#response->size ? return('Connection timed out.');
	
	local('out') = map('REQUESTID' = #requestid);
	
	iterate(#response->split('&'), local('i'));
		local(
			'n' = #i->split('=')->first,
			'v' = #i->split('=')->second
		);
		
		#out->insert(#n = #v);
	/iterate;
	
	return(#out);
/define_tag;

 

Related Tags



Comments

05/15/2009, Jason Huck
Compatibility Updates
Updated to use the current server addresses and report the content "size" per the latest requirements. Thanks to Randy Phillips for supplying the changes.
Email:


Password:



Newest

Most Popular

Support tagSwap.net