Lasso Soft Inc. > Home

[paypal_payflowpro]

Linkpaypal_payflowpro
AuthorJason Huck
CategoryUtility
Version8.5.x
LicensePublic Domain
Posted25 Oct 2007
Updated15 May 2009
More by this author...

Description

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.

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.

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

15 May 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.

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft