promisepay 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +44 -0
- data/lib/promisepay/client.rb +25 -1
- data/lib/promisepay/configurable.rb +5 -2
- data/lib/promisepay/default.rb +7 -0
- data/lib/promisepay/error.rb +15 -10
- data/lib/promisepay/models/item.rb +77 -0
- data/lib/promisepay/tool.rb +17 -0
- data/lib/promisepay/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 174ed6f8678e430701da0c172bfc2bc1fc48d93e
|
4
|
+
data.tar.gz: e7cf1118146b2dbcf34157b299258b7522ffe75f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59c33e45e95b0d7c718631f3f44f2ad83c32b5d421a6cb9f26eefe29d989cf5bb8bc496a4f56dc8b944cdb59f9efbd61c24a14cab6634a11c0f0640f2d63907e
|
7
|
+
data.tar.gz: 00135493b031cff9e61de1c06acad38cc82edc6bf48c187c5deebe8ccc1fb40a0c4936fd567fc637bc55d9951edefd5b0c966fb241cb35de2bc391c28c153383
|
data/README.md
CHANGED
@@ -274,6 +274,10 @@ item.request_refund(
|
|
274
274
|
refund_message: 'because'
|
275
275
|
)
|
276
276
|
```
|
277
|
+
#####Decline refund
|
278
|
+
```ruby
|
279
|
+
item.decline_refund
|
280
|
+
```
|
277
281
|
#####Refund
|
278
282
|
```ruby
|
279
283
|
item.refund(
|
@@ -281,6 +285,30 @@ item.refund(
|
|
281
285
|
refund_message: 'because'
|
282
286
|
)
|
283
287
|
```
|
288
|
+
#####Raise dispute
|
289
|
+
```ruby
|
290
|
+
item.raise_dispute(user_id: '5830def0-ffe8-11e5-86aa-5e5517507c66')
|
291
|
+
```
|
292
|
+
#####Request resolve dispute
|
293
|
+
```ruby
|
294
|
+
item.request_resolve_dispute
|
295
|
+
```
|
296
|
+
#####Resolve dispute
|
297
|
+
```ruby
|
298
|
+
item.resolve_dispute
|
299
|
+
```
|
300
|
+
#####Escalate dispute
|
301
|
+
```ruby
|
302
|
+
item.escalate_dispute
|
303
|
+
```
|
304
|
+
#####Send tax invoice
|
305
|
+
```ruby
|
306
|
+
item.send_tax_invoice
|
307
|
+
```
|
308
|
+
#####Request tax invoice
|
309
|
+
```ruby
|
310
|
+
item.request_tax_invoice
|
311
|
+
```
|
284
312
|
##Card Accounts
|
285
313
|
#####Create a card account
|
286
314
|
```ruby
|
@@ -527,6 +555,22 @@ dda = client.direct_debit_authorities.find('8f233e04-ffaa-4c9d-adf9-244853848e21
|
|
527
555
|
dda.delete
|
528
556
|
```
|
529
557
|
|
558
|
+
##Tools
|
559
|
+
#####Health check
|
560
|
+
```ruby
|
561
|
+
client.tools.health_check
|
562
|
+
```
|
563
|
+
##Marketplace
|
564
|
+
```ruby
|
565
|
+
client.marketplace
|
566
|
+
```
|
567
|
+
|
568
|
+
##Token
|
569
|
+
#####Generate
|
570
|
+
```ruby
|
571
|
+
client.generate_token(token_type: 'card', user_id: '5830def0-ffe8-11e5-86aa-5e5517507c66')
|
572
|
+
```
|
573
|
+
|
530
574
|
_Check out the [online documentation](http://promisepay.github.io/promisepay-ruby/) to get a full list of available resources and methods._
|
531
575
|
|
532
576
|
#4. Contributing
|
data/lib/promisepay/client.rb
CHANGED
@@ -27,6 +27,7 @@ require_relative 'resources/token_resource'
|
|
27
27
|
require_relative 'resources/transaction_resource'
|
28
28
|
require_relative 'resources/user_resource'
|
29
29
|
require_relative 'resources/wallet_account_resource'
|
30
|
+
require_relative 'tool'
|
30
31
|
require 'json'
|
31
32
|
require 'faraday'
|
32
33
|
|
@@ -112,6 +113,15 @@ module Promisepay
|
|
112
113
|
response
|
113
114
|
end
|
114
115
|
|
116
|
+
# Show details of your Platform.
|
117
|
+
#
|
118
|
+
# @see https://reference.promisepay.com/#show-marketplace
|
119
|
+
#
|
120
|
+
# @return [Hash]
|
121
|
+
def marketplace
|
122
|
+
JSON.parse(get('marketplace').body)['marketplaces']
|
123
|
+
end
|
124
|
+
|
115
125
|
# Available resources for {Client}
|
116
126
|
#
|
117
127
|
# @return [Hash]
|
@@ -128,6 +138,7 @@ module Promisepay
|
|
128
138
|
transactions: TransactionResource,
|
129
139
|
users: UserResource,
|
130
140
|
tokens: TokenResource,
|
141
|
+
tools: Tool,
|
131
142
|
wallet_accounts: WalletAccountResource
|
132
143
|
}
|
133
144
|
end
|
@@ -150,10 +161,23 @@ module Promisepay
|
|
150
161
|
@resources ||= {}
|
151
162
|
end
|
152
163
|
|
164
|
+
# Create a card token that can be used with the PromisePay.js package
|
165
|
+
# to securely send PromisePay credit card details.
|
166
|
+
#
|
167
|
+
# @param options [Hash] Optional options.
|
168
|
+
# @option options [String] :token_type token type ID.
|
169
|
+
# @option user_id [String] :user_id Buyer or Seller ID (already created).
|
170
|
+
#
|
171
|
+
# @return [Hash]
|
172
|
+
def generate_token(options)
|
173
|
+
response = JSON.parse(post("token_auths", options).body)
|
174
|
+
response['token_auth']
|
175
|
+
end
|
176
|
+
|
153
177
|
private
|
154
178
|
|
155
179
|
def on_complete(response)
|
156
|
-
fail Promisepay::Error.from_response(response) unless response.success?
|
180
|
+
fail Promisepay::Error.from_response(response, @errors_format) unless response.success?
|
157
181
|
end
|
158
182
|
end
|
159
183
|
end
|
@@ -12,8 +12,10 @@ module Promisepay
|
|
12
12
|
# @!attribute username
|
13
13
|
# @see http://docs.promisepay.com/v2.2/docs/overview-2
|
14
14
|
# @return [String] Promisepay username for Basic Authentication.
|
15
|
+
# @!attribute errors_format
|
16
|
+
# @return [String] {'processed', 'raw'} format to be used for exception messages.
|
15
17
|
|
16
|
-
attr_accessor :api_domain, :environment, :token, :username
|
18
|
+
attr_accessor :api_domain, :environment, :token, :username, :errors_format
|
17
19
|
|
18
20
|
class << self
|
19
21
|
# List of configurable keys for {Promisepay::Client}.
|
@@ -24,7 +26,8 @@ module Promisepay
|
|
24
26
|
:environment,
|
25
27
|
:api_domain,
|
26
28
|
:token,
|
27
|
-
:username
|
29
|
+
:username,
|
30
|
+
:errors_format
|
28
31
|
]
|
29
32
|
end
|
30
33
|
end
|
data/lib/promisepay/default.rb
CHANGED
data/lib/promisepay/error.rb
CHANGED
@@ -5,7 +5,7 @@ module Promisepay
|
|
5
5
|
#
|
6
6
|
# @param [Faraday::Response] response Faraday HTTP response
|
7
7
|
# @return [Promisepay::Error]
|
8
|
-
def self.from_response(response)
|
8
|
+
def self.from_response(response, errors_format = nil)
|
9
9
|
klass = case response.status
|
10
10
|
when 400 then Promisepay::BadRequest
|
11
11
|
when 401 then Promisepay::Unauthorized
|
@@ -22,11 +22,12 @@ module Promisepay
|
|
22
22
|
when 503 then Promisepay::ServiceUnavailable
|
23
23
|
when 500..599 then Promisepay::ServerError
|
24
24
|
end
|
25
|
-
(klass) ? klass.new(response) : new(response)
|
25
|
+
(klass) ? klass.new(response, errors_format) : new(response, errors_format)
|
26
26
|
end
|
27
27
|
|
28
|
-
def initialize(response = nil)
|
28
|
+
def initialize(response = nil, errors_format = nil)
|
29
29
|
@response = response
|
30
|
+
@errors_format = errors_format
|
30
31
|
super(build_error_message)
|
31
32
|
end
|
32
33
|
|
@@ -35,14 +36,18 @@ module Promisepay
|
|
35
36
|
def build_error_message
|
36
37
|
return nil if @response.nil? || @response.body.nil?
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
case @errors_format
|
40
|
+
when 'raw'
|
41
|
+
@response.body
|
42
|
+
else
|
43
|
+
json_response = JSON.parse(@response.body)
|
44
|
+
message = ''
|
45
|
+
message << json_response['message'] if json_response.key?('message')
|
46
|
+
if json_response.key?('errors')
|
47
|
+
message << json_response['errors'].map{|attribute, content| "#{attribute}: #{content}"}.join(", ")
|
48
|
+
end
|
49
|
+
message
|
43
50
|
end
|
44
|
-
|
45
|
-
message
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
@@ -184,6 +184,17 @@ module Promisepay
|
|
184
184
|
true
|
185
185
|
end
|
186
186
|
|
187
|
+
# Decline a refund request for an Item.
|
188
|
+
#
|
189
|
+
# @see https://reference.promisepay.com/#decline-refund
|
190
|
+
#
|
191
|
+
# @return [Boolean]
|
192
|
+
def decline_refund
|
193
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/decline_refund").body)
|
194
|
+
@attributes = response['items']
|
195
|
+
true
|
196
|
+
end
|
197
|
+
|
187
198
|
# Refund an Item’s funds held in escrow.
|
188
199
|
#
|
189
200
|
# @see https://reference.promisepay.com/#refund
|
@@ -195,6 +206,50 @@ module Promisepay
|
|
195
206
|
true
|
196
207
|
end
|
197
208
|
|
209
|
+
# Raise a dispute for the Item.
|
210
|
+
#
|
211
|
+
# @see https://reference.promisepay.com/#raise-dispute
|
212
|
+
#
|
213
|
+
# @return [Boolean]
|
214
|
+
def raise_dispute(options = {})
|
215
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/raise_dispute", options).body)
|
216
|
+
@attributes = response['items']
|
217
|
+
true
|
218
|
+
end
|
219
|
+
|
220
|
+
# Request that the dispute be resolved.
|
221
|
+
#
|
222
|
+
# @see https://reference.promisepay.com/#request-dispute-resolution
|
223
|
+
#
|
224
|
+
# @return [Boolean]
|
225
|
+
def request_resolve_dispute
|
226
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/request_resolve_dispute").body)
|
227
|
+
@attributes = response['items']
|
228
|
+
true
|
229
|
+
end
|
230
|
+
|
231
|
+
# Resolve a dispute.
|
232
|
+
#
|
233
|
+
# @see https://reference.promisepay.com/#resolve-dispute
|
234
|
+
#
|
235
|
+
# @return [Boolean]
|
236
|
+
def resolve_dispute
|
237
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/resolve_dispute").body)
|
238
|
+
@attributes = response['items']
|
239
|
+
true
|
240
|
+
end
|
241
|
+
|
242
|
+
# Escalate a dispute raised against an Item.
|
243
|
+
#
|
244
|
+
# @see https://reference.promisepay.com/#escalate-dispute
|
245
|
+
#
|
246
|
+
# @return [Boolean]
|
247
|
+
def escalate_dispute
|
248
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/escalate_dispute").body)
|
249
|
+
@attributes = response['items']
|
250
|
+
true
|
251
|
+
end
|
252
|
+
|
198
253
|
# Cancel an Item.
|
199
254
|
#
|
200
255
|
# @see https://reference.promisepay.com/#cancel
|
@@ -205,5 +260,27 @@ module Promisepay
|
|
205
260
|
@attributes = response['items']
|
206
261
|
true
|
207
262
|
end
|
263
|
+
|
264
|
+
# Email a Tax Invoice to the Users associated with the Item.
|
265
|
+
#
|
266
|
+
# @see https://reference.promisepay.com/#send-tax-invoice
|
267
|
+
#
|
268
|
+
# @return [Boolean]
|
269
|
+
def send_tax_invoice
|
270
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/send_tax_invoice").body)
|
271
|
+
@attributes = response['items']
|
272
|
+
true
|
273
|
+
end
|
274
|
+
|
275
|
+
# Request a Tax Invoice be sent to the Users associated with an Item.
|
276
|
+
#
|
277
|
+
# @see https://reference.promisepay.com/#request-tax-invoice
|
278
|
+
#
|
279
|
+
# @return [Boolean]
|
280
|
+
def request_tax_invoice
|
281
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/request_tax_invoice").body)
|
282
|
+
@attributes = response['items']
|
283
|
+
true
|
284
|
+
end
|
208
285
|
end
|
209
286
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Promisepay
|
2
|
+
# Resource for the Tools API
|
3
|
+
class Tool
|
4
|
+
def initialize(client)
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
# Displays a health check of the PromisePay service.
|
9
|
+
#
|
10
|
+
# @see https://reference.promisepay.com/#health-check
|
11
|
+
#
|
12
|
+
# @return [Hash]
|
13
|
+
def health_check
|
14
|
+
JSON.parse(@client.get('status').body)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/promisepay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promisepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain Vigo Benia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/promisepay/resources/transaction_resource.rb
|
109
109
|
- lib/promisepay/resources/user_resource.rb
|
110
110
|
- lib/promisepay/resources/wallet_account_resource.rb
|
111
|
+
- lib/promisepay/tool.rb
|
111
112
|
- lib/promisepay/version.rb
|
112
113
|
- promisepay.gemspec
|
113
114
|
homepage: https://github.com/PromisePay/promisepay-ruby
|