promisepay 0.0.4 → 0.0.5
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/LICENSE.txt +22 -22
- data/README.md +378 -163
- data/Rakefile +1 -1
- data/lib/promisepay.rb +13 -13
- data/lib/promisepay/client.rb +146 -147
- data/lib/promisepay/configurable.rb +49 -49
- data/lib/promisepay/default.rb +47 -47
- data/lib/promisepay/error.rb +92 -92
- data/lib/promisepay/models/account.rb +5 -5
- data/lib/promisepay/models/bank_account.rb +28 -28
- data/lib/promisepay/models/base_model.rb +23 -23
- data/lib/promisepay/models/card_account.rb +26 -26
- data/lib/promisepay/models/fee.rb +5 -5
- data/lib/promisepay/models/item.rb +197 -197
- data/lib/promisepay/models/paypal_account.rb +26 -26
- data/lib/promisepay/models/transaction.rb +24 -24
- data/lib/promisepay/models/user.rb +63 -63
- data/lib/promisepay/resources/account_resource.rb +5 -5
- data/lib/promisepay/resources/bank_account_resource.rb +32 -32
- data/lib/promisepay/resources/base_resource.rb +20 -20
- data/lib/promisepay/resources/card_account_resource.rb +32 -32
- data/lib/promisepay/resources/fee_resource.rb +47 -47
- data/lib/promisepay/resources/item_resource.rb +53 -53
- data/lib/promisepay/resources/paypal_account_resource.rb +32 -32
- data/lib/promisepay/resources/token_resource.rb +22 -28
- data/lib/promisepay/resources/transaction_resource.rb +35 -35
- data/lib/promisepay/resources/user_resource.rb +59 -59
- data/lib/promisepay/version.rb +4 -4
- data/promisepay.gemspec +27 -27
- metadata +13 -14
- data/lib/promisepay/models/token.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81abebc5923d9af216511284d1940b4856ec1ff5
|
4
|
+
data.tar.gz: 048efbbeb3acb567028438500473b64c277850e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d25d958566d6a19773f0b76b7c4b05dd4d2657a981810577bf367cb09ab1573f6082962bd1fd8d86f87997366a0592514ad53f498dbb6b66254e810d89a5de
|
7
|
+
data.tar.gz: 6bee0b0b9e0a808abc3089eb4884c59999da7fb72c078be950d69d79e2bf8a89b72845807d14a77ce416d3fe439f84ac543691f91173827ce2a3dd7d79b44f93
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2015 Romain Vigo Benia
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2015 Romain Vigo Benia
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,163 +1,378 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
[](https://gitter.im/PromisePay/promisepay-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
+
|
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
|
+
[](https://codeclimate.com/github/PromisePay/promisepay-ruby)
|
9
|
+
|
10
|
+
#1. Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'promisepay'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install promisepay
|
25
|
+
|
26
|
+
#2. Configuration
|
27
|
+
|
28
|
+
Before interacting with Promispay API you need to generate an access token.
|
29
|
+
|
30
|
+
See http://docs.promisepay.com/v2.2/docs/request_token for more information.
|
31
|
+
|
32
|
+
**Create a PromisePay client**
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'promisepay'
|
36
|
+
|
37
|
+
client = Promisepay::Client.new(username: 'YOUR_USERNAME', token: 'YOUR_TOKEN')
|
38
|
+
```
|
39
|
+
|
40
|
+
The client can be configured through environment variables.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
ENV['PROMISEPAY_USERNAME'] = 'YOUR_USERNAME'
|
44
|
+
ENV['PROMISEPAY_TOKEN'] = 'YOUR_TOKEN'
|
45
|
+
```
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'promisepay'
|
49
|
+
|
50
|
+
client = Promisepay::Client.new()
|
51
|
+
```
|
52
|
+
|
53
|
+
The following parameters are configurable through the client:
|
54
|
+
|
55
|
+
* `:username` / `ENV['PROMISEPAY_USERNAME']`: username for [basic authentication](http://docs.promisepay.com/v2.2/docs/overview-2)
|
56
|
+
* `:token` / `ENV['PROMISEPAY_TOKEN']`: token for [basic authentication](http://docs.promisepay.com/v2.2/docs/overview-2)
|
57
|
+
* `:environment` / `ENV['PROMISEPAY_ENVIRONMENT']`: API [environment](http://docs.promisepay.com/v2.2/docs/environments) to use (default: 'test')
|
58
|
+
* `:api_domain` / `ENV['PROMISEPAY_API_DOMAIN']`: API domain name to use (default: 'api.promisepay.com')
|
59
|
+
|
60
|
+
#3. Examples
|
61
|
+
|
62
|
+
##Tokens
|
63
|
+
##### 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.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
token_request = client.tokens.create(:session, {
|
68
|
+
current_user: 'seller',
|
69
|
+
item_name: 'Test Item',
|
70
|
+
amount: '2500',
|
71
|
+
seller_lastname: 'Seller',
|
72
|
+
seller_firstname: 'Sally',
|
73
|
+
buyer_lastname: 'Buyer',
|
74
|
+
buyer_firstname: 'Bobby',
|
75
|
+
buyer_country: 'AUS',
|
76
|
+
seller_country: 'USA',
|
77
|
+
seller_email: 'sally.seller@promisepay.com',
|
78
|
+
buyer_email: 'bobby.buyer@promisepay.com',
|
79
|
+
fee_ids: [],
|
80
|
+
payment_type_id: 2
|
81
|
+
})
|
82
|
+
token = token_request['token']
|
83
|
+
item_id = token_request['item']
|
84
|
+
buyer_id = token_request['buyer']
|
85
|
+
seller_id = token_request['seller']
|
86
|
+
```
|
87
|
+
#####Example 2 - Request session token
|
88
|
+
The below example shows the request for a marketplace that passes the Item and User IDs.
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
token = client.tokens.create(:session, {
|
92
|
+
current_user_id: 'seller1234',
|
93
|
+
item_name: 'Test Item',
|
94
|
+
amount: '2500',
|
95
|
+
seller_lastname: 'Seller',
|
96
|
+
seller_firstname: 'Sally',
|
97
|
+
buyer_lastname: 'Buyer',
|
98
|
+
buyer_firstname: 'Bobby',
|
99
|
+
buyer_country: 'AUS',
|
100
|
+
seller_country: 'USA',
|
101
|
+
seller_email: 'sally.seller@promisepay.com',
|
102
|
+
buyer_email: 'bobby.buyer@promisepay.com',
|
103
|
+
external_item_id: 'TestItemId1234',
|
104
|
+
external_seller_id: 'seller1234',
|
105
|
+
external_buyer_id: 'buyer1234',
|
106
|
+
fee_ids: [],
|
107
|
+
payment_type_id: 2
|
108
|
+
})['token']
|
109
|
+
```
|
110
|
+
##Items
|
111
|
+
|
112
|
+
#####Create an item
|
113
|
+
```ruby
|
114
|
+
item = client.items.create(
|
115
|
+
id: '12345',
|
116
|
+
name: 'test item for 5AUD',
|
117
|
+
amount: '500',
|
118
|
+
payement_type: '1',
|
119
|
+
buyer_id: buyer.id,
|
120
|
+
seller_id: seller.id,
|
121
|
+
fee_id: fee.id,
|
122
|
+
description: '5AUD transfer'
|
123
|
+
)
|
124
|
+
```
|
125
|
+
#####Get an item
|
126
|
+
```ruby
|
127
|
+
item = client.items.find('1')
|
128
|
+
```
|
129
|
+
#####Get a list of items
|
130
|
+
```ruby
|
131
|
+
items = client.items.find_all
|
132
|
+
```
|
133
|
+
#####Update an item
|
134
|
+
```ruby
|
135
|
+
item.update(name: 'new name')
|
136
|
+
```
|
137
|
+
#####Cancel an item
|
138
|
+
```ruby
|
139
|
+
item.cancel
|
140
|
+
```
|
141
|
+
#####Get an item status
|
142
|
+
```ruby
|
143
|
+
item.status
|
144
|
+
```
|
145
|
+
#####Get an item's buyer
|
146
|
+
```ruby
|
147
|
+
item.buyer
|
148
|
+
```
|
149
|
+
#####Get an item's seller
|
150
|
+
```ruby
|
151
|
+
item.seller
|
152
|
+
```
|
153
|
+
#####Get an item's fees
|
154
|
+
```ruby
|
155
|
+
item.fees
|
156
|
+
```
|
157
|
+
#####Get an item's transactions
|
158
|
+
```ruby
|
159
|
+
item.transaction
|
160
|
+
```
|
161
|
+
#####Get an item's wire details
|
162
|
+
```ruby
|
163
|
+
item.wire_details
|
164
|
+
```
|
165
|
+
#####Get an item's BPAY details
|
166
|
+
```ruby
|
167
|
+
item.bpay_details
|
168
|
+
```
|
169
|
+
|
170
|
+
##Users
|
171
|
+
|
172
|
+
#####Create a user
|
173
|
+
```ruby
|
174
|
+
user = client.users.create(
|
175
|
+
id: '123456',
|
176
|
+
first_name: 'test',
|
177
|
+
last_name: 'buyer',
|
178
|
+
email: 'buyer@test.com',
|
179
|
+
address_line1: '48 collingwood',
|
180
|
+
state: 'vic',
|
181
|
+
city: 'Mel',
|
182
|
+
zip: '3000',
|
183
|
+
country: 'AUS'
|
184
|
+
)
|
185
|
+
```
|
186
|
+
#####Get a user
|
187
|
+
```ruby
|
188
|
+
user = client.users.find('1')
|
189
|
+
```
|
190
|
+
#####Get a list of users
|
191
|
+
```ruby
|
192
|
+
users = client.users.find_all
|
193
|
+
```
|
194
|
+
#####Get a user's card accounts
|
195
|
+
```ruby
|
196
|
+
user.card_account
|
197
|
+
```
|
198
|
+
#####Get a user's PayPal accounts
|
199
|
+
```ruby
|
200
|
+
user.paypal_account
|
201
|
+
```
|
202
|
+
#####Get a user's bank accounts
|
203
|
+
```ruby
|
204
|
+
user.bank_account
|
205
|
+
```
|
206
|
+
#####Get a user's items
|
207
|
+
```ruby
|
208
|
+
user.items
|
209
|
+
```
|
210
|
+
#####Set a user's disbursement account
|
211
|
+
```ruby
|
212
|
+
user.disbursement_account(bank_account.id)
|
213
|
+
```
|
214
|
+
##Item Actions
|
215
|
+
#####Make payment
|
216
|
+
```ruby
|
217
|
+
item.make_payment(
|
218
|
+
account_id: buyer_card_account.id
|
219
|
+
)
|
220
|
+
```
|
221
|
+
#####Request payment
|
222
|
+
```ruby
|
223
|
+
item.request_payement
|
224
|
+
```
|
225
|
+
#####Release payment
|
226
|
+
```ruby
|
227
|
+
item.release_payment
|
228
|
+
```
|
229
|
+
#####Request release
|
230
|
+
```ruby
|
231
|
+
item.request_release
|
232
|
+
```
|
233
|
+
#####Cancel
|
234
|
+
```ruby
|
235
|
+
item.cancel
|
236
|
+
```
|
237
|
+
#####Acknowledge wire
|
238
|
+
```ruby
|
239
|
+
item.acknowledge_wire
|
240
|
+
```
|
241
|
+
#####Acknowledge PayPal
|
242
|
+
```ruby
|
243
|
+
item.acknowledge_paypal
|
244
|
+
```
|
245
|
+
#####Revert wire
|
246
|
+
```ruby
|
247
|
+
item.revert_wire
|
248
|
+
```
|
249
|
+
#####Request refund
|
250
|
+
```ruby
|
251
|
+
item.release_payment
|
252
|
+
```
|
253
|
+
#####Refund
|
254
|
+
```ruby
|
255
|
+
item.request_refund(
|
256
|
+
refund_amount: '1000',
|
257
|
+
refund_message: 'because'
|
258
|
+
)
|
259
|
+
```
|
260
|
+
##Card Accounts
|
261
|
+
#####Create a card account
|
262
|
+
```ruby
|
263
|
+
card_account = client.card_accounts.create(
|
264
|
+
user_id: buyer.id,
|
265
|
+
full_name: 'test Buyer',
|
266
|
+
number: '4111 1111 1111 1111',
|
267
|
+
expiry_month: Time.now.month,
|
268
|
+
expiry_year: Time.now.year + 1,
|
269
|
+
cvv: '123'
|
270
|
+
)
|
271
|
+
```
|
272
|
+
#####Get a card account
|
273
|
+
```ruby
|
274
|
+
card_account = client.card_accounts.find('1')
|
275
|
+
```
|
276
|
+
#####Deactivate a card account
|
277
|
+
```ruby
|
278
|
+
card_account.deactivate
|
279
|
+
```
|
280
|
+
#####Get a card account's users
|
281
|
+
```ruby
|
282
|
+
card_account.user
|
283
|
+
```
|
284
|
+
|
285
|
+
##Bank Accounts
|
286
|
+
#####Create a bank account
|
287
|
+
```ruby
|
288
|
+
bank_account = client.bank_accounts.create(
|
289
|
+
user_id: seller.id,
|
290
|
+
bank_name: 'Nab',
|
291
|
+
account_name: 'test seller',
|
292
|
+
routing_number: '22222222',
|
293
|
+
account_number: '1234567890',
|
294
|
+
account_type: 'savings',
|
295
|
+
holder_type: 'personal',
|
296
|
+
country: 'AUS'
|
297
|
+
)
|
298
|
+
```
|
299
|
+
#####Get a bank account
|
300
|
+
```ruby
|
301
|
+
bank_account = client.bank_accounts.find('1')
|
302
|
+
```
|
303
|
+
#####Deactivate a bank account
|
304
|
+
```ruby
|
305
|
+
bank_account.deactivate('mobile_pin')
|
306
|
+
```
|
307
|
+
#####Get a bank account's users
|
308
|
+
```ruby
|
309
|
+
bank_account.user
|
310
|
+
```
|
311
|
+
|
312
|
+
##PayPal Accounts
|
313
|
+
#####Create a PayPal account
|
314
|
+
```ruby
|
315
|
+
paypal_account = client.paypal_accounts.create(
|
316
|
+
user_id: seller.id,
|
317
|
+
paypal_email: 'seller@promisepay.com'
|
318
|
+
)
|
319
|
+
```
|
320
|
+
#####Get a PayPal account
|
321
|
+
```ruby
|
322
|
+
paypal_account = client.paypal_accounts.find('1')
|
323
|
+
```
|
324
|
+
#####Deactivate a PayPal account
|
325
|
+
```ruby
|
326
|
+
paypal_account.deactivate
|
327
|
+
```
|
328
|
+
#####Get a PayPal account's users
|
329
|
+
```ruby
|
330
|
+
paypal_account.user
|
331
|
+
```
|
332
|
+
|
333
|
+
##Fees
|
334
|
+
#####Get a list of fees
|
335
|
+
```ruby
|
336
|
+
fees = client.fees.find_all
|
337
|
+
```
|
338
|
+
#####Get a fee
|
339
|
+
```ruby
|
340
|
+
fees = client.fees.find('1')
|
341
|
+
```
|
342
|
+
#####Create a fee
|
343
|
+
```ruby
|
344
|
+
fee = client.fees.create(
|
345
|
+
name: 'test fee for 5 AUD',
|
346
|
+
fee_type_id: '1',
|
347
|
+
amount: '75',
|
348
|
+
to: 'seller'
|
349
|
+
)
|
350
|
+
```
|
351
|
+
|
352
|
+
##Transactions
|
353
|
+
#####Get a list of transactions
|
354
|
+
```ruby
|
355
|
+
transactions = client.transactions.find_all
|
356
|
+
```
|
357
|
+
#####Get a transaction
|
358
|
+
```ruby
|
359
|
+
transaction = client.transactions.find('1')
|
360
|
+
```
|
361
|
+
#####Get a transaction's users
|
362
|
+
```ruby
|
363
|
+
transaction.users
|
364
|
+
```
|
365
|
+
#####Get a transaction's fees
|
366
|
+
```ruby
|
367
|
+
transaction.fees
|
368
|
+
```
|
369
|
+
|
370
|
+
_Check out the [online documentation](http://promisepay.github.io/promisepay-ruby/) to get a full list of available resources and methods._
|
371
|
+
|
372
|
+
#4. Contributing
|
373
|
+
|
374
|
+
1. Fork it ( https://github.com/PromisePay/promisepay-ruby/fork )
|
375
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
376
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
377
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
378
|
+
5. Create a new Pull Request
|