paypal-payment 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/.gitignore +19 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +18 -0
  4. data/Guardfile +24 -0
  5. data/README.rdoc +107 -0
  6. data/Rakefile +5 -0
  7. data/docs/AdaptivePayments.rdoc +84 -0
  8. data/docs/PP_NVPAPI_DeveloperGuide.pdf +0 -0
  9. data/docs/PP_WPP_IntegrationGuide.pdf +0 -0
  10. data/docs/adaptive_payments.md +55 -0
  11. data/docs/api.txt +67 -0
  12. data/docs/design.txt +38 -0
  13. data/docs/express_checkout.md +172 -0
  14. data/docs/requirements.txt +32 -0
  15. data/lib/paypal-payment.rb +10 -0
  16. data/lib/paypal/adaptive_payments.rb +31 -0
  17. data/lib/paypal/adaptive_payments/api.rb +51 -0
  18. data/lib/paypal/adaptive_payments/base.rb +11 -0
  19. data/lib/paypal/adaptive_payments/client_details.rb +14 -0
  20. data/lib/paypal/adaptive_payments/display_options.rb +10 -0
  21. data/lib/paypal/adaptive_payments/funding_constraint.rb +11 -0
  22. data/lib/paypal/adaptive_payments/funding_type_info.rb +8 -0
  23. data/lib/paypal/adaptive_payments/funding_type_list.rb +11 -0
  24. data/lib/paypal/adaptive_payments/initiating_entity.rb +11 -0
  25. data/lib/paypal/adaptive_payments/institution_customer.rb +13 -0
  26. data/lib/paypal/adaptive_payments/invoice_data.rb +13 -0
  27. data/lib/paypal/adaptive_payments/invoice_item.rb +11 -0
  28. data/lib/paypal/adaptive_payments/payment.rb +105 -0
  29. data/lib/paypal/adaptive_payments/payment_info.rb +18 -0
  30. data/lib/paypal/adaptive_payments/payment_info_list.rb +11 -0
  31. data/lib/paypal/adaptive_payments/payment_options.rb +39 -0
  32. data/lib/paypal/adaptive_payments/phone.rb +9 -0
  33. data/lib/paypal/adaptive_payments/preapproval.rb +52 -0
  34. data/lib/paypal/adaptive_payments/receiver.rb +17 -0
  35. data/lib/paypal/adaptive_payments/receiver_list.rb +49 -0
  36. data/lib/paypal/adaptive_payments/receiver_options.rb +19 -0
  37. data/lib/paypal/adaptive_payments/request.rb +51 -0
  38. data/lib/paypal/adaptive_payments/response.rb +38 -0
  39. data/lib/paypal/adaptive_payments/response/address.rb +13 -0
  40. data/lib/paypal/adaptive_payments/response/address_list.rb +11 -0
  41. data/lib/paypal/adaptive_payments/response/base_address.rb +13 -0
  42. data/lib/paypal/adaptive_payments/response/details.rb +19 -0
  43. data/lib/paypal/adaptive_payments/response/error_list.rb +15 -0
  44. data/lib/paypal/adaptive_payments/response/pay.rb +31 -0
  45. data/lib/paypal/adaptive_payments/response/pay_error.rb +16 -0
  46. data/lib/paypal/adaptive_payments/response/pay_error_list.rb +15 -0
  47. data/lib/paypal/adaptive_payments/response/pay_options.rb +7 -0
  48. data/lib/paypal/adaptive_payments/response/preapproval.rb +47 -0
  49. data/lib/paypal/adaptive_payments/response/refund.rb +16 -0
  50. data/lib/paypal/adaptive_payments/response/refund_info.rb +24 -0
  51. data/lib/paypal/adaptive_payments/response/refund_info_list.rb +11 -0
  52. data/lib/paypal/adaptive_payments/response/shipping_address.rb +11 -0
  53. data/lib/paypal/adaptive_payments/sender_identifier.rb +7 -0
  54. data/lib/paypal/adaptive_payments/sender_options.rb +8 -0
  55. data/lib/paypal/api.rb +94 -0
  56. data/lib/paypal/cacert.pem +3987 -0
  57. data/lib/paypal/common.rb +11 -0
  58. data/lib/paypal/common/base.rb +83 -0
  59. data/lib/paypal/common/error_data.rb +15 -0
  60. data/lib/paypal/common/request.rb +45 -0
  61. data/lib/paypal/common/request_envelope.rb +13 -0
  62. data/lib/paypal/common/response.rb +34 -0
  63. data/lib/paypal/common/response_envelope.rb +19 -0
  64. data/lib/paypal/express_checkout.rb +19 -0
  65. data/lib/paypal/express_checkout/account.rb +16 -0
  66. data/lib/paypal/express_checkout/api.rb +43 -0
  67. data/lib/paypal/express_checkout/base.rb +37 -0
  68. data/lib/paypal/express_checkout/billing.rb +7 -0
  69. data/lib/paypal/express_checkout/callback.rb +17 -0
  70. data/lib/paypal/express_checkout/checkout.rb +144 -0
  71. data/lib/paypal/express_checkout/fields.rb +449 -0
  72. data/lib/paypal/express_checkout/fmf.rb +7 -0
  73. data/lib/paypal/express_checkout/payment.rb +76 -0
  74. data/lib/paypal/express_checkout/payment_item.rb +7 -0
  75. data/lib/paypal/express_checkout/recurring.rb +131 -0
  76. data/lib/paypal/express_checkout/request.rb +212 -0
  77. data/lib/paypal/express_checkout/response.rb +52 -0
  78. data/lib/paypal/express_checkout/response/account.rb +30 -0
  79. data/lib/paypal/express_checkout/response/address.rb +29 -0
  80. data/lib/paypal/express_checkout/response/authorization.rb +25 -0
  81. data/lib/paypal/express_checkout/response/base.rb +125 -0
  82. data/lib/paypal/express_checkout/response/callback_request.rb +10 -0
  83. data/lib/paypal/express_checkout/response/callback_response.rb +8 -0
  84. data/lib/paypal/express_checkout/response/capture.rb +14 -0
  85. data/lib/paypal/express_checkout/response/checkout.rb +11 -0
  86. data/lib/paypal/express_checkout/response/details.rb +35 -0
  87. data/lib/paypal/express_checkout/response/manage_profile.rb +9 -0
  88. data/lib/paypal/express_checkout/response/notification.rb +85 -0
  89. data/lib/paypal/express_checkout/response/payment.rb +24 -0
  90. data/lib/paypal/express_checkout/response/profile.rb +58 -0
  91. data/lib/paypal/express_checkout/response/reference.rb +11 -0
  92. data/lib/paypal/express_checkout/response/refund.rb +13 -0
  93. data/lib/paypal/express_checkout/response/search.rb +33 -0
  94. data/lib/paypal/express_checkout/response/transaction_details.rb +11 -0
  95. data/lib/paypal/express_checkout/shipping_option.rb +7 -0
  96. data/lib/paypal/express_checkout/utils.rb +26 -0
  97. data/lib/paypal/express_checkout/version.rb +10 -0
  98. data/lib/paypal/invoice.rb +22 -0
  99. data/lib/paypal/invoice/api.rb +51 -0
  100. data/lib/paypal/invoice/base.rb +11 -0
  101. data/lib/paypal/invoice/base_address.rb +11 -0
  102. data/lib/paypal/invoice/business_info.rb +17 -0
  103. data/lib/paypal/invoice/date_range.rb +8 -0
  104. data/lib/paypal/invoice/invoice.rb +117 -0
  105. data/lib/paypal/invoice/invoice_details.rb +38 -0
  106. data/lib/paypal/invoice/invoice_item.rb +13 -0
  107. data/lib/paypal/invoice/invoice_item_list.rb +10 -0
  108. data/lib/paypal/invoice/invoice_summary.rb +22 -0
  109. data/lib/paypal/invoice/invoice_summary_list.rb +10 -0
  110. data/lib/paypal/invoice/other_payment_details.rb +13 -0
  111. data/lib/paypal/invoice/payment_details.rb +16 -0
  112. data/lib/paypal/invoice/paypal_payment_details.rb +11 -0
  113. data/lib/paypal/invoice/request.rb +43 -0
  114. data/lib/paypal/invoice/response.rb +27 -0
  115. data/lib/paypal/invoice/response/details.rb +23 -0
  116. data/lib/paypal/invoice/response/invoice.rb +10 -0
  117. data/lib/paypal/invoice/response/search.rb +15 -0
  118. data/lib/paypal/invoice/search.rb +19 -0
  119. data/lib/paypal/invoice/search_parameters.rb +20 -0
  120. data/lib/paypal/permissions.rb +12 -0
  121. data/lib/paypal/permissions/api.rb +60 -0
  122. data/lib/paypal/permissions/base.rb +11 -0
  123. data/lib/paypal/permissions/permission.rb +33 -0
  124. data/lib/paypal/permissions/personal_data.rb +17 -0
  125. data/lib/paypal/permissions/request.rb +52 -0
  126. data/lib/paypal/permissions/response.rb +24 -0
  127. data/lib/paypal/permissions/response/permission.rb +14 -0
  128. data/lib/paypal/permissions/response/personal_data.rb +8 -0
  129. data/lib/paypal/permissions/response/token.rb +10 -0
  130. data/lib/paypal/permissions/token.rb +13 -0
  131. data/lib/paypal/recurring.rb +110 -0
  132. data/lib/paypal/request.rb +82 -0
  133. data/lib/paypal/version.rb +8 -0
  134. data/paypal-payment.gemspec +30 -0
  135. data/spec/fixtures/adaptive_payments/payment/create/failure.yml +62 -0
  136. data/spec/fixtures/adaptive_payments/payment/create/success.yml +58 -0
  137. data/spec/fixtures/adaptive_payments/payment/details/success.yml +113 -0
  138. data/spec/fixtures/adaptive_payments/payment/pay/failure.yml +62 -0
  139. data/spec/fixtures/adaptive_payments/payment/pay/preapproval.yml +58 -0
  140. data/spec/fixtures/adaptive_payments/payment/pay/success.yml +58 -0
  141. data/spec/fixtures/adaptive_payments/payment/pay/with_pay_key.yml +58 -0
  142. data/spec/fixtures/adaptive_payments/payment/refund/failure.yml +62 -0
  143. data/spec/fixtures/adaptive_payments/payment/refund/success.yml +58 -0
  144. data/spec/fixtures/adaptive_payments/payment/shipping_addresses/success.yml +113 -0
  145. data/spec/fixtures/adaptive_payments/payment_options/get/success.yml +174 -0
  146. data/spec/fixtures/adaptive_payments/payment_options/set/success.yml +113 -0
  147. data/spec/fixtures/adaptive_payments/preapproval/create/success.yml +58 -0
  148. data/spec/fixtures/adaptive_payments/preapproval/details/success.yml +168 -0
  149. data/spec/fixtures/express_checkout/account/balance/success.yml +32 -0
  150. data/spec/fixtures/express_checkout/account/pal_details/success.yml +32 -0
  151. data/spec/fixtures/express_checkout/checkout/checkout/sales/success.yml +61 -0
  152. data/spec/fixtures/express_checkout/checkout/checkout/success.yml +32 -0
  153. data/spec/fixtures/express_checkout/checkout/details/failure.yml +32 -0
  154. data/spec/fixtures/express_checkout/checkout/details/success.yml +61 -0
  155. data/spec/fixtures/express_checkout/checkout/pay/sales/success.yml +61 -0
  156. data/spec/fixtures/express_checkout/checkout/pay/success.yml +61 -0
  157. data/spec/fixtures/express_checkout/payment/details/failure.yml +32 -0
  158. data/spec/fixtures/express_checkout/payment/details/success.yml +32 -0
  159. data/spec/fixtures/express_checkout/payment/refund/failure.yml +32 -0
  160. data/spec/fixtures/express_checkout/payment/refund/success.yml +32 -0
  161. data/spec/fixtures/express_checkout/payment/search/success.yml +32 -0
  162. data/spec/fixtures/express_checkout/recurring/cancel/failure.yml +32 -0
  163. data/spec/fixtures/express_checkout/recurring/cancel/success.yml +32 -0
  164. data/spec/fixtures/express_checkout/recurring/checkout/success.yml +32 -0
  165. data/spec/fixtures/express_checkout/recurring/create_profile/failure.yml +32 -0
  166. data/spec/fixtures/express_checkout/recurring/create_profile/success.yml +61 -0
  167. data/spec/fixtures/express_checkout/recurring/profile/failure.yml +32 -0
  168. data/spec/fixtures/express_checkout/recurring/profile/success.yml +32 -0
  169. data/spec/fixtures/express_checkout/recurring/reactivate/failure.yml +32 -0
  170. data/spec/fixtures/express_checkout/recurring/reactivate/success.yml +32 -0
  171. data/spec/fixtures/express_checkout/recurring/suspend/failure.yml +32 -0
  172. data/spec/fixtures/express_checkout/recurring/suspend/success.yml +32 -0
  173. data/spec/fixtures/express_checkout/recurring/update_profile/failure.yml +32 -0
  174. data/spec/fixtures/express_checkout/recurring/update_profile/profile.yml +32 -0
  175. data/spec/fixtures/express_checkout/recurring/update_profile/success.yml +32 -0
  176. data/spec/fixtures/invoice/cancel/success.yml +174 -0
  177. data/spec/fixtures/invoice/create/failure.yml +62 -0
  178. data/spec/fixtures/invoice/create/success.yml +60 -0
  179. data/spec/fixtures/invoice/create_and_send/failure.yml +62 -0
  180. data/spec/fixtures/invoice/create_and_send/success.yml +60 -0
  181. data/spec/fixtures/invoice/details/success.yml +117 -0
  182. data/spec/fixtures/invoice/mark_as_paid/failure.yml +180 -0
  183. data/spec/fixtures/invoice/mark_as_paid/success.yml +174 -0
  184. data/spec/fixtures/invoice/mark_as_refunded/success.yml +174 -0
  185. data/spec/fixtures/invoice/mark_as_unpaid/success.yml +231 -0
  186. data/spec/fixtures/invoice/search/success.yml +174 -0
  187. data/spec/fixtures/invoice/send/success.yml +117 -0
  188. data/spec/fixtures/invoice/update/failure.yml +119 -0
  189. data/spec/fixtures/invoice/update/success.yml +117 -0
  190. data/spec/fixtures/ipn/express_checkout.json +35 -0
  191. data/spec/fixtures/ipn/recurring_payment.json +44 -0
  192. data/spec/fixtures/ipn/recurring_payment_profile_created.json +31 -0
  193. data/spec/fixtures/ipn/recurring_payment_profile_created_with_initial_amount.json +33 -0
  194. data/spec/fixtures/ipn/recurring_payment_skipped.json +30 -0
  195. data/spec/fixtures/ipn/recurring_payment_with_initial_amount.json +44 -0
  196. data/spec/fixtures/notification/failure.yml +50 -0
  197. data/spec/fixtures/notification/success.yml +50 -0
  198. data/spec/paypal/adaptive_payments/api_spec.rb +20 -0
  199. data/spec/paypal/adaptive_payments/payment/base_spec.rb +28 -0
  200. data/spec/paypal/adaptive_payments/payment/create_spec.rb +63 -0
  201. data/spec/paypal/adaptive_payments/payment/details_spec.rb +34 -0
  202. data/spec/paypal/adaptive_payments/payment/pay_spec.rb +97 -0
  203. data/spec/paypal/adaptive_payments/payment/refund_spec.rb +49 -0
  204. data/spec/paypal/adaptive_payments/payment/shipping_addresses_spec.rb +30 -0
  205. data/spec/paypal/adaptive_payments/payment_options/get_spec.rb +33 -0
  206. data/spec/paypal/adaptive_payments/payment_options/set_spec.rb +66 -0
  207. data/spec/paypal/adaptive_payments/preapproval/cancel_spec.rb +34 -0
  208. data/spec/paypal/adaptive_payments/preapproval/create_spec.rb +39 -0
  209. data/spec/paypal/adaptive_payments/preapproval/details_spec.rb +34 -0
  210. data/spec/paypal/adaptive_payments/request_spec.rb +48 -0
  211. data/spec/paypal/api_spec.rb +78 -0
  212. data/spec/paypal/common/base_spec.rb +157 -0
  213. data/spec/paypal/common/error_data_spec.rb +0 -0
  214. data/spec/paypal/common/request_envelope_spec.rb +6 -0
  215. data/spec/paypal/common/response_spec.rb +0 -0
  216. data/spec/paypal/express_checkout/account/balance_spec.rb +25 -0
  217. data/spec/paypal/express_checkout/account/pal_details_spec.rb +20 -0
  218. data/spec/paypal/express_checkout/checkout/checkout_spec.rb +73 -0
  219. data/spec/paypal/express_checkout/checkout/details_spec.rb +70 -0
  220. data/spec/paypal/express_checkout/checkout/pay_spec.rb +68 -0
  221. data/spec/paypal/express_checkout/fields_spec.rb +138 -0
  222. data/spec/paypal/express_checkout/payment/refund_spec.rb +34 -0
  223. data/spec/paypal/express_checkout/payment/search_spec.rb +24 -0
  224. data/spec/paypal/express_checkout/payment/transaction_details_spec.rb +30 -0
  225. data/spec/paypal/express_checkout/payment_spec.rb +13 -0
  226. data/spec/paypal/express_checkout/recurring/create_profile_spec.rb +50 -0
  227. data/spec/paypal/express_checkout/recurring/manage_profile_spec.rb +62 -0
  228. data/spec/paypal/express_checkout/recurring/profile_spec.rb +44 -0
  229. data/spec/paypal/express_checkout/recurring/update_profile_spec.rb +50 -0
  230. data/spec/paypal/express_checkout/request_spec.rb +221 -0
  231. data/spec/paypal/express_checkout/response/account_spec.rb +33 -0
  232. data/spec/paypal/express_checkout/response/base_spec.rb +253 -0
  233. data/spec/paypal/invoice/cancel_spec.rb +38 -0
  234. data/spec/paypal/invoice/create_and_send_spec.rb +58 -0
  235. data/spec/paypal/invoice/create_spec.rb +58 -0
  236. data/spec/paypal/invoice/details_spec.rb +39 -0
  237. data/spec/paypal/invoice/mark_as_paid_spec.rb +75 -0
  238. data/spec/paypal/invoice/mark_as_refunded_spec.rb +47 -0
  239. data/spec/paypal/invoice/mark_as_unpaid_spec.rb +43 -0
  240. data/spec/paypal/invoice/search_spec.rb +70 -0
  241. data/spec/paypal/invoice/send_spec.rb +48 -0
  242. data/spec/paypal/invoice/update_spec.rb +72 -0
  243. data/spec/paypal/request_spec.rb +45 -0
  244. data/spec/spec_helper.rb +35 -0
  245. metadata +546 -0
@@ -0,0 +1,8 @@
1
+ module PayPal::Permissions::Response
2
+ class PersonalData
3
+ include PayPal::Common::Response
4
+
5
+ attr_accessor :personal_data
6
+
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module PayPal::Permissions::Response
2
+ class Token
3
+ include PayPal::Common::Response
4
+
5
+ attr_accessor :scope
6
+ attr_accessor :token
7
+ attr_accessor :token_secret
8
+
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module PayPal::Permissions
2
+ class Token < PayPal::Permissions::Base
3
+
4
+ attr_accessor :token
5
+ attr_accessor :verifier
6
+ attr_accessor :subject_alias
7
+
8
+ def access_token
9
+ Response.process(:get_access_token, request.run(:get_access_token, self.to_hash(:token, :verifier, :subject_alias, :request_envelope)))
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,110 @@
1
+ require "net/https"
2
+ require "cgi"
3
+ require "uri"
4
+ require "ostruct"
5
+ require "time"
6
+
7
+ module PayPal
8
+ module Recurring
9
+ autoload :Base, "paypal/recurring/base"
10
+ autoload :Notification, "paypal/recurring/notification"
11
+ autoload :Request, "paypal/recurring/request"
12
+ autoload :Response, "paypal/recurring/response"
13
+ autoload :Version, "paypal/recurring/version"
14
+ autoload :Utils, "paypal/recurring/utils"
15
+
16
+ ENDPOINTS = {
17
+ :sandbox => {
18
+ :api => "https://api-3t.sandbox.paypal.com/nvp",
19
+ :site => "https://www.sandbox.paypal.com/cgi-bin/webscr"
20
+ },
21
+ :production => {
22
+ :api => "https://api-3t.paypal.com/nvp",
23
+ :site => "https://www.paypal.com/cgi-bin/webscr"
24
+ }
25
+ }
26
+
27
+ class << self
28
+ # Define if requests should be made to PayPal's
29
+ # sandbox environment. This is specially useful when running
30
+ # on development or test mode.
31
+ #
32
+ # PayPal::Recurring.sandbox = true
33
+ #
34
+ attr_accessor :sandbox
35
+
36
+ # Set PayPal's API username.
37
+ #
38
+ attr_accessor :username
39
+
40
+ # Set PayPal's API password.
41
+ #
42
+ attr_accessor :password
43
+
44
+ # Set PayPal's API signature.
45
+ #
46
+ attr_accessor :signature
47
+
48
+ # Set seller id. Will be used to verify IPN.
49
+ #
50
+ #
51
+ attr_accessor :seller_id
52
+
53
+ # The seller e-mail. Will be used to verify IPN.
54
+ #
55
+ attr_accessor :email
56
+ end
57
+
58
+ # Just a shortcut for <tt>PayPal::Recurring::Base.new</tt>.
59
+ #
60
+ def self.new(options = {})
61
+ Base.new(options)
62
+ end
63
+
64
+ # Configure PayPal::Recurring options.
65
+ #
66
+ # PayPal::Recurring.configure do |config|
67
+ # config.sandbox = true
68
+ # end
69
+ #
70
+ def self.configure(&block)
71
+ yield PayPal::Recurring
72
+ end
73
+
74
+ # Detect if sandbox mode is enabled.
75
+ #
76
+ def self.sandbox?
77
+ sandbox == true
78
+ end
79
+
80
+ # Return a name for current environment mode (sandbox or production).
81
+ #
82
+ def self.environment
83
+ sandbox? ? :sandbox : :production
84
+ end
85
+
86
+ # Return URL endpoints for current environment.
87
+ #
88
+ def self.endpoints
89
+ ENDPOINTS[environment]
90
+ end
91
+
92
+ # Return API endpoint based on current environment.
93
+ #
94
+ def self.api_endpoint
95
+ endpoints[:api]
96
+ end
97
+
98
+ # Return PayPal's API version.
99
+ #
100
+ def self.api_version
101
+ "72.0"
102
+ end
103
+
104
+ # Return site endpoint based on current environment.
105
+ #
106
+ def self.site_endpoint
107
+ endpoints[:site]
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,82 @@
1
+ module PayPal
2
+ class Request
3
+
4
+ CA_FILE = File.dirname(__FILE__) + "/cacert.pem"
5
+
6
+ attr_accessor :uri
7
+
8
+ # Do a POST request to PayPal API.
9
+ # The +method+ argument is the name of the API method you want to invoke.
10
+ # For instance, if you want to request a new checkout token, you may want
11
+ # to do something like:
12
+ #
13
+ # response = request.run(:express_checkout)
14
+ #
15
+ # We normalize the methods name. For a list of what's being covered, refer to
16
+ # PayPal::Recurring::Request::METHODS constant.
17
+ #
18
+ # The params hash can use normalized names. For a list, check the
19
+ # PayPal::Recurring::Request::ATTRIBUTES constant.
20
+ #
21
+ def run(method, params = {}, headers = {})
22
+ params = prepare_params(params.merge(:method => api_methods.fetch(method, method.to_s)))
23
+ headers = prepare_headers(headers)
24
+ response = post(params, headers)
25
+ Response.process(method, response)
26
+ end
27
+
28
+ # Post to PayPal api
29
+ #
30
+ def post(params = {}, headers = {})
31
+ Curl.post(uri, params) do |http|
32
+ http.ssl_verify_host = true
33
+ http.ssl_verify_peer = true
34
+ http.cacert = CA_FILE
35
+ headers.each { |key, value| http.headers[key] = value }
36
+ end
37
+ end
38
+
39
+ # Join headers
40
+ #
41
+ def prepare_headers(headers) # :nodoc:
42
+ default_headers.merge(headers)
43
+ end
44
+
45
+ # Default header for setting user agent
46
+ #
47
+ def default_headers # :nodoc:
48
+ {
49
+ 'User-Agent' => "PayPal::Payment/0.1"
50
+ }
51
+ end
52
+
53
+ # Join params and normalize attribute names.
54
+ #
55
+ def prepare_params(params) # :nodoc:
56
+ normalize_params default_params.merge(params)
57
+ end
58
+
59
+ # Parse current API url.
60
+ #
61
+ def uri # :nodoc:
62
+ @uri ||= PayPal::Api.site_endpoint
63
+ end
64
+
65
+ def normalize_params(params)
66
+ params.inject({}) do |buffer, (name, value)|
67
+ attr_names = [ATTRIBUTES[name.to_sym]].flatten.compact
68
+ attr_names << name if attr_names.empty?
69
+
70
+ attr_names.each do |attr_name|
71
+ buffer[attr_name.to_sym] = respond_to?("build_#{name}") ? send("build_#{name}", value) : value
72
+ end
73
+
74
+ buffer
75
+ end
76
+ end
77
+
78
+ def api_methods
79
+ {}
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,8 @@
1
+ module PayPal
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 0
6
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # $:.push File.expand_path("../lib", __FILE__)
3
+ # require "paypal-payment"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "paypal-payment"
7
+ s.version = "0.1.2"
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Chardy Wang"]
10
+ s.email = ["chardy@gmail.com"]
11
+ s.homepage = "http://rubygems.org/gems/paypal-payment"
12
+ s.summary = "PayPal Client."
13
+ s.description = s.summary
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "curb"
21
+ s.add_dependency "multi_json"
22
+
23
+ s.add_development_dependency "rspec"
24
+ s.add_development_dependency "rake"
25
+ s.add_development_dependency "vcr"
26
+ s.add_development_dependency "fakeweb"
27
+ s.add_development_dependency "pry"
28
+ s.add_development_dependency "awesome_print"
29
+ s.add_development_dependency "activesupport"
30
+ end
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://svcs.sandbox.paypal.com/AdaptivePayments/Pay
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"receiverList\":{\"receiver\":[{\"email\":\"chardy_1345003248_per@gmail.com\",\"amount\":10.0}]},\"currencyCode\":\"USD\",\"cancelUrl\":\"example.com/cancel\",\"returnUrl\":\"http://example.com/thank_you\",\"actionType\":\"CREATE\",\"requestEnvelope\":{\"errorLanguage\":\"en_US\",\"detailLevel\":\"ReturnAll\"}}"
9
+ headers:
10
+ User-Agent:
11
+ - PayPal::Payment/0.1.0
12
+ X-Paypal-Security-Userid:
13
+ - chardy_api1.gmail.com
14
+ X-Paypal-Security-Password:
15
+ - "8DTSWBZC7GDR3T4X"
16
+ X-Paypal-Security-Signature:
17
+ - AG-8mOpuFhFyFOYHlaTUYn3Syf15AWJKRnfHMVsmCtC3DK51-ENEPqLS
18
+ X-Paypal-Request-Data-Format:
19
+ - JSON
20
+ X-Paypal-Response-Data-Format:
21
+ - JSON
22
+ X-Paypal-Application-Id:
23
+ - APP-80W284485P519543T
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Fri, 04 Jan 2013 15:57:42 GMT
31
+ Server:
32
+ - Apache-Coyote/1.1
33
+ Cache-Control:
34
+ - no-cache
35
+ X-Ebay-Soa-Request-Id:
36
+ - 13c06483-a370-a486-d630-a7f0ffca5f4c!AdaptivePayments!10.72.109.99![]
37
+ X-Paypal-Operation-Name:
38
+ - Pay
39
+ X-Paypal-Service-Name:
40
+ - "{http://svcs.paypal.com/types/ap}AdaptivePayments"
41
+ X-Ebay-Soa-Message-Protocol:
42
+ - NONE
43
+ X-Ebay-Soa-Response-Data-Format:
44
+ - JSON
45
+ X-Paypal-Service-Version:
46
+ - 1.0.0
47
+ X-Paypal-Error-Response:
48
+ - "TRUE"
49
+ Content-Type:
50
+ - application/json;charset=UTF-8
51
+ Set-Cookie:
52
+ - Apache=10.72.109.11.1357315062321101; path=/; expires=Sun, 28-Dec-42 15:57:42 GMT
53
+ Vary:
54
+ - Accept-Encoding
55
+ Transfer-Encoding:
56
+ - chunked
57
+ body:
58
+ encoding: ASCII-8BIT
59
+ string: "{\"responseEnvelope\":{\"timestamp\":\"2013-01-04T07:57:42.598-08:00\",\"ack\":\"Failure\",\"correlationId\":\"448a7518d9aa6\",\"build\":\"4110101\"},\"error\":[{\"errorId\":\"580028\",\"domain\":\"PLATFORM\",\"subdomain\":\"Application\",\"severity\":\"Error\",\"category\":\"Application\",\"message\":\"The URL example.com\\/cancel is malformed\",\"parameter\":[\"example.com\\/cancel\"]}]}"
60
+ http_version:
61
+ recorded_at: Fri, 04 Jan 2013 15:57:44 GMT
62
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://svcs.sandbox.paypal.com/AdaptivePayments/Pay
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"receiverList\":{\"receiver\":[{\"email\":\"chardy_1345003248_per@gmail.com\",\"amount\":10.0}]},\"preapprovalKey\":\"PA-89578182UL033944H\",\"currencyCode\":\"USD\",\"cancelUrl\":\"http://example.com/cancel\",\"returnUrl\":\"http://example.com/thank_you\",\"actionType\":\"CREATE\",\"requestEnvelope\":{\"errorLanguage\":\"en_US\",\"detailLevel\":\"ReturnAll\"}}"
9
+ headers:
10
+ User-Agent:
11
+ - PayPal::Payment/0.1.0
12
+ X-Paypal-Security-Userid:
13
+ - chardy_api1.gmail.com
14
+ X-Paypal-Security-Password:
15
+ - "8DTSWBZC7GDR3T4X"
16
+ X-Paypal-Security-Signature:
17
+ - AG-8mOpuFhFyFOYHlaTUYn3Syf15AWJKRnfHMVsmCtC3DK51-ENEPqLS
18
+ X-Paypal-Request-Data-Format:
19
+ - JSON
20
+ X-Paypal-Response-Data-Format:
21
+ - JSON
22
+ X-Paypal-Application-Id:
23
+ - APP-80W284485P519543T
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Mon, 21 Jan 2013 14:50:46 GMT
31
+ Server:
32
+ - Apache-Coyote/1.1
33
+ X-Ebay-Soa-Request-Id:
34
+ - 13c5d970-cf10-a486-d636-a986fff66736!AdaptivePayments!10.72.109.99![]
35
+ X-Paypal-Operation-Name:
36
+ - Pay
37
+ X-Paypal-Service-Name:
38
+ - "{http://svcs.paypal.com/types/ap}AdaptivePayments"
39
+ X-Ebay-Soa-Message-Protocol:
40
+ - NONE
41
+ X-Ebay-Soa-Response-Data-Format:
42
+ - JSON
43
+ X-Paypal-Service-Version:
44
+ - 1.0.0
45
+ Content-Type:
46
+ - application/json;charset=UTF-8
47
+ Set-Cookie:
48
+ - Apache=10.72.109.11.1358779845872547; path=/; expires=Wed, 14-Jan-43 14:50:45 GMT
49
+ Vary:
50
+ - Accept-Encoding
51
+ Transfer-Encoding:
52
+ - chunked
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string: "{\"responseEnvelope\":{\"timestamp\":\"2013-01-21T06:50:46.823-08:00\",\"ack\":\"Success\",\"correlationId\":\"2a96375ce9438\",\"build\":\"4923149\"},\"payKey\":\"AP-5C085958M3074971R\",\"paymentExecStatus\":\"CREATED\"}"
56
+ http_version:
57
+ recorded_at: Mon, 21 Jan 2013 14:50:47 GMT
58
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,113 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://svcs.sandbox.paypal.com/AdaptivePayments/Pay
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"receiverList\":{\"receiver\":[{\"email\":\"chardy_1345003248_per@gmail.com\",\"amount\":10.0}]},\"currencyCode\":\"USD\",\"cancelUrl\":\"http://example.com/cancel\",\"returnUrl\":\"http://example.com/thank_you\",\"actionType\":\"CREATE\",\"requestEnvelope\":{\"errorLanguage\":\"en_US\",\"detailLevel\":\"ReturnAll\"}}"
9
+ headers:
10
+ User-Agent:
11
+ - PayPal::Payment/0.1.0
12
+ X-Paypal-Security-Userid:
13
+ - chardy_api1.gmail.com
14
+ X-Paypal-Security-Password:
15
+ - "8DTSWBZC7GDR3T4X"
16
+ X-Paypal-Security-Signature:
17
+ - AG-8mOpuFhFyFOYHlaTUYn3Syf15AWJKRnfHMVsmCtC3DK51-ENEPqLS
18
+ X-Paypal-Request-Data-Format:
19
+ - JSON
20
+ X-Paypal-Response-Data-Format:
21
+ - JSON
22
+ X-Paypal-Application-Id:
23
+ - APP-80W284485P519543T
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Tue, 05 Feb 2013 07:37:48 GMT
31
+ Server:
32
+ - Apache-Coyote/1.1
33
+ X-Ebay-Soa-Request-Id:
34
+ - 13ca94a0-d2f0-a486-d652-b0c2fffef749!AdaptivePayments!10.72.109.101![]
35
+ X-Paypal-Operation-Name:
36
+ - Pay
37
+ X-Paypal-Service-Name:
38
+ - "{http://svcs.paypal.com/types/ap}AdaptivePayments"
39
+ X-Ebay-Soa-Message-Protocol:
40
+ - NONE
41
+ X-Ebay-Soa-Response-Data-Format:
42
+ - JSON
43
+ X-Paypal-Service-Version:
44
+ - 1.0.0
45
+ Content-Type:
46
+ - application/json;charset=UTF-8
47
+ Set-Cookie:
48
+ - Apache=10.72.109.11.1360049868074098; path=/; expires=Thu, 29-Jan-43 07:37:48 GMT
49
+ Vary:
50
+ - Accept-Encoding
51
+ Transfer-Encoding:
52
+ - chunked
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string: "{\"responseEnvelope\":{\"timestamp\":\"2013-02-04T23:37:48.861-08:00\",\"ack\":\"Success\",\"correlationId\":\"b755955ab0586\",\"build\":\"4992011\"},\"payKey\":\"AP-8R817763TY917073J\",\"paymentExecStatus\":\"CREATED\"}"
56
+ http_version:
57
+ recorded_at: Tue, 05 Feb 2013 07:37:49 GMT
58
+ - request:
59
+ method: post
60
+ uri: https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails
61
+ body:
62
+ encoding: UTF-8
63
+ string: "{\"payKey\":\"AP-8R817763TY917073J\",\"requestEnvelope\":{\"errorLanguage\":\"en_US\",\"detailLevel\":\"ReturnAll\"}}"
64
+ headers:
65
+ User-Agent:
66
+ - PayPal::Payment/0.1.0
67
+ X-Paypal-Security-Userid:
68
+ - chardy_api1.gmail.com
69
+ X-Paypal-Security-Password:
70
+ - "8DTSWBZC7GDR3T4X"
71
+ X-Paypal-Security-Signature:
72
+ - AG-8mOpuFhFyFOYHlaTUYn3Syf15AWJKRnfHMVsmCtC3DK51-ENEPqLS
73
+ X-Paypal-Request-Data-Format:
74
+ - JSON
75
+ X-Paypal-Response-Data-Format:
76
+ - JSON
77
+ X-Paypal-Application-Id:
78
+ - APP-80W284485P519543T
79
+ response:
80
+ status:
81
+ code: 200
82
+ message: OK
83
+ headers:
84
+ Date:
85
+ - Tue, 05 Feb 2013 07:37:50 GMT
86
+ Server:
87
+ - Apache-Coyote/1.1
88
+ X-Ebay-Soa-Request-Id:
89
+ - 13ca94a1-54a0-a486-d652-b0c2fffef748!AdaptivePayments!10.72.109.101![]
90
+ X-Paypal-Operation-Name:
91
+ - PaymentDetails
92
+ X-Paypal-Service-Name:
93
+ - "{http://svcs.paypal.com/types/ap}AdaptivePayments"
94
+ X-Ebay-Soa-Message-Protocol:
95
+ - NONE
96
+ X-Ebay-Soa-Response-Data-Format:
97
+ - JSON
98
+ X-Paypal-Service-Version:
99
+ - 1.0.0
100
+ Content-Type:
101
+ - application/json;charset=UTF-8
102
+ Set-Cookie:
103
+ - Apache=10.72.109.11.1360049870148415; path=/; expires=Thu, 29-Jan-43 07:37:50 GMT
104
+ Vary:
105
+ - Accept-Encoding
106
+ Transfer-Encoding:
107
+ - chunked
108
+ body:
109
+ encoding: ASCII-8BIT
110
+ string: "{\"responseEnvelope\":{\"timestamp\":\"2013-02-04T23:37:50.762-08:00\",\"ack\":\"Success\",\"correlationId\":\"c53d41e6b1dfd\",\"build\":\"4992011\"},\"cancelUrl\":\"http:\\/\\/example.com\\/cancel\",\"currencyCode\":\"USD\",\"paymentInfoList\":{\"paymentInfo\":[{\"receiver\":{\"amount\":\"10.00\",\"email\":\"chardy_1345003248_per@gmail.com\",\"primary\":\"false\",\"paymentType\":\"SERVICE\"},\"pendingRefund\":\"false\"}]},\"returnUrl\":\"http:\\/\\/example.com\\/thank_you\",\"status\":\"CREATED\",\"payKey\":\"AP-8R817763TY917073J\",\"actionType\":\"CREATE\",\"feesPayer\":\"EACHRECEIVER\",\"reverseAllParallelPaymentsOnError\":\"false\",\"sender\":{\"useCredentials\":\"false\"}}"
111
+ http_version:
112
+ recorded_at: Tue, 05 Feb 2013 07:37:50 GMT
113
+ recorded_with: VCR 2.3.0