INSTALLATION:

Important: This gem have dependencies for soap4r-1.5.5 library(Sadly soap4r is not available as gem so we could not add it in gem specs).Please ensure that you have installed it before installing VPaypal.Also remember that the latest stable build as of 1.5.5 has a couple of bugs that are critical.

1) Create a sandbox test account at developer.paypal.com and download the sandbox Test Certificates.Creat two separate files from the API certificate, one called ‘client.keys’ containing the RSA private key and the other called ‘client.cert’ and containing the other part of the certificate.

Get the server certificate for paypal too. This certificate can be found at the following location in PayPal’s PHP SDK package: Services_PayPal/PayPal/cert/api_cert_chain.crt

Put all three certificate files in /v_paypal/certs/.

2) Edit /v_paypal/config/v_paypal.yml

a) Replace paypal_username and paypal_password with your account username and password.
b) If you hadn't  kept certificates in specified directory,specify the current locations in:
 	ca_file

client_cert client_keys

c) If you are not doing testing with sandbox account and going live then comment out express_checkout_redirect url For testing and uncomment the live url given below it.

3) For Testing:

For your testing of gem the gem's test include some test data based on our test account on paypal.If you want to check your account edit v_paypal/test/v_paypal.rb

a) Change request_params in test_with_set_express_checkout and test_with_do_direct_payment accordingly. b) If you havn’t created the account yet then skip step 2 & 3 and no changes needed in v_paypal_test.rb.Go ahead with test with provided test account.

Usage: We are using the request structure same as defined in Paypal Pro Payment Integration guide by Paypal.Please refer to this document for request parameters and request name.This manual can be found at

www.paypal.com/en_US/pdf/PP_WebsitePaymentsPro_IntegrationGuide.pdf

New instance can be created as Example:

vpp =VPaypal::PaypalPro.new

OR

vpp = VPaypal::PaypalPro.new(options)

Where options = of v_paypal.yml” Request method- Example:Like for “DoExpressCheckoutPayment” request call vRequest function wid request name and request parameters as follows.There is not need to append “Request” with Request name

  res = vpp.vRequest("DoExpressCheckoutPayment",{ "Token" => token_value, 
                                                "PaymentAction-PaymentActionCode" => "Sale", 
                                                "PayerID" => payerID, 
                                                "PaymentDetails" => 
                                                  {"OrderTotal"=>amount, 
                                                    "ShipppingTotal" =>shipping_total, 
                                                    "ShipToAddress-Address"=> 
                                                    {"Name" => name, 
                                                      "Street1" => street1, 
                                                      "StateOrProvince" => state, 
                                                      "CityName" => city, 
                                                      "Country" => country, 
                                                      "PostalCode" => zip 
                                                    } 
                                                  } 

                                              }) 
One needs to remember that if variable name is different from object name in the request ,the key value must contain both name seperated by a hyphen(-).{"VariableName-ObjectName"=>value}

Example: “ShipToAddress-Address”=>

                                                    {"Name" => name,  
                                                      "Street1" => street1,  
                                                      "StateOrProvince" => state,  
                                                      "CityName" => city,  
                                                      "Country" => country,  
                                                      "PostalCode" => zip  
                                                    }  

Returns Response. Check res.ack for 'Success' Or 'Failure' .Errors can be viewed in res.errors

**Please refer to the Paypal Pro Payment Integration Guide for request parameters and request name.The structure of request we are using is same as there.This manual can be found at

www.paypal.com/en_US/pdf/PP_WebsitePaymentsPro_IntegrationGuide.pdf

** Run the following command to generate the Ruby client interface for the PayPal WSDL files:

<local_soap4r_folder>\bin\wsdl2ruby.rb --wsdl http://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl --type client --force

Running this command will create ‘default.rb’, ‘defaultDriver.rb’, and ‘PayPalAPIInterfaceServiceClient.rb’ files and put them in /v_paypal/lib/v_paypal/. These files are part of our gem so you need not follow auto generate these files unless there is any change in them.

** For the time being this gem is only tested for paypal sandbox testing account. But we hope it should work for live payments as well.

** Thanks to Paranv Bihari for giving us the basic concept for this gem.His posting at www.pranavbihari.com/articles/2005/12/02/testing-paypal-web-services-with-ruby-soap4r and wiki.rubyonrails.com/rails/pages/PayPalWebServices/versions/25 helped us a lot.thanx again.