paypal-sdk-rest 1.4.9 → 1.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2490e56be1c78da53b019c1702f3d547df672024
4
- data.tar.gz: bceeb80ea46eb51676489edcde9a6c419c9066f0
2
+ SHA256:
3
+ metadata.gz: ceddc9047784a7073f8972215a244fd2d836ce6e01ff5a6607f47f121037ea5c
4
+ data.tar.gz: 161ba58a2ab0ed0d76f5d0c8eb454d9771e1f70dd1f843377abee0e16ed7dc82
5
5
  SHA512:
6
- metadata.gz: ace6f59d27a3d96761684d8c89bb75f88e6d24e5a0542b1c60d827a4e409539a890762e151d5517c7147575b780062e906a4092fc32e6db4d04dc7faaebd3669
7
- data.tar.gz: 48ed978938587c4b73b864ec6bb8c2153c8d17e532b7129c1147807c9e5d3aa6339377809ed5d386d7182cb9b8b046768711c22eb7cf0f5b9a72905d84ecb8bf
6
+ metadata.gz: 78c5333220b0e8f3706145337337f6012481c5ace6717f9b22e3103149ddabd712f0129aafec717e6aa2bc8673895278949ee4b764036aea839683239997e67c
7
+ data.tar.gz: 9bb769e8ddfe00d3313c2adf029094bd15be4a044e6e87125f146d3d552e9c962d73f0bb749a60088421ed536abfc5fcba5d4ffbe58fbd16bb3eedaa998908aa
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gem 'rake', :require => false
9
9
  group :test do
10
10
  gem 'simplecov', :require => false
11
11
  gem 'rspec'
12
+ gem 'webmock'
12
13
  end
13
14
 
14
15
  gem 'releasinator', '~> 0.6'
data/README.md CHANGED
@@ -1,8 +1,21 @@
1
+ # Deprecation Notice:
2
+ This SDK is deprecated. You can continue to use it, but no new features or support requests will be accepted.
3
+ For alternatives, please visit [the current SDK homepage on the PayPal Developer Portal](https://developer.paypal.com/docs/api/rest-sdks/)
4
+
1
5
  ## PayPal REST API Ruby SDK [![Build Status](https://travis-ci.org/paypal/PayPal-Ruby-SDK.svg?branch=master)](https://travis-ci.org/paypal/PayPal-Ruby-SDK) [![Coverage Status](https://coveralls.io/repos/github/paypal/PayPal-Ruby-SDK/badge.svg?branch=master)](https://coveralls.io/github/paypal/PayPal-Ruby-SDK?branch=master)
2
6
 
3
7
 
4
8
  The PayPal REST SDK provides Ruby APIs to create, process and manage payment.
5
9
 
10
+ ## PayPal Checkout v2
11
+ Please note that if you are integrating with PayPal Checkout, this SDK and corresponding API [v1/payments](https://developer.paypal.com/docs/api/payments/v1/) are in the process of being deprecated.
12
+
13
+ We recommend that you integrate with API [v2/checkout/orders](https://developer.paypal.com/docs/api/orders/v2/) and [v2/payments](https://developer.paypal.com/docs/api/payments/v2/). Please refer to the [Checkout Ruby SDK](https://github.com/paypal/Checkout-Ruby-SDK) to continue with the integration.
14
+
15
+
16
+ ## 2.0 Release Candidate!
17
+ We're releasing a [brand new version of our SDK!](https://github.com/paypal/PayPal-Ruby-SDK/tree/2.0-beta) 2.0 is currently at release candidate status, and represents a full refactor, with the goal of making all of our APIs extremely easy to use. 2.0 includes all of the existing APIs (except payouts), and includes the new Orders API (disputes and Marketplace coming soon). Check out the [FAQ and migration guide](https://github.com/paypal/PayPal-Ruby-SDK/tree/2.0-beta/docs), and let us know if you have any suggestions or issues!
18
+
6
19
  ## Prerequisites
7
20
  - Ruby 2.0.0 or above
8
21
  - Bundler
@@ -134,38 +147,25 @@ PayPal::SDK::REST.set_config(
134
147
 
135
148
  # Build Payment object
136
149
  @payment = Payment.new({
137
- :intent => "sale",
138
- :payer => {
139
- :payment_method => "credit_card",
140
- :funding_instruments => [{
141
- :credit_card => {
142
- :type => "visa",
143
- :number => "4567516310777851",
144
- :expire_month => "11",
145
- :expire_year => "2018",
146
- :cvv2 => "874",
147
- :first_name => "Joe",
148
- :last_name => "Shopper",
149
- :billing_address => {
150
- :line1 => "52 N Main ST",
151
- :city => "Johnstown",
152
- :state => "OH",
153
- :postal_code => "43210",
154
- :country_code => "US" }}}]},
155
- :transactions => [{
150
+ :intent => "sale",
151
+ :payer => {
152
+ :payment_method => "paypal" },
153
+ :redirect_urls => {
154
+ :return_url => "http://localhost:3000/payment/execute",
155
+ :cancel_url => "http://localhost:3000/" },
156
+ :transactions => [{
156
157
  :item_list => {
157
158
  :items => [{
158
159
  :name => "item",
159
160
  :sku => "item",
160
- :price => "1",
161
+ :price => "5",
161
162
  :currency => "USD",
162
163
  :quantity => 1 }]},
163
- :amount => {
164
- :total => "1.00",
165
- :currency => "USD" },
166
- :description => "This is the payment transaction description." }]})
164
+ :amount => {
165
+ :total => "5",
166
+ :currency => "USD" },
167
+ :description => "This is the payment transaction description." }]})
167
168
 
168
- # Create Payment and return the status(true or false)
169
169
  if @payment.create
170
170
  @payment.id # Payment Id
171
171
  else
@@ -186,8 +186,6 @@ payment_history.payments
186
186
 
187
187
  ## Execute Payment
188
188
 
189
- Only for [Payment](https://github.com/paypal/rest-api-sdk-ruby/blob/master/samples/payment/create_with_paypal.rb) with `payment_method` as `"paypal"`
190
-
191
189
  ```ruby
192
190
  payment = Payment.find("PAY-57363176S1057143SKE2HO3A")
193
191
 
@@ -273,6 +271,10 @@ rescue ResourceNotFound => err
273
271
  logger.error @payout.error.inspect
274
272
  end
275
273
  ```
274
+
275
+ ## Direct Credit Card Support
276
+ [Braintree Direct](https://www.braintreepayments.com/products/braintree-direct) is PayPal's preferred integration solution for accepting direct credit card payments in your mobile app or website. Braintree, a PayPal service, is the easiest way to accept credit cards, PayPal, and many other payment methods.
277
+
276
278
  ## License
277
279
  Code released under [SDK LICENSE](LICENSE)
278
280
 
@@ -136,7 +136,8 @@ module PayPal::SDK::Core
136
136
  def set(key, value)
137
137
  send("#{key}=", value)
138
138
  rescue NoMethodError => error
139
- logger.warn error.message
139
+ # Uncomment to see missing fields
140
+ # logger.debug error.message
140
141
  rescue TypeError, ArgumentError => error
141
142
  raise TypeError, "#{error.message}(#{value.inspect}) for #{self.class.name}.#{key} member"
142
143
  end
@@ -14,7 +14,6 @@ module PayPal::SDK::Core
14
14
  DEFAULT_REST_END_POINTS = {
15
15
  :sandbox => "https://api.sandbox.paypal.com",
16
16
  :live => "https://api.paypal.com",
17
- :security_test_sandbox => "https://test-api.sandbox.paypal.com"
18
17
  }
19
18
  TOKEN_REQUEST_PARAMS = "grant_type=client_credentials"
20
19
 
@@ -140,10 +139,12 @@ module PayPal::SDK::Core
140
139
  def format_response(payload)
141
140
  response = payload[:response]
142
141
  payload[:data] =
143
- if response.code >= "200" and response.code <= "299"
142
+ if response.body && response.body.strip == ""
143
+ {}
144
+ elsif response.code >= "200" and response.code <= "299"
144
145
  response.body && response.content_type == "application/json" ? MultiJson.load(response.body) : {}
145
146
  elsif response.content_type == "application/json"
146
- { "error" => MultiJson.load(response.body) }
147
+ { "error" => flat_hash(MultiJson.load(response.body)) }
147
148
  else
148
149
  { "error" => { "name" => response.code, "message" => response.message,
149
150
  "developer_msg" => response } }
@@ -151,6 +152,18 @@ module PayPal::SDK::Core
151
152
  payload
152
153
  end
153
154
 
155
+ def flat_hash(h)
156
+ new_hash = {}
157
+ h.each_pair do |key, val|
158
+ if val.is_a?(Hash)
159
+ new_hash.merge!(flat_hash(val))
160
+ else
161
+ new_hash[key] = val
162
+ end
163
+ end
164
+ new_hash
165
+ end
166
+
154
167
  # Log PayPal-Request-Id header
155
168
  def log_http_call(payload)
156
169
  if payload[:header] and payload[:header]["PayPal-Request-Id"]
@@ -84,6 +84,10 @@ module PayPal::SDK::Core
84
84
  class ResourceGone < ClientError # :nodoc:
85
85
  end
86
86
 
87
+ # 422 Unprocessable Entity
88
+ class ResourceInvalid < ClientError # :nodoc:
89
+ end
90
+
87
91
  # 5xx Server Error
88
92
  class ServerError < ConnectionError # :nodoc:
89
93
  end
@@ -20,7 +20,7 @@ module PayPal::SDK
20
20
  end
21
21
  alias_method :config=, :set_config
22
22
 
23
- AUTHORIZATION_URL = "paypal.com/webapps/auth/protocol/openidconnect/v1/authorize"
23
+ AUTHORIZATION_URL = "paypal.com/signin/authorize"
24
24
  ENDSESSION_URL = "paypal.com/webapps/auth/protocol/openidconnect/v1/endsession"
25
25
  DEFAULT_SCOPE = "openid"
26
26