promisepay 0.0.5 → 0.0.6
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 +105 -31
- data/Rakefile +8 -0
- data/lib/promisepay/client.rb +6 -2
- data/lib/promisepay/error.rb +1 -3
- data/lib/promisepay/models/bank_account.rb +2 -2
- data/lib/promisepay/models/card_account.rb +2 -2
- data/lib/promisepay/models/company.rb +38 -0
- data/lib/promisepay/models/item.rb +48 -36
- data/lib/promisepay/models/paypal_account.rb +2 -2
- data/lib/promisepay/models/transaction.rb +3 -3
- data/lib/promisepay/models/user.rb +41 -5
- data/lib/promisepay/resources/bank_account_resource.rb +16 -2
- data/lib/promisepay/resources/card_account_resource.rb +2 -2
- data/lib/promisepay/resources/company_resource.rb +59 -0
- data/lib/promisepay/resources/fee_resource.rb +3 -3
- data/lib/promisepay/resources/item_resource.rb +3 -3
- data/lib/promisepay/resources/paypal_account_resource.rb +2 -2
- data/lib/promisepay/resources/token_resource.rb +19 -7
- data/lib/promisepay/resources/transaction_resource.rb +2 -2
- data/lib/promisepay/resources/user_resource.rb +4 -4
- data/lib/promisepay/version.rb +1 -1
- data/promisepay.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dacee9ed6f0901b5ffc85139e1d62d1d7c89436
|
4
|
+
data.tar.gz: f99a7de4228a3c7a6190b6bbe478d40d6822c1d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9359c5c0411da5ad38c1ebeaa7253a0279996106f849d2dc38220e8c5c67a146d2ccb8036b26f3da1c09693b6ff0a0587b3e8212e9a0ea82a56b4c474d6c4733
|
7
|
+
data.tar.gz: c578ec4260aa6293eb095ea1962921132e74fec94e268a5c7c4b4fe358597933c4c427d9f0e2d326e714835ecff470196699436aa0237d2cdd10c6eec16c3b33
|
data/README.md
CHANGED
@@ -3,13 +3,15 @@
|
|
3
3
|
[](https://gitter.im/PromisePay/promisepay-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
4
|
|
5
5
|
[](http://badge.fury.io/rb/promisepay)
|
6
|
-
[](https://travis-ci.org/PromisePay/promisepay-ruby)
|
7
|
+
[](https://coveralls.io/r/PromisePay/promisepay-ruby?branch=develop)
|
8
8
|
[](https://codeclimate.com/github/PromisePay/promisepay-ruby)
|
9
9
|
|
10
|
+
To see a completed integration in a Ruby on Rails app, visit this [repository](https://github.com/dannyshafer/PromisePay_api_integration).
|
11
|
+
|
10
12
|
#1. Installation
|
11
13
|
|
12
|
-
Add
|
14
|
+
Add these lines to your application's Gemfile:
|
13
15
|
|
14
16
|
```ruby
|
15
17
|
gem 'promisepay'
|
@@ -27,27 +29,16 @@ Or install it yourself as:
|
|
27
29
|
|
28
30
|
Before interacting with Promispay API you need to generate an access token.
|
29
31
|
|
30
|
-
See
|
32
|
+
See [PromisePay documentation](https://promisepay-docs.readme.io/v1.0/docs/fetching-your-api-key) for more information.
|
31
33
|
|
32
34
|
**Create a PromisePay client**
|
33
35
|
|
34
|
-
```ruby
|
35
|
-
require 'promisepay'
|
36
|
-
|
37
|
-
client = Promisepay::Client.new(username: 'YOUR_USERNAME', token: 'YOUR_TOKEN')
|
38
|
-
```
|
39
|
-
|
40
36
|
The client can be configured through environment variables.
|
41
37
|
|
42
38
|
```ruby
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
require 'promisepay'
|
49
|
-
|
50
|
-
client = Promisepay::Client.new()
|
39
|
+
# In your environment file
|
40
|
+
PROMISEPAY_USERNAME ||= youremailaddress
|
41
|
+
PROMISEPAY_TOKEN ||= y0urt0k3n12345678910123456789101
|
51
42
|
```
|
52
43
|
|
53
44
|
The following parameters are configurable through the client:
|
@@ -57,11 +48,17 @@ The following parameters are configurable through the client:
|
|
57
48
|
* `:environment` / `ENV['PROMISEPAY_ENVIRONMENT']`: API [environment](http://docs.promisepay.com/v2.2/docs/environments) to use (default: 'test')
|
58
49
|
* `:api_domain` / `ENV['PROMISEPAY_API_DOMAIN']`: API domain name to use (default: 'api.promisepay.com')
|
59
50
|
|
51
|
+
Instantiate the PromisePay client.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
client = Promisepay::Client.new(username: ENV['PROMISEPAY_USERNAME'], token: ENV['PROMISEPAY_TOKEN'])
|
55
|
+
```
|
56
|
+
|
60
57
|
#3. Examples
|
61
58
|
|
62
59
|
##Tokens
|
63
60
|
##### Example 1 - Request session token
|
64
|
-
The below example shows the request for a marketplace configured to have the Item and User IDs generated automatically for them.
|
61
|
+
The below example shows the controller request for a marketplace configured to have the Item and User IDs generated automatically for them. Note: by default, the ability to have PromisePay auto generate IDs is turned off. However, it can easily be requested by contacting PromisePay support.
|
65
62
|
|
66
63
|
```ruby
|
67
64
|
token_request = client.tokens.create(:session, {
|
@@ -115,10 +112,10 @@ item = client.items.create(
|
|
115
112
|
id: '12345',
|
116
113
|
name: 'test item for 5AUD',
|
117
114
|
amount: '500',
|
118
|
-
|
115
|
+
payment_type: '1',
|
119
116
|
buyer_id: buyer.id,
|
120
117
|
seller_id: seller.id,
|
121
|
-
|
118
|
+
fee_ids: fee.id,
|
122
119
|
description: '5AUD transfer'
|
123
120
|
)
|
124
121
|
```
|
@@ -180,7 +177,23 @@ user = client.users.create(
|
|
180
177
|
state: 'vic',
|
181
178
|
city: 'Mel',
|
182
179
|
zip: '3000',
|
183
|
-
country: 'AUS'
|
180
|
+
country: 'AUS',
|
181
|
+
dob:'12/06/1980'
|
182
|
+
)
|
183
|
+
```
|
184
|
+
#####Update a user
|
185
|
+
```ruby
|
186
|
+
user = client.users.update(
|
187
|
+
id: '123456',
|
188
|
+
first_name: 'test',
|
189
|
+
last_name: 'buyer',
|
190
|
+
email: 'buyer@test.com',
|
191
|
+
address_line1: '48 collingwood',
|
192
|
+
state: 'vic',
|
193
|
+
city: 'Mel',
|
194
|
+
zip: '3000',
|
195
|
+
country: 'AUS',
|
196
|
+
dob:'12/06/1980'
|
184
197
|
)
|
185
198
|
```
|
186
199
|
#####Get a user
|
@@ -191,15 +204,15 @@ user = client.users.find('1')
|
|
191
204
|
```ruby
|
192
205
|
users = client.users.find_all
|
193
206
|
```
|
194
|
-
#####Get a user's card
|
207
|
+
#####Get a user's card account
|
195
208
|
```ruby
|
196
209
|
user.card_account
|
197
210
|
```
|
198
|
-
#####Get a user's PayPal
|
211
|
+
#####Get a user's PayPal account
|
199
212
|
```ruby
|
200
213
|
user.paypal_account
|
201
214
|
```
|
202
|
-
#####Get a user's bank
|
215
|
+
#####Get a user's bank account
|
203
216
|
```ruby
|
204
217
|
user.bank_account
|
205
218
|
```
|
@@ -207,6 +220,10 @@ user.bank_account
|
|
207
220
|
```ruby
|
208
221
|
user.items
|
209
222
|
```
|
223
|
+
#####Get a user's address
|
224
|
+
```ruby
|
225
|
+
user.address
|
226
|
+
```
|
210
227
|
#####Set a user's disbursement account
|
211
228
|
```ruby
|
212
229
|
user.disbursement_account(bank_account.id)
|
@@ -220,7 +237,7 @@ item.make_payment(
|
|
220
237
|
```
|
221
238
|
#####Request payment
|
222
239
|
```ruby
|
223
|
-
item.
|
240
|
+
item.request_payment
|
224
241
|
```
|
225
242
|
#####Release payment
|
226
243
|
```ruby
|
@@ -248,11 +265,14 @@ item.revert_wire
|
|
248
265
|
```
|
249
266
|
#####Request refund
|
250
267
|
```ruby
|
251
|
-
item.
|
268
|
+
item.request_refund(
|
269
|
+
refund_amount: '1000',
|
270
|
+
refund_message: 'because'
|
271
|
+
)
|
252
272
|
```
|
253
273
|
#####Refund
|
254
274
|
```ruby
|
255
|
-
item.
|
275
|
+
item.refund(
|
256
276
|
refund_amount: '1000',
|
257
277
|
refund_message: 'because'
|
258
278
|
)
|
@@ -302,19 +322,23 @@ bank_account = client.bank_accounts.find('1')
|
|
302
322
|
```
|
303
323
|
#####Deactivate a bank account
|
304
324
|
```ruby
|
305
|
-
bank_account.deactivate
|
325
|
+
bank_account.deactivate
|
306
326
|
```
|
307
327
|
#####Get a bank account's users
|
308
328
|
```ruby
|
309
329
|
bank_account.user
|
310
330
|
```
|
331
|
+
#####Validate Routing Number
|
332
|
+
```ruby
|
333
|
+
client.bank_accounts.validate('122235821')
|
334
|
+
```
|
311
335
|
|
312
336
|
##PayPal Accounts
|
313
337
|
#####Create a PayPal account
|
314
338
|
```ruby
|
315
339
|
paypal_account = client.paypal_accounts.create(
|
316
|
-
|
317
|
-
|
340
|
+
user_id: seller.id,
|
341
|
+
paypal_email: 'seller@promisepay.com'
|
318
342
|
)
|
319
343
|
```
|
320
344
|
#####Get a PayPal account
|
@@ -329,6 +353,56 @@ paypal_account.deactivate
|
|
329
353
|
```ruby
|
330
354
|
paypal_account.user
|
331
355
|
```
|
356
|
+
##Companies
|
357
|
+
|
358
|
+
#####Create a company
|
359
|
+
```ruby
|
360
|
+
client.companies.create(
|
361
|
+
user_id: "1",
|
362
|
+
name: "Acme Co",
|
363
|
+
legal_name: "Acme Co Pty Ltd",
|
364
|
+
tax_number: "1231231",
|
365
|
+
charge_tax: true,
|
366
|
+
address_line1: "123 Test St",
|
367
|
+
address_line2: "",
|
368
|
+
city: "Melbourne",
|
369
|
+
state: "VIC",
|
370
|
+
zip: "3000",
|
371
|
+
country: "AUS"
|
372
|
+
)
|
373
|
+
```
|
374
|
+
|
375
|
+
#####Get a company
|
376
|
+
```ruby
|
377
|
+
client.companies.find('compamy_id')
|
378
|
+
```
|
379
|
+
|
380
|
+
#####Get a list of companies
|
381
|
+
```ruby
|
382
|
+
client.companies.find_all
|
383
|
+
```
|
384
|
+
|
385
|
+
#####Get a company's address
|
386
|
+
```ruby
|
387
|
+
company.address
|
388
|
+
```
|
389
|
+
|
390
|
+
#####Update a company
|
391
|
+
```ruby
|
392
|
+
client.companies.update(
|
393
|
+
id: "8d578b9c-5b79-11e5-885d-feff819cdc9f",
|
394
|
+
name: "Acme Co",
|
395
|
+
legal_name: "Acme Co Pty Ltd",
|
396
|
+
tax_number: "1231231",
|
397
|
+
charge_tax: true,
|
398
|
+
address_line1: "123 Test St",
|
399
|
+
address_line2: "",
|
400
|
+
city: "Melbourne",
|
401
|
+
state: "VIC",
|
402
|
+
zip: "3000",
|
403
|
+
country: "AUS"
|
404
|
+
)
|
405
|
+
```
|
332
406
|
|
333
407
|
##Fees
|
334
408
|
#####Get a list of fees
|
data/Rakefile
CHANGED
data/lib/promisepay/client.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require_relative 'configurable'
|
2
|
+
require_relative 'error'
|
2
3
|
require_relative 'models/base_model'
|
3
4
|
require_relative 'models/account'
|
4
5
|
require_relative 'models/bank_account'
|
5
6
|
require_relative 'models/card_account'
|
7
|
+
require_relative 'models/company'
|
6
8
|
require_relative 'models/fee'
|
7
9
|
require_relative 'models/item'
|
8
10
|
require_relative 'models/paypal_account'
|
@@ -12,6 +14,7 @@ require_relative 'resources/base_resource'
|
|
12
14
|
require_relative 'resources/account_resource'
|
13
15
|
require_relative 'resources/bank_account_resource'
|
14
16
|
require_relative 'resources/card_account_resource'
|
17
|
+
require_relative 'resources/company_resource'
|
15
18
|
require_relative 'resources/fee_resource'
|
16
19
|
require_relative 'resources/item_resource'
|
17
20
|
require_relative 'resources/paypal_account_resource'
|
@@ -52,9 +55,9 @@ module Promisepay
|
|
52
55
|
# @param url [String] The path, relative to {#api_endpoint}
|
53
56
|
# @param parameters [Hash] Query params for request
|
54
57
|
# @return [Faraday::Response]
|
55
|
-
def get(url, parameters = {})
|
58
|
+
def get(url, parameters = {}, skip_status_check = false)
|
56
59
|
response = connection.get("#{api_endpoint}#{url}", parameters)
|
57
|
-
on_complete(response)
|
60
|
+
on_complete(response) unless skip_status_check
|
58
61
|
response
|
59
62
|
end
|
60
63
|
|
@@ -110,6 +113,7 @@ module Promisepay
|
|
110
113
|
{
|
111
114
|
bank_accounts: BankAccountResource,
|
112
115
|
card_accounts: CardAccountResource,
|
116
|
+
companies: CompanyResource,
|
113
117
|
fees: FeeResource,
|
114
118
|
items: ItemResource,
|
115
119
|
paypal_accounts: PaypalAccountResource,
|
data/lib/promisepay/error.rb
CHANGED
@@ -39,9 +39,7 @@ module Promisepay
|
|
39
39
|
message = ''
|
40
40
|
message << json_response['message'] if json_response.key?('message')
|
41
41
|
if json_response.key?('errors')
|
42
|
-
json_response['errors'].
|
43
|
-
message << "#{attribute}: #{content}"
|
44
|
-
end
|
42
|
+
message << json_response['errors'].map{|attribute, content| "#{attribute}: #{content}"}.join(", ")
|
45
43
|
end
|
46
44
|
|
47
45
|
message
|
@@ -3,7 +3,7 @@ module Promisepay
|
|
3
3
|
class BankAccount < Account
|
4
4
|
# Get the user the bank account belongs to.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://reference.promisepay.com/#show-bank-account-user
|
7
7
|
#
|
8
8
|
# @return [Promisepay::User]
|
9
9
|
def user
|
@@ -14,7 +14,7 @@ module Promisepay
|
|
14
14
|
# Deletes a bank account for a user on a marketplace.
|
15
15
|
# Sets the account to in-active.
|
16
16
|
#
|
17
|
-
# @see
|
17
|
+
# @see https://reference.promisepay.com/#redact-bank-account
|
18
18
|
#
|
19
19
|
# @param mobile_pin [String] Mobile PIN.
|
20
20
|
#
|
@@ -3,7 +3,7 @@ module Promisepay
|
|
3
3
|
class CardAccount < Account
|
4
4
|
# Get the user the card account belongs to.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://reference.promisepay.com/#show-card-account-user
|
7
7
|
#
|
8
8
|
# @return [Promisepay::User]
|
9
9
|
def user
|
@@ -14,7 +14,7 @@ module Promisepay
|
|
14
14
|
# Deletes a card account for a user on a marketplace.
|
15
15
|
# Sets the account to in-active.
|
16
16
|
#
|
17
|
-
# @see
|
17
|
+
# @see https://reference.promisepay.com/#redact-card-account
|
18
18
|
#
|
19
19
|
# @return [Boolean]
|
20
20
|
def deactivate
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Promisepay
|
2
|
+
# Manage Companies
|
3
|
+
class Company < BaseModel
|
4
|
+
# Update the attributes of an item.
|
5
|
+
#
|
6
|
+
# @see https://reference.promisepay.com/#update-item
|
7
|
+
#
|
8
|
+
# @param attributes [Hash] Item's attributes to be updated.
|
9
|
+
#
|
10
|
+
# @return [self]
|
11
|
+
def update(attributes)
|
12
|
+
response = JSON.parse(@client.patch("companies/#{send(:id)}", attributes).body)
|
13
|
+
@attributes = response['companies']
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get the user the company belongs to.
|
18
|
+
#
|
19
|
+
# @see
|
20
|
+
#
|
21
|
+
# @return [Promisepay::User]
|
22
|
+
def user
|
23
|
+
response = JSON.parse(@client.get("companies/#{send(:id)}/users").body)
|
24
|
+
Promisepay::User.new(@client, response['users'])
|
25
|
+
end
|
26
|
+
|
27
|
+
# Gets company address.
|
28
|
+
#
|
29
|
+
# @see https://reference.promisepay.com/#addresses
|
30
|
+
#
|
31
|
+
# @return [Hash]
|
32
|
+
def address
|
33
|
+
return nil unless @attributes.key?('related')
|
34
|
+
response = JSON.parse(@client.get("addresses/#{send(:related)['addresses']}").body)
|
35
|
+
response['addresses']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -3,7 +3,7 @@ module Promisepay
|
|
3
3
|
class Item < BaseModel
|
4
4
|
# Update the attributes of an item.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://reference.promisepay.com/#update-item
|
7
7
|
#
|
8
8
|
# @param attributes [Hash] Item's attributes to be updated.
|
9
9
|
#
|
@@ -16,7 +16,7 @@ module Promisepay
|
|
16
16
|
|
17
17
|
# Show the item status for a marketplace.
|
18
18
|
#
|
19
|
-
# @see
|
19
|
+
# @see https://reference.promisepay.com/#show-item-status
|
20
20
|
#
|
21
21
|
# @return [Hash]
|
22
22
|
def status
|
@@ -26,7 +26,7 @@ module Promisepay
|
|
26
26
|
|
27
27
|
# Show the buyer detail for a single item for a marketplace.
|
28
28
|
#
|
29
|
-
# @see
|
29
|
+
# @see https://reference.promisepay.com/#show-item-buyer
|
30
30
|
#
|
31
31
|
# @return [Promisepay::User]
|
32
32
|
def buyer
|
@@ -36,7 +36,7 @@ module Promisepay
|
|
36
36
|
|
37
37
|
# Show the seller detail for a single item for a marketplace.
|
38
38
|
#
|
39
|
-
# @see
|
39
|
+
# @see https://reference.promisepay.com/#show-item-seller
|
40
40
|
#
|
41
41
|
# @return [Promisepay::User]
|
42
42
|
def seller
|
@@ -46,7 +46,7 @@ module Promisepay
|
|
46
46
|
|
47
47
|
# Get fees associated to the item.
|
48
48
|
#
|
49
|
-
# @see
|
49
|
+
# @see https://reference.promisepay.com/#show-item-fees
|
50
50
|
#
|
51
51
|
# @param options [Hash] Optional options.
|
52
52
|
# @option options [Integer] :limit Can ask for up to 200 fees. default: 10
|
@@ -61,7 +61,7 @@ module Promisepay
|
|
61
61
|
|
62
62
|
# Get historical transaction for the item.
|
63
63
|
#
|
64
|
-
# @see
|
64
|
+
# @see https://reference.promisepay.com/#list-item-transactions
|
65
65
|
#
|
66
66
|
# @param options [Hash] Optional options.
|
67
67
|
# @option options [Integer] :limit Can ask for up to 200 transactions. default: 10
|
@@ -76,7 +76,7 @@ module Promisepay
|
|
76
76
|
|
77
77
|
# Show the wire details for payment.
|
78
78
|
#
|
79
|
-
# @see
|
79
|
+
# @see https://reference.promisepay.com/#show-item-wire-details
|
80
80
|
#
|
81
81
|
# @return [Hash]
|
82
82
|
def wire_details
|
@@ -86,7 +86,7 @@ module Promisepay
|
|
86
86
|
|
87
87
|
# Show the bpay details details for payment.
|
88
88
|
#
|
89
|
-
# @see
|
89
|
+
# @see https://reference.promisepay.com/#show-item-bpay-details
|
90
90
|
#
|
91
91
|
# @return [Hash]
|
92
92
|
def bpay_details
|
@@ -94,53 +94,60 @@ module Promisepay
|
|
94
94
|
response['items']['bpay_details']
|
95
95
|
end
|
96
96
|
|
97
|
-
# .
|
97
|
+
# Make a payment for an Item.
|
98
98
|
#
|
99
|
-
# @see
|
99
|
+
# @see https://reference.promisepay.com/#make-payment
|
100
100
|
#
|
101
101
|
# @return [Boolean]
|
102
102
|
def make_payment(options = {})
|
103
|
-
@client.patch("items/#{send(:id)}/make_payment", options).body
|
103
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/make_payment", options).body)
|
104
|
+
@attributes = response['items']
|
104
105
|
true
|
105
106
|
end
|
106
107
|
|
107
|
-
# .
|
108
|
+
# Request payment for an Item.
|
108
109
|
#
|
109
|
-
# @see
|
110
|
+
# @see https://reference.promisepay.com/#request-payment
|
110
111
|
#
|
111
112
|
# @return [Boolean]
|
112
113
|
def request_payment(options = {})
|
113
|
-
@client.patch("items/#{send(:id)}/request_payment", options).body
|
114
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/request_payment", options).body)
|
115
|
+
@attributes = response['items']
|
114
116
|
true
|
115
117
|
end
|
116
118
|
|
117
|
-
#
|
119
|
+
# Release funds held in escrow from an Item with an Escrow or Escrow Partial Release
|
120
|
+
# payment type.
|
118
121
|
#
|
119
|
-
# @see
|
122
|
+
# @see https://reference.promisepay.com/#release-payment
|
120
123
|
#
|
121
124
|
# @return [Boolean]
|
122
125
|
def release_payment(options = {})
|
123
|
-
@client.patch("items/#{send(:id)}/release_payment", options).body
|
126
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/release_payment", options).body)
|
127
|
+
@attributes = response['items']
|
124
128
|
true
|
125
129
|
end
|
126
130
|
|
127
|
-
#
|
131
|
+
# Request release of funds held in escrow, from an Item with an Escrow or Escrow Partial
|
132
|
+
# Release payment type.
|
128
133
|
#
|
129
|
-
# @see
|
134
|
+
# @see https://reference.promisepay.com/#request-release
|
130
135
|
#
|
131
136
|
# @return [Boolean]
|
132
137
|
def request_release(options = {})
|
133
|
-
@client.patch("items/#{send(:id)}/request_release", options).body
|
138
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/request_release", options).body)
|
139
|
+
@attributes = response['items']
|
134
140
|
true
|
135
141
|
end
|
136
142
|
|
137
|
-
# .
|
143
|
+
# Acknowledge that funds are being wired for payment.
|
138
144
|
#
|
139
|
-
# @see
|
145
|
+
# @see https://reference.promisepay.com/#acknowledge-wire-transfer
|
140
146
|
#
|
141
147
|
# @return [Boolean]
|
142
148
|
def acknowledge_wire(options = {})
|
143
|
-
@client.patch("items/#{send(:id)}/acknowledge_wire", options).body
|
149
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/acknowledge_wire", options).body)
|
150
|
+
@attributes = response['items']
|
144
151
|
true
|
145
152
|
end
|
146
153
|
|
@@ -150,47 +157,52 @@ module Promisepay
|
|
150
157
|
#
|
151
158
|
# @return [Boolean]
|
152
159
|
def acknowledge_paypal(options = {})
|
153
|
-
@client.patch("items/#{send(:id)}/acknowledge_paypal", options).body
|
160
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/acknowledge_paypal", options).body)
|
161
|
+
@attributes = response['items']
|
154
162
|
true
|
155
163
|
end
|
156
164
|
|
157
|
-
# .
|
165
|
+
# Revert an acknowledge wire Item Action.
|
158
166
|
#
|
159
|
-
# @see
|
167
|
+
# @see https://reference.promisepay.com/#revert-wire-transfer
|
160
168
|
#
|
161
169
|
# @return [Boolean]
|
162
170
|
def revert_wire(options = {})
|
163
|
-
@client.patch("items/#{send(:id)}/revert_wire", options).body
|
171
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/revert_wire", options).body)
|
172
|
+
@attributes = response['items']
|
164
173
|
true
|
165
174
|
end
|
166
175
|
|
167
|
-
# .
|
176
|
+
# Request a refund for an Item.
|
168
177
|
#
|
169
|
-
# @see
|
178
|
+
# @see https://reference.promisepay.com/#request-refund
|
170
179
|
#
|
171
180
|
# @return [Boolean]
|
172
181
|
def request_refund(options = {})
|
173
|
-
@client.patch("items/#{send(:id)}/request_refund", options).body
|
182
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/request_refund", options).body)
|
183
|
+
@attributes = response['items']
|
174
184
|
true
|
175
185
|
end
|
176
186
|
|
177
|
-
# .
|
187
|
+
# Refund an Item’s funds held in escrow.
|
178
188
|
#
|
179
|
-
# @see
|
189
|
+
# @see https://reference.promisepay.com/#refund
|
180
190
|
#
|
181
191
|
# @return [Boolean]
|
182
192
|
def refund(options = {})
|
183
|
-
@client.patch("items/#{send(:id)}/refund", options).body
|
193
|
+
response = JSON.parse(@client.patch("items/#{send(:id)}/refund", options).body)
|
194
|
+
@attributes = response['items']
|
184
195
|
true
|
185
196
|
end
|
186
197
|
|
187
|
-
# .
|
198
|
+
# Cancel an Item.
|
188
199
|
#
|
189
|
-
# @see
|
200
|
+
# @see https://reference.promisepay.com/#cancel
|
190
201
|
#
|
191
202
|
# @return [Boolean]
|
192
203
|
def cancel
|
193
|
-
@client.patch("items/#{id}/cancel")
|
204
|
+
response = JSON.parse(@client.patch("items/#{id}/cancel").body)
|
205
|
+
@attributes = response['items']
|
194
206
|
true
|
195
207
|
end
|
196
208
|
end
|
@@ -3,7 +3,7 @@ module Promisepay
|
|
3
3
|
class PaypalAccount < Account
|
4
4
|
# Get the user the paypal account belongs to.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://reference.promisepay.com/#show-paypal-account-user
|
7
7
|
#
|
8
8
|
# @return [Promisepay::User]
|
9
9
|
def user
|
@@ -14,7 +14,7 @@ module Promisepay
|
|
14
14
|
# Deletes a Paypal account for a user on a marketplace.
|
15
15
|
# Sets the account to in-active.
|
16
16
|
#
|
17
|
-
# @see
|
17
|
+
# @see https://reference.promisepay.com/#redact-paypal-account
|
18
18
|
#
|
19
19
|
# @return [Boolean]
|
20
20
|
def deactivate
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Promisepay
|
2
2
|
# Manage Transactions
|
3
3
|
class Transaction < Account
|
4
|
-
# .
|
4
|
+
# Show the User associated with the Transaction.
|
5
5
|
#
|
6
|
-
# @see https://
|
6
|
+
# @see https://reference.promisepay.com/#show-transaction-user
|
7
7
|
#
|
8
8
|
# @return [Promisepay::User]
|
9
9
|
def user
|
@@ -13,7 +13,7 @@ module Promisepay
|
|
13
13
|
|
14
14
|
# Gets a transactions fee details if applicable.
|
15
15
|
#
|
16
|
-
# @see
|
16
|
+
# @see https://reference.promisepay.com/#shows-transaction-fees
|
17
17
|
#
|
18
18
|
# @return [Promisepay::Fee]
|
19
19
|
def fee
|
@@ -2,9 +2,22 @@
|
|
2
2
|
module Promisepay
|
3
3
|
# Manage Users
|
4
4
|
class User < BaseModel
|
5
|
+
# Update the attributes of an item.
|
6
|
+
#
|
7
|
+
# @see https://reference.promisepay.com/#update-item
|
8
|
+
#
|
9
|
+
# @param attributes [Hash] Item's attributes to be updated.
|
10
|
+
#
|
11
|
+
# @return [self]
|
12
|
+
def update(attributes)
|
13
|
+
response = JSON.parse(@client.patch("users/#{send(:id)}", attributes).body)
|
14
|
+
@attributes = response['users']
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
5
18
|
# Lists items for a user on a marketplace.
|
6
19
|
#
|
7
|
-
# @see
|
20
|
+
# @see https://reference.promisepay.com/#list-user-items
|
8
21
|
#
|
9
22
|
# @return [Array<Promisepay::Item>]
|
10
23
|
def items
|
@@ -15,7 +28,7 @@ module Promisepay
|
|
15
28
|
|
16
29
|
# Gets Bank account for a user on a marketplace.
|
17
30
|
#
|
18
|
-
# @see
|
31
|
+
# @see https://reference.promisepay.com/#show-user-bank-account
|
19
32
|
#
|
20
33
|
# @return [Promisepay::BankAccount]
|
21
34
|
def bank_account
|
@@ -27,7 +40,7 @@ module Promisepay
|
|
27
40
|
|
28
41
|
# Gets Card account for a user on a marketplace.
|
29
42
|
#
|
30
|
-
# @see
|
43
|
+
# @see https://reference.promisepay.com/#show-user-card-account
|
31
44
|
#
|
32
45
|
# @return [Promisepay::CardAccount]
|
33
46
|
def card_account
|
@@ -39,7 +52,7 @@ module Promisepay
|
|
39
52
|
|
40
53
|
# Gets PayPal account for a user on a marketplace.
|
41
54
|
#
|
42
|
-
# @see
|
55
|
+
# @see https://reference.promisepay.com/#show-user-paypal-account
|
43
56
|
#
|
44
57
|
# @return [Promisepay::PaypalAccount]
|
45
58
|
def paypal_account
|
@@ -51,7 +64,7 @@ module Promisepay
|
|
51
64
|
|
52
65
|
# Set the disbursement account for a user.
|
53
66
|
#
|
54
|
-
# @see
|
67
|
+
# @see https://reference.promisepay.com/#set-user-disbursement-account
|
55
68
|
#
|
56
69
|
# @return [Boolean]
|
57
70
|
def disbursement_account(account_id)
|
@@ -59,5 +72,28 @@ module Promisepay
|
|
59
72
|
JSON.parse(@client.post("users/#{send(:id)}/disbursement_account", options).body)
|
60
73
|
true
|
61
74
|
end
|
75
|
+
|
76
|
+
# Gets company for a user on a marketplace.
|
77
|
+
#
|
78
|
+
# @see
|
79
|
+
#
|
80
|
+
# @return [Promisepay::Company]
|
81
|
+
def company
|
82
|
+
response = JSON.parse(@client.get("users/#{send(:id)}/companies").body)
|
83
|
+
Promisepay::Company.new(@client, response['companies'])
|
84
|
+
rescue Promisepay::NotFound
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
|
88
|
+
# Gets user address.
|
89
|
+
#
|
90
|
+
# @see https://reference.promisepay.com/#addresses
|
91
|
+
#
|
92
|
+
# @return [Hash]
|
93
|
+
def address
|
94
|
+
return nil unless @attributes.key?('related')
|
95
|
+
response = JSON.parse(@client.get("addresses/#{send(:related)['addresses']}").body)
|
96
|
+
response['addresses']
|
97
|
+
end
|
62
98
|
end
|
63
99
|
end
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# Get bank account for a user on a marketplace.
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#show-bank-account
|
11
11
|
#
|
12
12
|
# @param id [String] Bank Account ID.
|
13
13
|
#
|
@@ -19,7 +19,7 @@ module Promisepay
|
|
19
19
|
|
20
20
|
# Create a bank account for a user on a marketplace.
|
21
21
|
#
|
22
|
-
# @see
|
22
|
+
# @see https://reference.promisepay.com/#create-bank-account
|
23
23
|
#
|
24
24
|
# @param attributes [Hash] Bank Account's attributes.
|
25
25
|
#
|
@@ -28,5 +28,19 @@ module Promisepay
|
|
28
28
|
response = JSON.parse(@client.post('bank_accounts', attributes).body)
|
29
29
|
Promisepay::BankAccount.new(@client, response['bank_accounts'])
|
30
30
|
end
|
31
|
+
|
32
|
+
# Validate a US bank routing number before creating an account.
|
33
|
+
# This can be used to provide on-demand verification,
|
34
|
+
# and further information of the bank information a User is providing.
|
35
|
+
#
|
36
|
+
# @see https://reference.promisepay.com/#validate-routing-number
|
37
|
+
#
|
38
|
+
# @param routing_number [String] Bank account Routing Number
|
39
|
+
#
|
40
|
+
# @return [Hash]
|
41
|
+
def validate(routing_number)
|
42
|
+
response = @client.get('tools/routing_number', { routing_number: routing_number }, true)
|
43
|
+
(response.status == 200) ? JSON.parse(response.body)['routing_number'] : {}
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# Get card account for a user on a marketplace.
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#show-card-account
|
11
11
|
#
|
12
12
|
# @param id [String] Bank Account ID.
|
13
13
|
#
|
@@ -19,7 +19,7 @@ module Promisepay
|
|
19
19
|
|
20
20
|
# Create a card account for a user on a marketplace.
|
21
21
|
#
|
22
|
-
# @see
|
22
|
+
# @see https://reference.promisepay.com/#create-card-account
|
23
23
|
#
|
24
24
|
# @param attributes [Hash] Bank Account's attributes.
|
25
25
|
#
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Promisepay
|
2
|
+
# Resource for the Fees API
|
3
|
+
class CompanyResource < BaseResource
|
4
|
+
def model
|
5
|
+
Promisepay::Company
|
6
|
+
end
|
7
|
+
|
8
|
+
# List all companies for a marketplace
|
9
|
+
#
|
10
|
+
# @see https://reference.promisepay.com/#list-companies
|
11
|
+
#
|
12
|
+
# @param options [Hash] Optional options.
|
13
|
+
# @option options [Integer] :limit Can ask for up to 200 users. default: 10
|
14
|
+
# @option options [Integer] :offset Pagination help. default: 0
|
15
|
+
#
|
16
|
+
# @return [Array<Promisepay::Company>] List all companies for a marketplace.
|
17
|
+
def find_all(options = {})
|
18
|
+
response = JSON.parse(@client.get('companies', options).body)
|
19
|
+
users = response.key?('companies') ? response['companies'] : []
|
20
|
+
users.map { |attributes| Promisepay::Company.new(@client, attributes) }
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a company
|
24
|
+
#
|
25
|
+
# @see https://reference.promisepay.com/#show-company
|
26
|
+
#
|
27
|
+
# @param id [String] Company id
|
28
|
+
#
|
29
|
+
# @return [Promisepay::Company]
|
30
|
+
def find(id)
|
31
|
+
response = JSON.parse(@client.get("companies/#{id}").body)
|
32
|
+
Promisepay::Company.new(@client, response['companies'])
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create a company for a user
|
36
|
+
#
|
37
|
+
# @see https://reference.promisepay.com/#create-company
|
38
|
+
#
|
39
|
+
# @param attributes [Hash] Company's attributes.
|
40
|
+
#
|
41
|
+
# @return [Promisepay::Company]
|
42
|
+
def create(attributes)
|
43
|
+
response = JSON.parse(@client.post('companies', attributes).body)
|
44
|
+
Promisepay::Company.new(@client, response['companies'])
|
45
|
+
end
|
46
|
+
|
47
|
+
# Update a company for a user
|
48
|
+
#
|
49
|
+
# @see https://reference.promisepay.com/#update-company
|
50
|
+
#
|
51
|
+
# @param attributes [Hash] Company's attributes.
|
52
|
+
#
|
53
|
+
# @return [Promisepay::Company]
|
54
|
+
def update(attributes)
|
55
|
+
response = JSON.parse(@client.patch('companies', attributes).body)
|
56
|
+
Promisepay::Company.new(@client, response['companies'])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# List all fees for a marketplace
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#list-fees
|
11
11
|
#
|
12
12
|
# @param options [Hash] Optional options.
|
13
13
|
# @option options [Integer] :limit Can ask for up to 200 fees. default: 10
|
@@ -22,7 +22,7 @@ module Promisepay
|
|
22
22
|
|
23
23
|
# Get a single fee for a marketplace
|
24
24
|
#
|
25
|
-
# @see
|
25
|
+
# @see https://reference.promisepay.com/#show-fee
|
26
26
|
#
|
27
27
|
# @param id [String] Marketplace Fee ID.
|
28
28
|
#
|
@@ -34,7 +34,7 @@ module Promisepay
|
|
34
34
|
|
35
35
|
# Create a fee for a marketplace
|
36
36
|
#
|
37
|
-
# @see
|
37
|
+
# @see https://reference.promisepay.com/#create-fee
|
38
38
|
#
|
39
39
|
# @param attributes [Hash] Item's attributes.
|
40
40
|
#
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# List all items for a marketplace
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#list-items
|
11
11
|
#
|
12
12
|
# @param options [Hash] Optional options.
|
13
13
|
# @option options [Integer] :limit Can ask for up to 200 items. default: 10
|
@@ -22,7 +22,7 @@ module Promisepay
|
|
22
22
|
|
23
23
|
# Get a single item for a marketplace
|
24
24
|
#
|
25
|
-
# @see
|
25
|
+
# @see https://reference.promisepay.com/#show-item
|
26
26
|
#
|
27
27
|
# @param id [String] Marketplace item ID.
|
28
28
|
#
|
@@ -40,7 +40,7 @@ module Promisepay
|
|
40
40
|
|
41
41
|
# Create an item for a marketplace
|
42
42
|
#
|
43
|
-
# @see
|
43
|
+
# @see https://reference.promisepay.com/#create-item
|
44
44
|
#
|
45
45
|
# @param attributes [Hash] Item's attributes.
|
46
46
|
#
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# Get paypal account for a user on a marketplace.
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#show-paypal-account
|
11
11
|
#
|
12
12
|
# @param id [String] Paypal Account ID.
|
13
13
|
#
|
@@ -19,7 +19,7 @@ module Promisepay
|
|
19
19
|
|
20
20
|
# Create a Paypal account for a user on a marketplace.
|
21
21
|
#
|
22
|
-
# @see
|
22
|
+
# @see https://reference.promisepay.com/#create-paypal-account
|
23
23
|
#
|
24
24
|
# @param attributes [Hash] Paypal Account's attributes.
|
25
25
|
#
|
@@ -3,19 +3,31 @@ module Promisepay
|
|
3
3
|
class TokenResource < BaseResource
|
4
4
|
# Create a new token for an item
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://reference.promisepay.com/#generate-card-token
|
7
7
|
#
|
8
8
|
# @param attributes [Hash] Token's attributes.
|
9
9
|
#
|
10
10
|
# @return [Hash]
|
11
11
|
def create(type = :session, attributes)
|
12
12
|
case type
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
when :session
|
14
|
+
if attributes && attributes[:fee_ids] && attributes[:fee_ids].is_a?(Array)
|
15
|
+
attributes[:fee_ids] = attributes[:fee_ids].join(',')
|
16
|
+
end
|
17
|
+
response = @client.get('request_session_token', attributes)
|
18
|
+
JSON.parse(response.body)
|
19
|
+
when :eui
|
20
|
+
attributes[:token_type] = 'eui'
|
21
|
+
response = @client.post('token_auths/', attributes)
|
22
|
+
JSON.parse(response.body)
|
23
|
+
when :card
|
24
|
+
attributes[:token_type] = 'card'
|
25
|
+
response = @client.post('token_auths/', attributes)
|
26
|
+
JSON.parse(response.body)
|
27
|
+
when :approve
|
28
|
+
attributes[:token_type] = '4'
|
29
|
+
response = @client.post('token_auths/', attributes)
|
30
|
+
JSON.parse(response.body)
|
19
31
|
end
|
20
32
|
end
|
21
33
|
end
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# List all transactions for a marketplace
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#list-transactions
|
11
11
|
#
|
12
12
|
# @param options [Hash] Optional options.
|
13
13
|
# @option options [Integer] :limit Can ask for up to 200 transactions. default: 10
|
@@ -22,7 +22,7 @@ module Promisepay
|
|
22
22
|
|
23
23
|
# Get a single transaction for a marketplace
|
24
24
|
#
|
25
|
-
# @see
|
25
|
+
# @see https://reference.promisepay.com/#show-transaction
|
26
26
|
#
|
27
27
|
# @param id [String] transaction ID.
|
28
28
|
#
|
@@ -7,7 +7,7 @@ module Promisepay
|
|
7
7
|
|
8
8
|
# List all users for a marketplace
|
9
9
|
#
|
10
|
-
# @see
|
10
|
+
# @see https://reference.promisepay.com/#list-users
|
11
11
|
#
|
12
12
|
# @param options [Hash] Optional options.
|
13
13
|
# @option options [Integer] :limit Can ask for up to 200 users. default: 10
|
@@ -22,7 +22,7 @@ module Promisepay
|
|
22
22
|
|
23
23
|
# Get a single user
|
24
24
|
#
|
25
|
-
# @see
|
25
|
+
# @see https://reference.promisepay.com/#show-user
|
26
26
|
#
|
27
27
|
# @param id [String] Marketplace user ID.
|
28
28
|
#
|
@@ -34,7 +34,7 @@ module Promisepay
|
|
34
34
|
|
35
35
|
# Create a new user for a marketplace
|
36
36
|
#
|
37
|
-
# @see
|
37
|
+
# @see https://reference.promisepay.com/#create-user
|
38
38
|
#
|
39
39
|
# @param attributes [Hash] User's attributes.
|
40
40
|
#
|
@@ -46,7 +46,7 @@ module Promisepay
|
|
46
46
|
|
47
47
|
# Update a user for a marketplace
|
48
48
|
#
|
49
|
-
# @see
|
49
|
+
# @see https://reference.promisepay.com/#update-user
|
50
50
|
#
|
51
51
|
# @param attributes [Hash] User's attributes.
|
52
52
|
#
|
data/lib/promisepay/version.rb
CHANGED
data/promisepay.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'promisepay/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'promisepay'
|
8
|
-
spec.version =
|
8
|
+
spec.version = '0.0.6'
|
9
9
|
spec.authors = ['Romain Vigo Benia']
|
10
10
|
spec.email = ['romain.vigobenia@gmail.com']
|
11
11
|
spec.summary = 'Gem to wrap promisepay.com API.'
|
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: 0.0.
|
4
|
+
version: 0.0.6
|
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:
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/promisepay/models/bank_account.rb
|
86
86
|
- lib/promisepay/models/base_model.rb
|
87
87
|
- lib/promisepay/models/card_account.rb
|
88
|
+
- lib/promisepay/models/company.rb
|
88
89
|
- lib/promisepay/models/fee.rb
|
89
90
|
- lib/promisepay/models/item.rb
|
90
91
|
- lib/promisepay/models/paypal_account.rb
|
@@ -94,6 +95,7 @@ files:
|
|
94
95
|
- lib/promisepay/resources/bank_account_resource.rb
|
95
96
|
- lib/promisepay/resources/base_resource.rb
|
96
97
|
- lib/promisepay/resources/card_account_resource.rb
|
98
|
+
- lib/promisepay/resources/company_resource.rb
|
97
99
|
- lib/promisepay/resources/fee_resource.rb
|
98
100
|
- lib/promisepay/resources/item_resource.rb
|
99
101
|
- lib/promisepay/resources/paypal_account_resource.rb
|
@@ -122,9 +124,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
124
|
version: '0'
|
123
125
|
requirements: []
|
124
126
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.1
|
126
128
|
signing_key:
|
127
129
|
specification_version: 4
|
128
130
|
summary: Gem to wrap promisepay.com API.
|
129
131
|
test_files: []
|
130
|
-
has_rdoc:
|