recurly 2.16.2 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/recurly/invoice.rb +26 -10
- data/lib/recurly/js.rb +0 -81
- data/lib/recurly/version.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bfeb53a4a29911b77e3d863c5ed3354c60205d43c03723f28aa166d161956e0
|
4
|
+
data.tar.gz: 48e368772a86ce80fba49d3621495f344a3b7cc6cd39a6e99e0fff4e8016fda6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bfb17cbe277468533f96a4576d6153b01e164e5f6ef321c204cd252eb0b94522dc7ad393bd39a9b61e3a61be5699f4a0b15bf142d0f791417d7f05321df2137
|
7
|
+
data.tar.gz: 993f84fbf4f298a883f0a25daff915d00a8f0dedcd49a93c303fbdfeafdf96cf77c3869dabe122e1ed593d8baebc1f97c87f791ba60f70d36fe79ebba3cf30fb
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Recurly is packaged as a Ruby gem. We recommend you install it with
|
|
14
14
|
[Bundler](http://gembundler.com/) by adding the following line to your Gemfile:
|
15
15
|
|
16
16
|
``` ruby
|
17
|
-
gem 'recurly', '~> 2.
|
17
|
+
gem 'recurly', '~> 2.17'
|
18
18
|
```
|
19
19
|
|
20
20
|
Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
|
@@ -85,8 +85,7 @@ thread you can use the following within the thread's context:
|
|
85
85
|
Recurly.config({
|
86
86
|
subdomain: ENV['RECURLY_SUBDOMAIN']
|
87
87
|
api_key: ENV['RECURLY_API_KEY'],
|
88
|
-
default_currency: "US"
|
89
|
-
private_key: ENV['RECURLY_PUBLIC_API_KEY']
|
88
|
+
default_currency: "US"
|
90
89
|
})
|
91
90
|
```
|
92
91
|
|
@@ -96,14 +95,15 @@ will be used.
|
|
96
95
|
|
97
96
|
## Supported Ruby Versions
|
98
97
|
|
99
|
-
We are currently supporting ruby language versions `2.
|
98
|
+
We are currently supporting ruby language versions `2.3` and above. `1.9`, `2.0`, `2.1`, and `2.3` may still work but are not officially supported.
|
100
99
|
|
101
100
|
If you are still using one of these rubies, you should know that support for them ended in
|
102
|
-
2015 (1.9), 2016 (2.0),
|
101
|
+
2015 (1.9), 2016 (2.0), 2017 (2.1), 2018 (2.2) and continuing to use them is a security risk.
|
103
102
|
|
104
103
|
- https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/
|
105
104
|
- https://www.ruby-lang.org/en/news/2016/02/24/support-plan-of-ruby-2-0-0-and-2-1/
|
106
105
|
- https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/
|
106
|
+
- https://www.ruby-lang.org/en/news/2018/06/20/support-of-ruby-2-2-has-ended/
|
107
107
|
|
108
108
|
## Nokogiri Support
|
109
109
|
|
data/lib/recurly/invoice.rb
CHANGED
@@ -86,7 +86,7 @@ module Recurly
|
|
86
86
|
line_items
|
87
87
|
transactions
|
88
88
|
terms_and_conditions
|
89
|
-
vat_reverse_charge_notes
|
89
|
+
vat_reverse_charge_notes
|
90
90
|
customer_notes
|
91
91
|
address
|
92
92
|
net_terms
|
@@ -176,11 +176,16 @@ module Recurly
|
|
176
176
|
# refundable.
|
177
177
|
# @raise [Error] If the refund fails.
|
178
178
|
# @param line_items [Array, nil] An array of line items to refund.
|
179
|
-
# @param refund_method ["credit_first", "transaction_first"] The method used to refund.
|
180
|
-
|
179
|
+
# @param refund_method ["credit_first", "transaction_first", "all_transaction", "all_credit"] The method used to refund.
|
180
|
+
# @param external_refund [true, false] Designates that the refund transactions created are manual.
|
181
|
+
# @param credit_customer_notes [String] Adds notes to refund credit invoice.
|
182
|
+
# @param payment_method [String] Creates the manual transactions with this payment method. Allowed if *external_refund* is true.
|
183
|
+
# @param description [String] Sets this value as the *transaction_note* on the manual transactions created. Allowed if *external_refund* is true.
|
184
|
+
# @param refunded_at [DateTime] Sets this value as the *collected_at* on the manual transactions created. Allowed if *external_refund* is true.
|
185
|
+
def refund(line_items = nil, refund_method = 'credit_first', options = {})
|
181
186
|
return false unless link? :refund
|
182
187
|
self.class.from_response(
|
183
|
-
follow_link :refund, :body => refund_line_items_to_xml(line_items, refund_method)
|
188
|
+
follow_link :refund, :body => refund_line_items_to_xml(line_items, refund_method, options)
|
184
189
|
)
|
185
190
|
end
|
186
191
|
|
@@ -190,11 +195,16 @@ module Recurly
|
|
190
195
|
# refundable.
|
191
196
|
# @raise [Error] If the refund fails.
|
192
197
|
# @param amount_in_cents [Integer, nil] The amount (in cents) to refund.
|
193
|
-
# @param refund_method ["credit_first", "transaction_first"] The method used to refund.
|
194
|
-
|
198
|
+
# @param refund_method ["credit_first", "transaction_first", "all_transaction", "all_credit"] The method used to refund.
|
199
|
+
# @param external_refund [true, false] Designates that the refund transactions created are manual.
|
200
|
+
# @param credit_customer_notes [String] Adds notes to refund credit invoice.
|
201
|
+
# @param payment_method [String] Creates the manual transactions with this payment method. Allowed if *external_refund* is true.
|
202
|
+
# @param description [String] Sets this value as the *transaction_note* on the manual transactions created. Allowed if *external_refund* is true.
|
203
|
+
# @param refunded_at [DateTime] Sets this value as the *collected_at* on the manual transactions created. Allowed if *external_refund* is true.
|
204
|
+
def refund_amount(amount_in_cents = nil, refund_method = 'credit_first', options = {})
|
195
205
|
return false unless link? :refund
|
196
206
|
self.class.from_response(
|
197
|
-
follow_link :refund, :body => refund_amount_to_xml(amount_in_cents, refund_method)
|
207
|
+
follow_link :refund, :body => refund_amount_to_xml(amount_in_cents, refund_method, options)
|
198
208
|
)
|
199
209
|
end
|
200
210
|
|
@@ -224,17 +234,23 @@ module Recurly
|
|
224
234
|
super({ :currency => Recurly.default_currency }.merge attributes)
|
225
235
|
end
|
226
236
|
|
227
|
-
def refund_amount_to_xml
|
237
|
+
def refund_amount_to_xml(amount_in_cents = nil, refund_method = nil, options = {})
|
228
238
|
builder = XML.new("<invoice/>")
|
229
239
|
builder.add_element 'refund_method', refund_method
|
230
240
|
builder.add_element 'amount_in_cents', amount_in_cents
|
241
|
+
options.each do |k, v|
|
242
|
+
builder.add_element k.to_s, v
|
243
|
+
end
|
231
244
|
builder.to_s
|
232
245
|
end
|
233
246
|
|
234
|
-
def refund_line_items_to_xml
|
247
|
+
def refund_line_items_to_xml(line_items = nil, refund_method = nil, options = {})
|
235
248
|
builder = XML.new("<invoice/>")
|
236
249
|
builder.add_element 'refund_method', refund_method
|
237
|
-
|
250
|
+
options.each do |k, v|
|
251
|
+
builder.add_element k.to_s, v
|
252
|
+
end
|
253
|
+
line_items ||= []
|
238
254
|
node = builder.add_element 'line_items'
|
239
255
|
line_items.each do |line_item|
|
240
256
|
adj_node = node.add_element 'adjustment'
|
data/lib/recurly/js.rb
CHANGED
@@ -1,35 +1,6 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
require 'base64'
|
3
|
-
require 'cgi'
|
4
|
-
|
5
1
|
module Recurly
|
6
|
-
# @deprecated Please use the new Recurly.js tokenization system https://dev.recurly.com/docs/recurlyjs
|
7
|
-
#
|
8
|
-
# A collection of helper methods to use to verify the old
|
9
|
-
# {Recurly.js}[http://js.recurly.com/] callbacks.
|
10
2
|
module JS
|
11
|
-
# Raised when signature verification fails.
|
12
|
-
class RequestForgery < Error
|
13
|
-
end
|
14
|
-
|
15
|
-
# Raised when the timestamp is over an hour old. Prevents replay attacks.
|
16
|
-
class RequestTooOld < RequestForgery
|
17
|
-
end
|
18
|
-
|
19
3
|
class << self
|
20
|
-
# @return [String] A private key for Recurly.js.
|
21
|
-
# @raise [ConfigurationError] No private key has been set.
|
22
|
-
def private_key
|
23
|
-
if Thread.current[:recurly_config] && Thread.current[:recurly_config][:private_key]
|
24
|
-
return Thread.current[:recurly_config][:private_key]
|
25
|
-
end
|
26
|
-
|
27
|
-
defined? @private_key and @private_key or raise(
|
28
|
-
ConfigurationError, "private_key not configured"
|
29
|
-
)
|
30
|
-
end
|
31
|
-
attr_writer :private_key
|
32
|
-
|
33
4
|
# @return [String] A public key for Recurly.js.
|
34
5
|
# @raise [ConfigurationError] No public key has been set.
|
35
6
|
def public_key
|
@@ -38,58 +9,6 @@ module Recurly
|
|
38
9
|
)
|
39
10
|
end
|
40
11
|
attr_writer :public_key
|
41
|
-
|
42
|
-
# Create a signature for a given hash for Recurly.js
|
43
|
-
# @param Array of objects and hash of data to sign
|
44
|
-
def sign *records
|
45
|
-
data = records.last.is_a?(Hash) ? records.pop.dup : {}
|
46
|
-
records.each do |record|
|
47
|
-
data[record.class.member_name] = record.signable_attributes
|
48
|
-
end
|
49
|
-
Helper.stringify_keys! data
|
50
|
-
data['timestamp'] ||= Time.now.to_i
|
51
|
-
data['nonce'] ||= Base64.encode64(
|
52
|
-
OpenSSL::Random.random_bytes(32)
|
53
|
-
).gsub(/\W/, '')
|
54
|
-
unsigned = to_query data
|
55
|
-
signed = OpenSSL::HMAC.hexdigest 'sha1', private_key, unsigned
|
56
|
-
signature = [signed, unsigned].join '|'
|
57
|
-
signature = signature.html_safe if signature.respond_to? :html_safe
|
58
|
-
signature
|
59
|
-
end
|
60
|
-
|
61
|
-
# Fetches a record using a token provided by Recurly.js.
|
62
|
-
# @param [String] Token to look up
|
63
|
-
# @return [BillingInfo, Invoice, Subscription] The record created or
|
64
|
-
# modified by Recurly.js
|
65
|
-
# @raise [API::NotFound] No record was found for the token provided.
|
66
|
-
# @example
|
67
|
-
# begin
|
68
|
-
# Recurly.js.fetch params[:token]
|
69
|
-
# rescue Recurly::API::NotFound
|
70
|
-
# # Handle potential tampering here.
|
71
|
-
# end
|
72
|
-
def fetch token
|
73
|
-
Resource.from_response API.get "recurly_js/result/#{token}"
|
74
|
-
end
|
75
|
-
|
76
|
-
# @return [String]
|
77
|
-
def inspect
|
78
|
-
'Recurly.js'
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
def to_query object, key = nil
|
84
|
-
case object
|
85
|
-
when Hash
|
86
|
-
object.map { |k, v| to_query v, key ? "#{key}[#{k}]" : k }.sort * '&'
|
87
|
-
when Array
|
88
|
-
object.map { |o| to_query o, "#{key}[]" } * '&'
|
89
|
-
else
|
90
|
-
"#{CGI.escape key.to_s}=#{CGI.escape object.to_s}"
|
91
|
-
end
|
92
|
-
end
|
93
12
|
end
|
94
13
|
end
|
95
14
|
end
|
data/lib/recurly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recurly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description: 'An API client library for Recurly:
|
153
|
+
description: 'An API client library for Recurly: https://recurly.com'
|
154
154
|
email: support@recurly.com
|
155
155
|
executables: []
|
156
156
|
extensions: []
|
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
271
|
version: '0'
|
272
272
|
requirements: []
|
273
273
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.7.
|
274
|
+
rubygems_version: 2.7.6
|
275
275
|
signing_key:
|
276
276
|
specification_version: 4
|
277
277
|
summary: Recurly API Client
|