paypal-business 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ CHANGELOG.txt
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ setup.rb
7
+ lib/paypal-business.rb
8
+ lib/paypal-business/version.rb
9
+ lib/paypal-business/PayPalAPIInterfaceServiceClient.rb
10
+ lib/paypal-business/api_cert_chain.crt
11
+ lib/paypal-business/api_cert_chain.pem
12
+ lib/paypal-business/default.rb
13
+ lib/paypal-business/defaultDriver.rb
14
+ lib/paypal-business/paypal.rb
15
+ test/test_helper.rb
@@ -0,0 +1,212 @@
1
+ Ruby on Rails PayPal Plugin v1.4
2
+ by Andre Price and David Stevenson, ELC Technologies
3
+ Based off of the PayPal Web Services Example by Will C
4
+ PayPal Business Gem-
5
+ ----------------------
6
+ This package implements various paypal merchant actions. They are intended to e used at a level transparent to parent applications. Therefore the express check out and other actions that link to and back from paypal's site are curently not implemented. These actions return a response packet that the user can process as they see fit.
7
+
8
+
9
+ Requirements-
10
+ ----------------------
11
+ Valid PayPal Business Account ( or Developer account for testing) -- Instructions for setting up developer account below.
12
+ Soap4r -- Install the latest from http://dev.ctor.org/soap4r.
13
+
14
+
15
+ Getting Developer Account and needed certificates
16
+ ----------------------
17
+ Visit https://developer.paypal.com
18
+ Create an account( remember name and password)
19
+ Login and select the sandbox
20
+ Select Create an Account and follow the steps to create a premier account (remember name and password)
21
+ Once created launch the account via the sandbox site
22
+ Click on the Profile tab in the My Account section
23
+ CLick on API Access and request a direct access certificate
24
+ Download and install certificats as indicated below.
25
+
26
+ Installation-
27
+ ----------------------
28
+ 1) Install GEM
29
+
30
+ 4) Obtain the api chain cert from PayPal. Save this to:
31
+ lib/api_cert_chain.crt
32
+ This file is obtainable through their SDK downloads at http://developer.paypal.com.
33
+
34
+ 5) Obtain a crt/key pair for your sandbox account and save to:
35
+ sandbox_api.crt
36
+ sandbox_api.key
37
+
38
+ 6) Obtain a crt/key pair for your live account and save to:
39
+ live_api.crt
40
+ live_api.key
41
+
42
+ 7) Edit paypal/lib/paypal.rb. Replace 'SANDBOX_ACCOUNT_NAME' with the account
43
+ name that was created for your sandbox account api access.
44
+
45
+ 8) Edit paypal/lib/paypal.rb. Replace 'SANDBOX_ACCOUNT_PASS' with the account
46
+ password for the sandbox api.
47
+
48
+ 9) Repeat the for live account and password:
49
+ change 'LIVE_ACCOUNT_NAME' and 'LIVE_ACCOUNT_PASSWD'
50
+
51
+
52
+ 10) Edit paypal/test/paypal_test.rb.
53
+ a) Replace the variables in good_params with known good parameters
54
+ i)Credit card numbers can be "genereated" trough paypal by using the
55
+ sandbox to add credit cards to your test account.
56
+ (see http://paypaltech.com/Patrick/testAcctOpt/) for more info
57
+
58
+ b) Replace the variables in bad_params with known invalid values.
59
+
60
+ 11) From within /vendor/plugins/paypal, run:
61
+ rake
62
+ this will do dummy operations with the sandbox account
63
+ You should see the following output:
64
+
65
+ /usr/bin/ruby -Ilib:lib "/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader.rb" "test/paypal_test.rb"
66
+ Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake_test_loader
67
+ Started
68
+ .......
69
+ Finished in 10.361749 seconds.
70
+
71
+ 7 tests, 7 assertions, 0 failures, 0 errors
72
+
73
+ 11) Success! If you do have had troubles along the way, see the troubleshooting section below.
74
+
75
+
76
+
77
+ Usage:
78
+ -----------------
79
+ Each function in the Paypal suite have two ways of calling it one for
80
+ test or dummy charges. And one for live acions.
81
+ testing,sandbox: Paypal.directcharge(params)
82
+ live : Paypal.directcharge(params,true)
83
+
84
+ Function: directcharge
85
+ This function performs a doDirectCharge action. Transfering funds from the parameter's account to your paypal merchant account.
86
+
87
+ The return value of this function is the response object from paypal.
88
+ For instance:
89
+ res = Paypal.directcharge(params)
90
+ res.ack == Success // true if action was succesful
91
+ res.ack == Failure // true if action failed
92
+ The directcharge method takes a hash argument (params).
93
+ The method expects the hash to be in the form of:
94
+ :firstName => "<FIRST_NAME_VALUE>",
95
+ :lastName => "<LAST_NAME_VALUE>",
96
+ :ip => "<BUYERS_IP_ADDRESS",
97
+ :ammount => "<AMOUNT_TO_CHARGE>", //This value has a maximum of 10,000.00
98
+ :itemName => "<ITEM_THAT_IS_BEING_SOLD",
99
+ :addressName => "Billing",
100
+ :street1 => "<FIRST LINE OF STREET ADDRESS>",
101
+ :street2 => "<SECOND LINE OF STREET ADDRESS>",
102
+ :cityName => "<CITY OF BILLING ADDRESS OF CARD>",
103
+ :postalCode => "<ZIPCODE OF BILLING ADDRESS OF CARD>",
104
+ :stateOrProvince => "<STATECODE OF BILLING ADDRESS>",
105
+ :country => "<COUNTRY CODE OF BILLING ADDRESS>",
106
+ :creditCardType => "Visa or MasterCard or Amex or Discover",
107
+ :creditCardNumber => "<VALID CREDIT CARD NUMBER",
108
+ :cVV2 => "<CVV2 AUTHORIZATION NUMBER FROM CARD"
109
+ :expMonth => 1 , //Expiration month in numerical form not string
110
+ :expYear => 2006 ///Expiration year in numerical form
111
+
112
+ Function: directauth
113
+ This function performs a directcharge in authorization mode. This means no actual funds are
114
+ transfered upon comletetion of this action.
115
+
116
+
117
+ The return value of this function is the response object from paypal.
118
+ For instance:
119
+ res = Paypal.directauth(params)
120
+ res.ack == Success // true if action was succesful
121
+ res.ack == Failure // true if action failed
122
+
123
+ The transactionID is needed if you intend to capture the funds authroized by this function.
124
+ The method expects the param hash to be in the form of :
125
+ :firstName => "<FIRST_NAME_VALUE>",
126
+ :lastName => "<LAST_NAME_VALUE>",
127
+ :ip => "<BUYERS_IP_ADDRESS",
128
+ :ammount => "<AMOUNT_TO_CHARGE>", //This value has a maximum of 10,000.00
129
+ :itemName => "<ITEM_THAT_IS_BEING_SOLD",
130
+ :addressName => "Billing",
131
+ :street1 => "<FIRST LINE OF STREET ADDRESS>",
132
+ :street2 => "<SECOND LINE OF STREET ADDRESS>",
133
+ :cityName => "<CITY OF BILLING ADDRESS OF CARD>",
134
+ :postalCode => "<ZIPCODE OF BILLING ADDRESS OF CARD>",
135
+ :stateOrProvince => "<STATECODE OF BILLING ADDRESS>",
136
+ :country => "<COUNTRY CODE OF BILLING ADDRESS>",
137
+ :creditCardType => "Visa or MasterCard or Amex or Discover",
138
+ :creditCardNumber => "<VALID CREDIT CARD NUMBER",
139
+ :cVV2 => "<CVV2 AUTHORIZATION NUMBER FROM CARD"
140
+ :expMonth => 1 , //Expiration month in numerical form not string
141
+ :expYear => 2006 ///Expiration year in numerical form
142
+
143
+
144
+
145
+ Function: capture
146
+
147
+ This funcion performs a doCapture. It captures or collects the charge from a previously authorized
148
+ transaction. This transaction is referenced by the transactionID returned from directauth.
149
+
150
+
151
+ The return value of this function is the response object from paypal.
152
+ For instance:
153
+ res = Paypal.capture(params)
154
+ res.ack == Success // true if action was succesful
155
+ res.ack == Failure // true if action failed
156
+
157
+ The parameter hash for this function is to be in the following form:
158
+ :transactionID => "<transactionID FROM PREVIOUS DIRECT AUTH return object>"
159
+ :amount = > "<AMOUNT TO CHARGE>" //should be less than or equal to
160
+ //auth's amount
161
+ Function: void
162
+
163
+ This funcion performs a DoVoid. It voids the charge from a previously authorized
164
+ transaction. This transaction is referenced by the transactionID value of the return object from directauth.
165
+
166
+
167
+ The return value of this function is the response object from paypal.
168
+ For instance:
169
+ res = Paypal.void(params)
170
+ res.ack == Success // true if action was succesful
171
+ res.ack == Failure // true if action failed
172
+
173
+ The parameter hash for this function is to be in the following form:
174
+ :transactionID => "<transactionID FROM PREVIOUS DIRECT AUTH return object>"
175
+
176
+
177
+ You can run test charges through the console and get an idea on how to use the class by:
178
+ ./script/console
179
+ paypal.directcharge( {
180
+ :firstName => "Justin",
181
+ --- SNIP ---
182
+ :expYear => 2008 } )
183
+
184
+ You should see a bunch of data relating to the response object from paypal.
185
+ For more information on what specific data is given/useful please refer to the PayPal developer api.
186
+
187
+ If things go well and the charge should show in your sandbox. To run the charge live, just add a second parameter of true.
188
+
189
+ paypal.directcharge( {...}, true )
190
+
191
+ If your certificates are all setup correctly, you'll see a credit on your live paypal account.
192
+
193
+ Please direct any questions or comments to: aprice@elctech.com or ds@elctech.com
194
+
195
+
196
+
197
+ Troubleshooting
198
+ -----------------------
199
+ Put the command line to run the test in debug mode.
200
+ /usr/bin/ruby -d -Ilib:lib "/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/rake_test_loader.rb" "test/paypal_test.rb"
201
+
202
+ This will give you lots of information. Look for errors in the XML response. Often passwords with '<' or other non-XML unencoded friendly characters will cause ruby to fail due to the Web Service support being incomplete at this time.
203
+
204
+
205
+ If you are recieving a "NoMethodError: for each..." when trying to perform a capture. Your soap version may need to be updated.
206
+ If this does not work please refer to the following pages which concern this bug in soap4r.
207
+ bug link : http://dev.ctor.org/soap4r/ticket/184
208
+ code fix: http://dev.ctor.org/soap4r/changeset/1674
209
+
210
+ Upgrading Soap4r-
211
+ Please see the following site for more information on upgrading soap4r
212
+ http://www.pranavbihari.com/articles/2005/12/02/testing-paypal-web-services-with-ruby-soap4r
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+ require 'hoe'
11
+ include FileUtils
12
+ require File.join(File.dirname(__FILE__), 'lib', 'paypal-business', 'version')
13
+
14
+ AUTHOR = ["Andre Price", "David Stevenson"] # can also be an array of Authors
15
+ EMAIL = "paypal_business@elctech.com"
16
+ DESCRIPTION = "Ruby-friendly paypal API. Works for both sandbox and live methods."
17
+ GEM_NAME = "paypal-business" # what ppl will type to install your gem
18
+ RUBYFORGE_PROJECT = "paypal-business" # The unix name for your project
19
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
20
+ RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
21
+
22
+
23
+ NAME = "paypal-business"
24
+ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
25
+ VERS = ENV['VERSION'] || (Paypal_business::VERSION::STRING + (REV ? ".#{REV}" : ""))
26
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
27
+ RDOC_OPTS = ['--quiet', '--title', "paypal-business documentation",
28
+ "--opname", "index.html",
29
+ "--line-numbers",
30
+ "--main", "README",
31
+ "--inline-source"]
32
+
33
+ # Generate all the Rake tasks
34
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
35
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
36
+ p.author = AUTHOR
37
+ p.description = DESCRIPTION
38
+ p.email = EMAIL
39
+ p.summary = DESCRIPTION
40
+ p.url = HOMEPATH
41
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
42
+ p.test_globs = ["test/**/*_test.rb"]
43
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
44
+
45
+ # == Optional
46
+ #p.changes - A description of the release's latest changes.
47
+ #p.extra_deps - An array of rubygem dependencies.
48
+ #p.spec_extras - A hash of extra values to set in the gemspec.
49
+ end
50
+
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), "paypal-business/paypal.rb")
2
+ #Dir[File.join(File.dirname(__FILE__), 'paypal-business/**/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,221 @@
1
+ #!/usr/bin/env ruby
2
+ require 'defaultDriver.rb'
3
+
4
+ endpoint_url = ARGV.shift
5
+ obj = PayPalAPIInterface.new(endpoint_url)
6
+
7
+ # run ruby with -d to see SOAP wiredumps.
8
+ obj.wiredump_dev = STDERR if $DEBUG
9
+
10
+ # SYNOPSIS
11
+ # RefundTransaction(refundTransactionRequest)
12
+ #
13
+ # ARGS
14
+ # refundTransactionRequest RefundTransactionReq - {urn:ebay:api:PayPalAPI}RefundTransactionReq
15
+ #
16
+ # RETURNS
17
+ # refundTransactionResponse RefundTransactionResponse - {urn:ebay:api:PayPalAPI}RefundTransactionResponse
18
+ #
19
+ refundTransactionRequest = nil
20
+ puts obj.refundTransaction(refundTransactionRequest)
21
+
22
+ # SYNOPSIS
23
+ # GetTransactionDetails(getTransactionDetailsRequest)
24
+ #
25
+ # ARGS
26
+ # getTransactionDetailsRequest GetTransactionDetailsReq - {urn:ebay:api:PayPalAPI}GetTransactionDetailsReq
27
+ #
28
+ # RETURNS
29
+ # getTransactionDetailsResponse GetTransactionDetailsResponse - {urn:ebay:api:PayPalAPI}GetTransactionDetailsResponse
30
+ #
31
+ getTransactionDetailsRequest = nil
32
+ puts obj.getTransactionDetails(getTransactionDetailsRequest)
33
+
34
+ # SYNOPSIS
35
+ # BillUser(billUserRequest)
36
+ #
37
+ # ARGS
38
+ # billUserRequest BillUserReq - {urn:ebay:api:PayPalAPI}BillUserReq
39
+ #
40
+ # RETURNS
41
+ # billUserResponse BillUserResponse - {urn:ebay:api:PayPalAPI}BillUserResponse
42
+ #
43
+ billUserRequest = nil
44
+ puts obj.billUser(billUserRequest)
45
+
46
+ # SYNOPSIS
47
+ # TransactionSearch(transactionSearchRequest)
48
+ #
49
+ # ARGS
50
+ # transactionSearchRequest TransactionSearchReq - {urn:ebay:api:PayPalAPI}TransactionSearchReq
51
+ #
52
+ # RETURNS
53
+ # transactionSearchResponse TransactionSearchResponse - {urn:ebay:api:PayPalAPI}TransactionSearchResponse
54
+ #
55
+ transactionSearchRequest = nil
56
+ puts obj.transactionSearch(transactionSearchRequest)
57
+
58
+ # SYNOPSIS
59
+ # MassPay(massPayRequest)
60
+ #
61
+ # ARGS
62
+ # massPayRequest MassPayReq - {urn:ebay:api:PayPalAPI}MassPayReq
63
+ #
64
+ # RETURNS
65
+ # massPayResponse MassPayResponse - {urn:ebay:api:PayPalAPI}MassPayResponse
66
+ #
67
+ massPayRequest = nil
68
+ puts obj.massPay(massPayRequest)
69
+
70
+ # SYNOPSIS
71
+ # BillAgreementUpdate(billAgreementUpdateRequest)
72
+ #
73
+ # ARGS
74
+ # billAgreementUpdateRequest BillAgreementUpdateReq - {urn:ebay:api:PayPalAPI}BillAgreementUpdateReq
75
+ #
76
+ # RETURNS
77
+ # body BAUpdateResponse - {urn:ebay:api:PayPalAPI}BAUpdateResponse
78
+ #
79
+ billAgreementUpdateRequest = nil
80
+ puts obj.billAgreementUpdate(billAgreementUpdateRequest)
81
+
82
+ # SYNOPSIS
83
+ # AddressVerify(addressVerifyRequest)
84
+ #
85
+ # ARGS
86
+ # addressVerifyRequest AddressVerifyReq - {urn:ebay:api:PayPalAPI}AddressVerifyReq
87
+ #
88
+ # RETURNS
89
+ # addressVerifyResponse AddressVerifyResponse - {urn:ebay:api:PayPalAPI}AddressVerifyResponse
90
+ #
91
+ addressVerifyRequest = nil
92
+ puts obj.addressVerify(addressVerifyRequest)
93
+
94
+ # SYNOPSIS
95
+ # EnterBoarding(enterBoardingRequest)
96
+ #
97
+ # ARGS
98
+ # enterBoardingRequest EnterBoardingReq - {urn:ebay:api:PayPalAPI}EnterBoardingReq
99
+ #
100
+ # RETURNS
101
+ # enterBoardingResponse EnterBoardingResponse - {urn:ebay:api:PayPalAPI}EnterBoardingResponse
102
+ #
103
+ enterBoardingRequest = nil
104
+ puts obj.enterBoarding(enterBoardingRequest)
105
+
106
+ # SYNOPSIS
107
+ # GetBoardingDetails(getBoardingDetailsRequest)
108
+ #
109
+ # ARGS
110
+ # getBoardingDetailsRequest GetBoardingDetailsReq - {urn:ebay:api:PayPalAPI}GetBoardingDetailsReq
111
+ #
112
+ # RETURNS
113
+ # getBoardingDetailsResponse GetBoardingDetailsResponse - {urn:ebay:api:PayPalAPI}GetBoardingDetailsResponse
114
+ #
115
+ getBoardingDetailsRequest = nil
116
+ puts obj.getBoardingDetails(getBoardingDetailsRequest)
117
+
118
+
119
+ endpoint_url = ARGV.shift
120
+ obj = PayPalAPIAAInterface.new(endpoint_url)
121
+
122
+ # run ruby with -d to see SOAP wiredumps.
123
+ obj.wiredump_dev = STDERR if $DEBUG
124
+
125
+ # SYNOPSIS
126
+ # DoExpressCheckoutPayment(doExpressCheckoutPaymentRequest)
127
+ #
128
+ # ARGS
129
+ # doExpressCheckoutPaymentRequest DoExpressCheckoutPaymentReq - {urn:ebay:api:PayPalAPI}DoExpressCheckoutPaymentReq
130
+ #
131
+ # RETURNS
132
+ # doExpressCheckoutPaymentResponse DoExpressCheckoutPaymentResponse - {urn:ebay:api:PayPalAPI}DoExpressCheckoutPaymentResponse
133
+ #
134
+ doExpressCheckoutPaymentRequest = nil
135
+ puts obj.doExpressCheckoutPayment(doExpressCheckoutPaymentRequest)
136
+
137
+ # SYNOPSIS
138
+ # SetExpressCheckout(setExpressCheckoutRequest)
139
+ #
140
+ # ARGS
141
+ # setExpressCheckoutRequest SetExpressCheckoutReq - {urn:ebay:api:PayPalAPI}SetExpressCheckoutReq
142
+ #
143
+ # RETURNS
144
+ # setExpressCheckoutResponse SetExpressCheckoutResponse - {urn:ebay:api:PayPalAPI}SetExpressCheckoutResponse
145
+ #
146
+ setExpressCheckoutRequest = nil
147
+ puts obj.setExpressCheckout(setExpressCheckoutRequest)
148
+
149
+ # SYNOPSIS
150
+ # GetExpressCheckoutDetails(getExpressCheckoutDetailsRequest)
151
+ #
152
+ # ARGS
153
+ # getExpressCheckoutDetailsRequest GetExpressCheckoutDetailsReq - {urn:ebay:api:PayPalAPI}GetExpressCheckoutDetailsReq
154
+ #
155
+ # RETURNS
156
+ # getExpressCheckoutDetailsResponse GetExpressCheckoutDetailsResponse - {urn:ebay:api:PayPalAPI}GetExpressCheckoutDetailsResponse
157
+ #
158
+ getExpressCheckoutDetailsRequest = nil
159
+ puts obj.getExpressCheckoutDetails(getExpressCheckoutDetailsRequest)
160
+
161
+ # SYNOPSIS
162
+ # DoDirectPayment(doDirectPaymentRequest)
163
+ #
164
+ # ARGS
165
+ # doDirectPaymentRequest DoDirectPaymentReq - {urn:ebay:api:PayPalAPI}DoDirectPaymentReq
166
+ #
167
+ # RETURNS
168
+ # doDirectPaymentResponse DoDirectPaymentResponse - {urn:ebay:api:PayPalAPI}DoDirectPaymentResponse
169
+ #
170
+ doDirectPaymentRequest = nil
171
+ puts obj.doDirectPayment(doDirectPaymentRequest)
172
+
173
+ # SYNOPSIS
174
+ # DoCapture(doCaptureRequest)
175
+ #
176
+ # ARGS
177
+ # doCaptureRequest DoCaptureReq - {urn:ebay:api:PayPalAPI}DoCaptureReq
178
+ #
179
+ # RETURNS
180
+ # doCaptureResponse DoCaptureResponse - {urn:ebay:api:PayPalAPI}DoCaptureResponse
181
+ #
182
+ doCaptureRequest = nil
183
+ puts obj.doCapture(doCaptureRequest)
184
+
185
+ # SYNOPSIS
186
+ # DoReauthorization(doReauthorizationRequest)
187
+ #
188
+ # ARGS
189
+ # doReauthorizationRequest DoReauthorizationReq - {urn:ebay:api:PayPalAPI}DoReauthorizationReq
190
+ #
191
+ # RETURNS
192
+ # doReauthorizationResponse DoReauthorizationResponse - {urn:ebay:api:PayPalAPI}DoReauthorizationResponse
193
+ #
194
+ doReauthorizationRequest = nil
195
+ puts obj.doReauthorization(doReauthorizationRequest)
196
+
197
+ # SYNOPSIS
198
+ # DoVoid(doVoidRequest)
199
+ #
200
+ # ARGS
201
+ # doVoidRequest DoVoidReq - {urn:ebay:api:PayPalAPI}DoVoidReq
202
+ #
203
+ # RETURNS
204
+ # doVoidResponse DoVoidResponse - {urn:ebay:api:PayPalAPI}DoVoidResponse
205
+ #
206
+ doVoidRequest = nil
207
+ puts obj.doVoid(doVoidRequest)
208
+
209
+ # SYNOPSIS
210
+ # DoAuthorization(doAuthorizationRequest)
211
+ #
212
+ # ARGS
213
+ # doAuthorizationRequest DoAuthorizationReq - {urn:ebay:api:PayPalAPI}DoAuthorizationReq
214
+ #
215
+ # RETURNS
216
+ # doAuthorizationResponse DoAuthorizationResponse - {urn:ebay:api:PayPalAPI}DoAuthorizationResponse
217
+ #
218
+ doAuthorizationRequest = nil
219
+ puts obj.doAuthorization(doAuthorizationRequest)
220
+
221
+