pin-ruby 0.0.3 → 0.0.4

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: 356743431583ed5f8d65d66afc14b86284e78673
4
- data.tar.gz: fdb3e0727ac8ca496c00046a52a6540c681804d9
3
+ metadata.gz: 01730b41395bb4905a13620dd2e88fa0f1a303f6
4
+ data.tar.gz: 9e61e9bdbc7a6814003645521e28efd4c301c40b
5
5
  SHA512:
6
- metadata.gz: fffa9b5c27e783bac2d2641805c0520dd2849fb701f18a8484b1b3d1163635695d8aa88cbd6f3c56d0bb91c7792de2df5c7692027748357c135a78c60035591e
7
- data.tar.gz: 32125fab08f51c572997cc27c4c3152a1ec1bfc54ce173da8c6ff2e74e9d7cfc998c3ab84c5b50c2398eebeb5c1f5f3799c85c8be49c57433b8733867e21c7ba
6
+ metadata.gz: 643cb647fbaf356ee77ee02794a5e4a4e0c3be65bec0b8ba20b84fc1aa2356e56d706a4aceb9d88f91813594c6cb8216406ff0e2639eb8b67c5a2f3c24de1107
7
+ data.tar.gz: cfe17f44af91a1b1c36462eeff55632eac04c09a8195c153c03d36b4e9732188ff9485ccb2b4de1c47d17d71d62c888a9f2b45092eaa0f77daae8c382b87b0ae
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Pin::Ruby
2
-
3
1
  A Ruby library for interacting with v1 of the [Pin Payments API](https://pin.net.au/docs/api).
4
2
 
5
- ## Installation
3
+ # Installation
6
4
 
7
5
  Add this line to your application's Gemfile:
8
6
 
@@ -45,11 +43,169 @@ When using the Pin library in a non-rails application, you must configure it to
45
43
  config.endpoint = 'api.pin.net.au'
46
44
  end
47
45
 
48
- ## Usage
46
+ # Usage
47
+
48
+ require 'pin/api'
49
+
50
+ client = Pin::API::Client.new()
51
+
52
+ ## Charges
53
+
54
+ ### List Charges
55
+
56
+ Return a paginated list of `Pin::Models::Charge` objects:
57
+
58
+ client.charges()
59
+
60
+ Optionally pass the `page` parameter to specify a different page of results:
61
+
62
+ client.charges(2)
63
+
64
+ Will get the second page of charges.
65
+
66
+ ### Fetch Charge
67
+
68
+ Get a specific customer by their token:
69
+
70
+ client.charge('ch_1234')
71
+
72
+ Returns a `Pin::Models::Charge` object, or raises a `Pin::Error`:
73
+
74
+ HTTP Error 404: not_found
75
+
76
+ ### Search charges
77
+
78
+ Search for charges by description, amount and date, as per [Pin's Documentation](https://pin.net.au/docs/api/charges#search-charges):
79
+
80
+ client.charge_search({:query => 'Test Transaction'})
81
+
82
+ Returns a paginated list of `Pin::Models::Charges`.
83
+
84
+ ### Create Charge
85
+
86
+ Charges a customer or card, and returns the newly created charge object:
87
+
88
+ client.create_charge('me@some.net', 'Test Transaction', '1295', 'AUD', request.remote_ip, 'cus_1234')
89
+
90
+ The last parameter (`token_or_card`) can be either a customer token, a card token or a card hash.
91
+
92
+ Returns a `Pin::Models::Charge` of the charge, or a `Pin::Error`, as per [Pin's Documentation](https://pin.net.au/docs/api/charges#post-charges).
93
+
94
+ ## Customers
95
+
96
+ ### List Customers
97
+
98
+ Return a paginated list of `Pin::Models::Customer` objects:
99
+
100
+ client.customers()
101
+
102
+ Optionally pass the `page` parameter to specify a different page of results:
103
+
104
+ client.customers(2)
105
+
106
+ Will get the second page of customers.
107
+
108
+ ### Fetch customer
109
+
110
+ Get a specific customer by their token:
111
+
112
+ client.customer('cus_1234')
113
+
114
+ Returns a `Pin::Models::Customer` object, or raises a `Pin::Error`:
115
+
116
+ HTTP Error 404: not_found
117
+
118
+ ### Customer's charges
119
+
120
+ Gets a paginated list of charges against a customer:
121
+
122
+ client.customer_charges('cus_1234')
123
+
124
+ Optionally pass a second parameter `page` to specify a different page of results:
125
+
126
+ client.customer_charges('cus_1234', 2)
127
+
128
+ Returns a list of `Pin::Models::Charge` object, or raises a `Pin::Error`:
129
+
130
+ HTTP Error 404: not_found
131
+
132
+ ### Create Customer
133
+
134
+ Create a new customer with either an existing card token, or a hash of card details):
135
+
136
+ client.create_customer('me@some.net', 'card_1234')
137
+
138
+ or
139
+
140
+ client.create_customer('me@some.net', {:number => '5520000000000000', ... })
141
+
142
+ Card hash should be supplied as per [Pin's documentation](https://pin.net.au/docs/api/cards):
143
+
144
+ {
145
+ "token": "card_nytGw7koRg23EEp9NTmz9w",
146
+ "display_number": "XXXX-XXXX-XXXX-0000",
147
+ "scheme": "master",
148
+ "address_line1": "42 Sevenoaks St",
149
+ "address_line2": null,
150
+ "address_city": "Lathlain",
151
+ "address_postcode": "6454",
152
+ "address_state": "WA",
153
+ "address_country": "Australia"
154
+ }
155
+
156
+ Returns the newly created customer as a `Pin::Models::Customer` object.
157
+
158
+ ### Update customer
159
+
160
+ Update's a customer's card and/or email address:
161
+
162
+ client.update_customer('cus_1234', {:email => 'new@some.net', :card => {:number => '5520000000000000', ... } })
163
+
164
+ Returns the updated customer as a `Pin::Models::Customer` object.
165
+
166
+ ## Refunds
167
+
168
+ ### List Refunds
169
+
170
+ Return a paginated list of `Pin::Models::Refund` objects for the specified charge token:
171
+
172
+ client.refunds('ch_1234')
173
+
174
+ Optionally pass the `page` parameter to specify a different page of results:
175
+
176
+ client.refunds('ch_1234', 2)
177
+
178
+ Will get the second page of refunds for the specified charge.
179
+
180
+ ### Refund a charge
181
+
182
+ Refunds the specified amount against an existing charge, and returns the refund object created, or a `Pin::Error`:
183
+
184
+ client.create_refund('ch_1234')
185
+
186
+ By default `create_refund` refunds the full amount of the original charge. To specify a different amount, pass the amount as cents to the optional second parameter:
187
+
188
+ client.create_refund('ch_1234', '1000')
189
+
190
+ Returns the refund object created, or a `Pin::Error`.
191
+
192
+ ## Tokens
193
+
194
+ ### Create a token for a card
195
+
196
+ Takes a card and stores it returning a reusable token for charges.
197
+
198
+ client.create_token('5520000000000000', '01', '2015', '123', 'John Appleseed', {
199
+ :line1 => '1 Main Street',
200
+ :city => 'Melbourne',
201
+ :postcode => '3000',
202
+ :state => 'Victoria',
203
+ :country => 'Australia'
204
+ })
49
205
 
50
- TODO: Write usage instructions here
206
+ Returns a `Pin::Models::Card` containing the non-sensitive card details.
51
207
 
52
- ## Contributing
208
+ # Contributing
53
209
 
54
210
  1. Fork it
55
211
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -11,8 +11,8 @@ module Pin::API::Customers
11
11
  pin_response(raw_response, Pin::Models::Customer.new(raw_response['response']))
12
12
  end
13
13
 
14
- def customer_charges(token)
15
- raw_response = api_call(:get, "customers/#{token}/charges")
14
+ def customer_charges(token, page=1)
15
+ raw_response = api_call(:get, "customers/#{token}/charges", {:page => page})
16
16
 
17
17
  pin_response(raw_response, raw_response['response'].map { |e| Pin::Models::Charge.new(e) })
18
18
  end
@@ -1,7 +1,7 @@
1
1
  module Pin::API::Refunds
2
2
 
3
- def refunds(charge_token, params={})
4
- raw_response = api_call(:get, "charges/#{charge_token}/refunds", params)
3
+ def refunds(charge_token, page=1)
4
+ raw_response = api_call(:get, "charges/#{charge_token}/refunds", {:page => page})
5
5
 
6
6
  pin_response(raw_response, raw_response['response'].map { |e| Pin::Models::Refund.new(e) })
7
7
  end
@@ -34,6 +34,6 @@ module Pin::API::Tokens
34
34
  end
35
35
 
36
36
  raw_response = api_call(:post, 'cards', params)
37
- pin_response(raw_response, Pin::Models::Charge.new(raw_response['response']))
37
+ pin_response(raw_response, Pin::Models::Card.new(raw_response['response']))
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Pin
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pin-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Shimmins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-07 00:00:00.000000000 Z
11
+ date: 2013-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json