| 1. | New Mexico Service Jane | my website | 04/17/2012 09:43:34 |
I've been having a similar problem. Will try this advice and let you know if it has been successful for me too! Thanks for sharing.
We've been using Paypal's Website Payments Pro for a few years and the ROR::Paypal has been working just fine for our purposes, until I changed things up a bit. I wanted to make the signup more atomic in case of a failure but had trouble when I tried to use the DoCapture method. Looking at the code it actually says in the comments that they couldn't get it to work, awesome right?
First I tried out ActiveMerchant. It looked great and was super easy to implement. Unfortunately it did not work in my app for reasons that are too embarrassing to publicly admit.
After effin around for awhile I found an alternate solution. Apparently there's a Paypal Ruby SDK that uses their NVP or Name Value Pair protocol. I didn't even know the used NVP until now. What a relief, SOAP is so crappy.
The best part is it's super easy to implement. The SDK download is a sample Rails app. To use it yourself all you need to do is copy the PayPalSDK plugin from the vendor directory and paypal.yml from config.
If your currently using a certificate you'll want to switch to a signature, another welcome change. The signature is just a string you pass to the web service, instead of a stupid cert file you have to load up. You can get the signature from the API Settings in your Paypal account. Once you have that info copy the API Username, Password and Signature into the paypal.yml file.
Then look at the controllers in the sample app for examples of how to call it. The basic gist is something like this.
require 'caller'
caller = PayPalSDKCallers::Caller.new
transaction = caller.call(
{
:method => 'DoDirectPayment',
:amt => total.to_s,
:currencycode => 'USD',
:paymentaction => 'Authorization',
:creditcardtype => card.type_code,
:acct => card.card_number,
:firstname => name[0],
:lastname => name[1],
:street => address.address1,
:city => address.city,
:state => address.state,
:zip => address.zipcode.to_s,
:countrycode => address.country,
:expdate => card.card_expiration.strftime("%m%Y"),
:cvv2 => TEST_MODE ? "000" : card.security_code
}
)
if transaction.success?
return transaction.response["TRANSACTIONID"]
else
raise PaymentException, transaction.response["L_LONGMESSAGE0"]
end
I really like this approach because it's a super thin layer that just does what it needs.
| 1. | New Mexico Service Jane | my website | 04/17/2012 09:43:34 |
I've been having a similar problem. Will try this advice and let you know if it has been successful for me too! Thanks for sharing.
Post a Comment