<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>penney dot org &#187; Ruby</title>
	<atom:link href="http://www.penney.org/category/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.penney.org</link>
	<description>a little knowledge is a dangerous thing</description>
	<lastBuildDate>Tue, 27 Jul 2010 23:20:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting Substruct to use the PayPal API</title>
		<link>http://www.penney.org/getting-substruct-to-use-the-paypal-api.html</link>
		<comments>http://www.penney.org/getting-substruct-to-use-the-paypal-api.html#comments</comments>
		<pubDate>Wed, 05 Jul 2006 14:13:02 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.penney.org/getting-substruct-to-use-the-paypal-api.html</guid>
		<description><![CDATA[So I&#8217;ve been trying to get Substruct to use PayPal Pro instead of Authorize.net as the payment gateway. There are a couple of options out there to do this namely
vPayPal which I didn&#8217;t have any luck with and
elTechs PayPal plugin which is the option I finally got working
The problems I had were all due to [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been trying to get <a href="http://dev.subimage.com/projects/substruct">Substruct</a> to use PayPal Pro instead of Authorize.net as the payment gateway. There are a couple of options out there to do this namely</p>
<p><a href="http://rubyforge.org/projects/vpaypal/">vPayPal</a> which I didn&#8217;t have any luck with and</p>
<p><a href="http://www.elctech.com/products_ruby_paypal.shtml">elTechs PayPal plugin</a> which is the option I finally got working</p>
<p>The problems I had were all due to bugs in <a href="http://dev.ctor.org/soap4r">soap4r</a> 1.5.5, the so called stable release.</p>
<p>So here is how you tweak soap4r to make it work&#8230; (If you want to be lazy <a href="http://www.penney.org/trunk.zip">download my patched copy</a>)</p>
<ol>
<li>Skip 1.5.5 and grab the code that is sitting on the <a href="http://dev.ctor.org/soap4r/changeset/1681/trunk?old_path=%2F&#038;format=zip">trunk</a> and make these next two updates</li>
<li>Apply <a href="http://dev.ctor.org/soap4r/changeset/1629">patch 1629</a> to complexContent.rb that lives in lib/wsdl/xmlSchema/complexContent.rb</li>
<li>Change wsdl/soap/classDefCreator.rb as follows<br />
Comment out the type = nil line and uncomment the type = create_class_name line)<code /></p>
<pre>if element.type == XSD::AnyTypeName
type = nil
elsif klass = element_basetype(element)
type = klass.name
elsif element.type
type = create_class_name(element.type)
else
# type = nil
# do we define a class for local complexType from it's name?
type = create_class_name(element.name)
end</pre>
</li>
<li>You can now go ahead and run install.rb to install the package.</li>
<li>Follow the rest of the <a href="http://www.elctech.com/ruby/paypal/README">instructions from the PayPal plugin</a></li>
<li>Success!</li>
</ol>
<p>Big thanks to <a href="http://www.brendonwilson.com/blog/2006/04/02/ruby-soap4r-wsdl-hell/">Brenden Wilson</a> as without his post I never would have gotten this running (being a complete RubyNoobie)</p>
<p>The next step is getting all of this working from within Substruct.</p>
<p>Change the finish_order method in store_controller.rb to</p>
<p><code /></p>
<pre>def finish_order
@title = "Thanks for your order!"
@order = find_order
# If there's no order redirect to index
if @order == nil
redirect_to_index and return
end

@transaction_details = {
:firstName => @order.billing_address.first_name,
:lastName => @order.billing_address.last_name,
:ip => "127.0.0.1",
:amount => @order.total.to_s,
:itemName => @order.order_number,
:addressName => "Billing",
:street1 => @order.billing_address.address,
:street2 => "",
:cityName => @order.billing_address.city,
:postalCode =>  @order.billing_address.zip,
:stateOrProvince => @order.billing_address.state,
:country => "US",
:creditCardType => get_credit_card_type(@order.account.cc_number),
:creditCardNumber => @order.account.cc_number,
:cVV2 => @order.account.credit_ccv,
:expMonth => @order.account.expiration_month,
:expYear => @order.account.expiration_year
}

result = Paypal.directauth(@transaction_details)

if(result.ack == "Success")
@payment_message = "Card processed successfully: #{result.transactionID}"
# Save transaction id for later
@order.auth_transaction_id = result.transactionID
logger.info("nnORDER TRANSACTION ID - #{result.transactionID}nn")
# Set completed
@order.cleanup_successful
# Send success message
@order.deliver_receipt
clear_cart_and_order(false)
else
# Order failed - store transaction id
# @order.auth_transaction_id = result.transactionID
@order.cleanup_failed(result.ack)
# Send failed message
@order.deliver_failed
# Log errors
logger.error("nn[ERROR] FAILED ORDER n")
logger.error(result)
logger.error("nn")
# Redirect to checkout and allow them to enter info again.
error_message = "#{result.errors.longMessage}"
error_message << "Try again or contact us for further assistance."
redirect_to_checkout(error_message)
end
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.penney.org/getting-substruct-to-use-the-paypal-api.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Ruby (Briefly) Derailed</title>
		<link>http://www.penney.org/ruby-briefly-derailed.html</link>
		<comments>http://www.penney.org/ruby-briefly-derailed.html#comments</comments>
		<pubDate>Sat, 29 Apr 2006 06:38:00 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.penney.org/ruby-briefly-derailed.html</guid>
		<description><![CDATA[Just tried to get up and running with Ruby on Rails as it looks very slick. Anyway first problem I had was apparently a common one but with various solutions. The error was
error  Before updating scaffolding from new DB schema, try creating a table for your model (Product)
Anyway, the solution was to gem install [...]]]></description>
			<content:encoded><![CDATA[<p>Just tried to get up and running with Ruby on Rails as it looks very slick. Anyway first problem I had was apparently a common one but with various solutions. The error was</p>
<p>error  Before updating scaffolding from new DB schema, try creating a table for your model (Product)</p>
<p>Anyway, the solution was to gem install mysql (choosing the latest) and then copying libmySQL.dll to windows/system32</p>
<p>So now I&#8217;m back on track :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.penney.org/ruby-briefly-derailed.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
