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 +5 -5
- data/Gemfile +1 -0
- data/README.md +29 -27
- data/lib/paypal-sdk/core/api/data_types/base.rb +2 -1
- data/lib/paypal-sdk/core/api/rest.rb +16 -3
- data/lib/paypal-sdk/core/exceptions.rb +4 -0
- data/lib/paypal-sdk/core/openid_connect.rb +1 -1
- data/lib/paypal-sdk/rest/data_types.rb +465 -86
- data/lib/paypal-sdk/rest/error_hash.rb +1 -1
- data/lib/paypal-sdk/rest/version.rb +1 -1
- data/spec/core/api/data_type_spec.rb +100 -0
- data/spec/core/api/rest_spec.rb +66 -2
- data/spec/payments_examples_spec.rb +48 -1
- data/spec/payouts_examples_spec.rb +25 -0
- data/spec/rest/error_hash_spec.rb +83 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/webhooks_examples_spec.rb +8 -0
- metadata +11 -28
- data/spec/log/http.log +0 -0
- data/spec/log/rest_http.log +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ceddc9047784a7073f8972215a244fd2d836ce6e01ff5a6607f47f121037ea5c
|
4
|
+
data.tar.gz: 161ba58a2ab0ed0d76f5d0c8eb454d9771e1f70dd1f843377abee0e16ed7dc82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c5333220b0e8f3706145337337f6012481c5ace6717f9b22e3103149ddabd712f0129aafec717e6aa2bc8673895278949ee4b764036aea839683239997e67c
|
7
|
+
data.tar.gz: 9bb769e8ddfe00d3313c2adf029094bd15be4a044e6e87125f146d3d552e9c962d73f0bb749a60088421ed536abfc5fcba5d4ffbe58fbd16bb3eedaa998908aa
|
data/Gemfile
CHANGED
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 =>
|
138
|
-
:payer =>
|
139
|
-
:payment_method =>
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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 => "
|
161
|
+
:price => "5",
|
161
162
|
:currency => "USD",
|
162
163
|
:quantity => 1 }]},
|
163
|
-
:amount =>
|
164
|
-
:total =>
|
165
|
-
:currency =>
|
166
|
-
: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
|
-
|
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.
|
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"]
|
@@ -20,7 +20,7 @@ module PayPal::SDK
|
|
20
20
|
end
|
21
21
|
alias_method :config=, :set_config
|
22
22
|
|
23
|
-
AUTHORIZATION_URL = "paypal.com/
|
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
|
|