<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Forum posts to 'Extending and hacking'</title>
		<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/</link>
		

		
		<item>
			<title>Re: Credit Card Validation</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=117277</link>
			<description>Attached is the securepaytech payment file I've managed to get working.  I've merged my ecommerce code with the svn version so I'm not 100% sure it'll work for everyone but should at least give you a good place to start.&lt;br /&gt;&lt;br /&gt;Add the following line to mysite/_config.php with the correct details&lt;br /&gt;[code]SecurePayTechPayment::set_account('merchantID', 'password');[/code]&lt;br /&gt;&lt;br /&gt;I ended up using Director::forceSSL() in order to get SSL working, which is across the whole site, not just the payment pages.&lt;br /&gt;&lt;br /&gt;Two additional javascript functions I've added (to Checkout.js) and use in this file:&lt;br /&gt;&lt;br /&gt;[code]paymarkVerify();[/code]&lt;br /&gt;&lt;br /&gt;Is the same as the implementation in the SecurePayTech integration guide, just pops up a window with the right merchantID for verification purposes.&lt;br /&gt;&lt;br /&gt;[code]requireValidCC(fieldName);[/code]&lt;br /&gt;&lt;br /&gt;this is a new validation function that works just the same as require() in /sapphire/javascript/Validator.js except it checks for a valid credit card number.  Listing for this is below, add it to Checkout.js or anywhere that suits/works :):&lt;br /&gt;&lt;br /&gt;[code]&lt;br /&gt;function requireValidCC(fieldName) {&lt;br /&gt;			el = _CURRENT_FORM.elements[fieldName];&lt;br /&gt;			&lt;br /&gt;			if (!checkCC(el.value)) {&lt;br /&gt;				validationError(el,&quot;Please enter a valid credit card number&quot;,&quot;required&quot;,false);&lt;br /&gt;				return false;&lt;br /&gt;			} else {&lt;br /&gt;			if(!hasHadFormError()) {&lt;br /&gt;				clearErrorMessage(el.parentNode);&lt;br /&gt;			}&lt;br /&gt;			return true;			&lt;br /&gt;			}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function checkCC(s) {&lt;br /&gt;&lt;br /&gt;  var i, n, c, r, t;&lt;br /&gt;&lt;br /&gt;  r = &quot;&quot;;&lt;br /&gt;  for (i = 0; i &amp;lt; s.length; i++) {&lt;br /&gt;    c = parseInt(s.charAt(i), 10);&lt;br /&gt;    if (c &amp;gt;= 0 &amp;amp;&amp;amp; c &amp;lt;= 9)&lt;br /&gt;      r = c + r;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  if (r.length &amp;lt;= 1)&lt;br /&gt;    return false;&lt;br /&gt;&lt;br /&gt;  t = &quot;&quot;;&lt;br /&gt;  for (i = 0; i &amp;lt; r.length; i++) {&lt;br /&gt;    c = parseInt(r.charAt(i), 10);&lt;br /&gt;    if (i % 2 != 0)&lt;br /&gt;      c *= 2;&lt;br /&gt;    t = t + c;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  n = 0;&lt;br /&gt;  for (i = 0; i &amp;lt; t.length; i++) {&lt;br /&gt;    c = parseInt(t.charAt(i), 10);&lt;br /&gt;    n = n + c;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  if (n != 0 &amp;amp;&amp;amp; n % 10 == 0)&lt;br /&gt;    return true;&lt;br /&gt;  else&lt;br /&gt;    return false;&lt;br /&gt;}&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;I'm using a Modified version of the latest release of silverstripe along with a modified version of the svn version of ecommerce so results may vary widely!&lt;br /&gt;&lt;br /&gt;Enjoy.&lt;br /&gt;&lt;br&gt;&lt;br&gt;Posted to: Credit Card Validation</description>
			<pubDate>Wed, 09 Jul 2008 11:35:36 +1200</pubDate>
			<author>Nick Koirala</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=117277</guid>
		</item>
		
		<item>
			<title>Re: Credit Card Validation</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=116886</link>
			<description>brilliant - Thanks!&lt;br /&gt;&lt;br /&gt;I will hold off reinventing the wheel.... Still looking around for another lightweight ecommerce gpl system that will easily integrate with securepaytech without too much effort....&lt;br /&gt;&lt;br /&gt;Need to get a ecommerce site up fast with minimal product and minimal effort....&lt;br /&gt;&lt;br /&gt;Any ideas welcome!&lt;br&gt;&lt;br&gt;Posted to: Credit Card Validation</description>
			<pubDate>Tue, 08 Jul 2008 22:58:14 +1200</pubDate>
			<author>Kerry F</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=116886</guid>
		</item>
		
		<item>
			<title>Re: Credit Card Validation</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=116882</link>
			<description>I'm still in the process of testing and integrating, if I have a suitable version working (hopefully this week, securepaytech are testing it at the moment) I'll post it.&lt;br /&gt;&lt;br /&gt;Can't guarantee it meets silverstripe's code guidelines, but if it works I'll let you all know :)&lt;br /&gt;&lt;br /&gt;Nick&lt;br /&gt;&lt;br&gt;&lt;br&gt;Posted to: Credit Card Validation</description>
			<pubDate>Tue, 08 Jul 2008 22:54:11 +1200</pubDate>
			<author>Nick Koirala</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=116882</guid>
		</item>
		
		<item>
			<title>Re: Credit Card Validation</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=116879</link>
			<description>hi there&lt;br /&gt;&lt;br /&gt;I am also very interested in this....&lt;br /&gt;&lt;br /&gt;Have you managed to get it working well?&lt;br /&gt;&lt;br /&gt;From SilverStripe to SecurePayTech and back again?&lt;br /&gt;&lt;br /&gt;Is there a chance of forwarding your code?&lt;br /&gt;&lt;br /&gt;Many thanks!&lt;br&gt;&lt;br&gt;Posted to: Credit Card Validation</description>
			<pubDate>Tue, 08 Jul 2008 22:50:23 +1200</pubDate>
			<author>Kerry F</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=116879</guid>
		</item>
		
		<item>
			<title>Re: Credit Card Validation</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=104078</link>
			<description>This thread will probably help you: [url]http://www.silverstripe.com/site-builders-forum/flat/1369[/url]&lt;br&gt;&lt;br&gt;Posted to: Credit Card Validation</description>
			<pubDate>Mon, 23 Jun 2008 16:50:49 +1200</pubDate>
			<author>Aaron Cooper</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021?showPost=104078</guid>
		</item>
		
		<item>
			<title>Credit Card Validation</title>
			<link>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021</link>
			<description>I have just made a working SecurePayTech module for ecommerce based of the DPS module.  I have some javascript for client-side credit card validation, something that securepaytech prefers people to do.&lt;br /&gt;&lt;br /&gt;Where do I put this in order to have is triggered either:&lt;br /&gt;1. On leaving the creditcard field, like it currently shows a 'this field is required' message. &lt;br /&gt;or&lt;br /&gt;2. Prior to submit, again triggering a warning message.&lt;br /&gt;&lt;br /&gt;I've looked through the existing javascript, but don't think I'm up to speed with Behaviours etc., to pinpoint where it does what.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Nick&lt;br /&gt;&lt;br&gt;&lt;br&gt;Posted to: Credit Card Validation</description>
			<pubDate>Fri, 20 Jun 2008 15:43:44 +1200</pubDate>
			<author>Nick Koirala</author>
			<guid>http://www.silverstripe.com/extending-hacking-silverstripe-forum/show/102021</guid>
		</item>
		

	</channel>
</rss>
