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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23ea2e12b7d1d4f35d341d41172be42221ee8291
4
- data.tar.gz: 132b72a092ec9ad83e6d5ae6c8b01e156a3410df
3
+ metadata.gz: 81abebc5923d9af216511284d1940b4856ec1ff5
4
+ data.tar.gz: 048efbbeb3acb567028438500473b64c277850e8
5
5
  SHA512:
6
- metadata.gz: f3c30eec78f309ef4750b9f8d719b65e04ddcea609e0b45aed746b1c1065e29806f0087e97ded5740b12915f099eb0b12a218d6801652ddb9095ef60d6be1dab
7
- data.tar.gz: 5ef05d8c96a61ef9452d5d4ad0b62a90912c69a14bd06fb2ea625259f78637a53f98c664905c9a7e2ed2c94990ad41eac48e6f0ddc76b2660adcaf52935b6992
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
- # The PromisePay Ruby Gem
2
- [![Gem Version](https://badge.fury.io/rb/promisepay.svg)](http://badge.fury.io/rb/promisepay)
3
- [![Build Status](https://travis-ci.org/PromisePay/promisepay-ruby.svg?branch=develop)](https://travis-ci.org/PromisePay/promisepay-ruby)
4
- [![Coverage Status](https://coveralls.io/repos/PromisePay/promisepay-ruby/badge.svg?branch=develop)](https://coveralls.io/r/PromisePay/promisepay-ruby?branch=develop)
5
- [![Code Climate](https://codeclimate.com/github/PromisePay/promisepay-ruby/badges/gpa.svg)](https://codeclimate.com/github/PromisePay/promisepay-ruby)
6
-
7
- A Ruby interface to the Promisepay API.
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'promisepay'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install promisepay
24
-
25
- ## Usage
26
-
27
- Before interacting with Promispay API you need to generate an access token.
28
-
29
- See http://docs.promisepay.com/v2.2/docs/request_token for more information.
30
-
31
- ### Client
32
-
33
- Create a client as following:
34
-
35
- ```ruby
36
- require 'promisepay'
37
-
38
- client = Promisepay::Client.new(username: 'YOUR_USERNAME', token: 'YOUR_TOKEN')
39
- ```
40
-
41
- Alternatively Promisepay Gem handles client configuration through environment variables.
42
-
43
- ```ruby
44
- ENV['PROMISEPAY_USERNAME'] = 'YOUR_USERNAME'
45
- ENV['PROMISEPAY_TOKEN'] = 'YOUR_TOKEN'
46
- ```
47
-
48
- ```ruby
49
- require 'promisepay'
50
-
51
- client = Promisepay::Client.new()
52
- ```
53
-
54
- _All configurable parameters are available in the Client Configuration section of this README._
55
-
56
- ### Calls
57
-
58
- The example below is translating [use case #1](http://docs.promisepay.com/v2.2/docs/charge-a-buyer-hold-funds-in-escrow-then-release-t) available on Promispay online documentation.
59
-
60
- ```ruby
61
- # 1- Create buyer
62
- buyer = client.users.create(
63
- id: '123456',
64
- first_name: 'test',
65
- last_name: 'buyer',
66
- email: 'buyer@test.com',
67
- address_line1: '48 collingwood',
68
- state: 'vic',
69
- city: 'Mel',
70
- zip: '3000',
71
- country: 'AUS'
72
- )
73
-
74
- # 2- Create buyer's card account
75
- buyer_card_account = client.card_accounts.create(
76
- user_id: buyer.id,
77
- full_name: 'test Buyer',
78
- number: '4111 1111 1111 1111',
79
- expiry_month: Time.now.month,
80
- expiry_year: Time.now.year + 1,
81
- cvv: '123'
82
- )
83
-
84
- # 3- Create seller
85
- seller = client.users.create(
86
- id: '123457',
87
- first_name: 'test',
88
- last_name: 'seller',
89
- email: 'seller@test.com',
90
- mobile: '+61416452321',
91
- address_line1: 'abc',
92
- state: 'vic',
93
- city: 'Mel',
94
- zip: '3000',
95
- country: 'AUS'
96
- )
97
-
98
- # 4- Create seller's bank account
99
- seller_bank_account = client.bank_accounts.create(
100
- user_id: seller.id,
101
- bank_name: 'Nab',
102
- account_name: 'test seller',
103
- routing_number: '22222222',
104
- account_number: '1234567890',
105
- account_type: 'savings',
106
- holder_type: 'personal',
107
- country: 'AUS'
108
- )
109
-
110
- # 5. Create seller's disbursement account
111
- seller.disbursement_account(seller_bank_account.id)
112
-
113
- # 6. Create fee
114
- fee = client.fees.create(
115
- name: 'test fee for 5 AUD',
116
- fee_type_id: '1',
117
- amount: '75',
118
- to: 'seller'
119
- )
120
-
121
- # 7. Create item and link buyer, seller and fee to it
122
- item = client.items.create(
123
- id: '12345',
124
- name: 'test item for 5AUD',
125
- amount: '500',
126
- payement_type: '1',
127
- buyer_id: buyer.id,
128
- seller_id: seller.id,
129
- fee_id: fee.id,
130
- description: '5AUD transfer'
131
- )
132
-
133
- # 8. Pay for item using the buyer's CC account
134
- item.make_payment(
135
- user_id: buyer.id,
136
- account_id: buyer_card_account.id
137
- )
138
-
139
- # 9. Buyer releases payment
140
- item.release_payment(user_id: buyer.id)
141
-
142
- # 10. Check payment status at any time (optional)
143
- item.status
144
- ```
145
-
146
- _Check out the [online documentation](http://promisepay.github.io/promisepay-ruby/) to get a list of available resources and methods._
147
-
148
- ## Client Configuration
149
-
150
- The following parameters are configurable through the client:
151
-
152
- * `:username` / `ENV['PROMISEPAY_USERNAME']`: username for [basic authentication](http://docs.promisepay.com/v2.2/docs/overview-2)
153
- * `:token` / `ENV['PROMISEPAY_TOKEN']`: token for [basic authentication](http://docs.promisepay.com/v2.2/docs/overview-2)
154
- * `:environment` / `ENV['PROMISEPAY_ENVIRONMENT']`: API [environment](http://docs.promisepay.com/v2.2/docs/environments) to use (default: 'test')
155
- * `:api_domain` / `ENV['PROMISEPAY_API_DOMAIN']`: API domain name to use (default: 'api.promisepay.com')
156
-
157
- ## Contributing
158
-
159
- 1. Fork it ( https://github.com/PromisePay/promisepay-ruby/fork )
160
- 2. Create your feature branch (`git checkout -b my-new-feature`)
161
- 3. Commit your changes (`git commit -am 'Add some feature'`)
162
- 4. Push to the branch (`git push origin my-new-feature`)
163
- 5. Create a new Pull Request
1
+ # Ruby SDK - PromisePay API
2
+
3
+ [![Join the chat at https://gitter.im/PromisePay/promisepay-ruby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/PromisePay/promisepay-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/promisepay.svg)](http://badge.fury.io/rb/promisepay)
6
+ [![Build Status](https://travis-ci.org/PromisePay/promisepay-ruby.svg?branch=develop)](https://travis-ci.org/PromisePay/promisepay-ruby)
7
+ [![Coverage Status](https://coveralls.io/repos/PromisePay/promisepay-ruby/badge.svg?branch=develop)](https://coveralls.io/r/PromisePay/promisepay-ruby?branch=develop)
8
+ [![Code Climate](https://codeclimate.com/github/PromisePay/promisepay-ruby/badges/gpa.svg)](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