pr-pin 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 351423e96e140be0cfc71d237c63843bb817c7c18412b61cef905dca087a6c81
4
- data.tar.gz: 3dd044b2514e87abc637f079800422d553a393e491b0b7455270e723259f6869
3
+ metadata.gz: e52cacf6c475aff3f5bce1ae540a40311d62907bb7384b797a63daa8e064434d
4
+ data.tar.gz: 8f45f062ed9148fb0a8c3e85b6d8ce3b3176193404b2479d4fc3404421457b48
5
5
  SHA512:
6
- metadata.gz: e959f6b6d6d2999789fec7333556dea26f4ee37e90177e00c003804bcc88b21e771b408703468e4a692d4cf38281418181070574aeda4b3b649a719e5d2e0292
7
- data.tar.gz: b49f72a07fe9bcd745f427ea44883c349b931f9bd8c5d155361ce6234e59ae73fedd4363a71e757c361d27169c5655335c77b4a7c50e1e90507e28ebddf0bef5
6
+ metadata.gz: 7647fc611ae51dd161fa406344f7fed7dca217aba9779e01ef06287f556a1f9ac2a29a5163183bd8dd8421c471ee06f123e1fe3121b8aec3b49061e8b88c72a2
7
+ data.tar.gz: b6a18bd913ec606128be3a7db21dddc3a42d62bd4cc24cfaec6a2158670811bb4d27eb2955353ea09b026a64f7e0afe04a64eb1243825cc77446d1a597571bee
data/README.md CHANGED
@@ -18,16 +18,41 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### Registering Connections
21
22
  ```ruby
22
23
  # Require the gem
23
24
  require 'pr-pin'
24
25
 
25
- # Connect using your Pin Payments secret key
26
- PR::Pin.connect(
26
+ # Register a connection using your Pin Payments secret key
27
+ PR::Pin.register_connection(
27
28
  secret_key: 'your_secret_key',
29
+ # raise on error, defaults to returning PR::Pin::API::Error instance
30
+ error_handler: ->(exception) { raise(exception) },
28
31
  sandbox: true # Defaults to true, false for production
29
32
  )
30
33
 
34
+ # You can register another connection by passsing an identifier to
35
+ # PR::Pin.register_connection, i.e.
36
+ PR::Pin.register_connection(
37
+ :admin, # defaults to :default
38
+ secret_key: 'your_secret_key',
39
+ sandbox: true
40
+ )
41
+
42
+ # Then, you can specify the connection to use when resolving the
43
+ # endpoint repository from the PR::Pin container
44
+ customers = PR::Pin.customers(:admin).list(page: 1)
45
+ # => [#<PR::Pin::Struct::Customer>, ...]
46
+ customers.current_page # => 1
47
+ customers.per_page # => 25
48
+ customers.prev_page # => nil
49
+ customers.next_page # => 2
50
+ customers.total_count # => 53
51
+ customers.total_pages # => 3
52
+ ```
53
+
54
+ ### One-off charge
55
+ ```ruby
31
56
  # Create a charge using a token, you can get a card token
32
57
  # using Pin Payments hosted fields, or by creating a card
33
58
  # via the API, this can be used to take a one-off payment
@@ -38,11 +63,13 @@ charge = PR::Pin.charges.create(
38
63
  ip_address: '127.0.0.1',
39
64
  card_token: 'card_58b6c52f131956c4394ba7'
40
65
  )
41
-
42
66
  charge.success? # => true
43
67
  charge.error? # => false
44
68
  charge # => #<PR::Pin::Struct::Charge>
69
+ ```
45
70
 
71
+ ### Recurring payments
72
+ ```ruby
46
73
  # For a subscription, create a customer using a card token
47
74
  customer = PR::Pin.customers.create(
48
75
  email: 'a.user@petrescue.com.au',
@@ -53,7 +80,7 @@ customer.error? # => false
53
80
  customer # => #<PR::Pin::Struct::Customer>
54
81
 
55
82
  # And then attach a subscription using the plan token from
56
- # the plans endpoint (you may need to create the plan first)
83
+ # the plans endpoint (you will need to create the plan first)
57
84
  subscription = PR::Pin.subscriptions.create(
58
85
  plan_token: 'plan_2d16b31863015a57820b70',
59
86
  customer_token: 'cus_9d18a4516a6ae777-NDecB'
@@ -63,6 +90,18 @@ subscription.error? # => false
63
90
  subscription # => #<PR::Pin::Struct::Subscription>
64
91
  ```
65
92
 
93
+ ### Errors - See [PR::Pin::API::Error](https://github.com/PetRescue/pr-pin/blob/master/lib/pr/pin/api/error.rb)
94
+ ```ruby
95
+ charge = PR::Pin.charges.create(
96
+ email: 'a.user@petrescue.com.au'
97
+ )
98
+ charge.success? # => false
99
+ charge.error? # => true
100
+ charge.code # => "invalid_resource"
101
+ charge.description # => "One or more parameters were missing or invalid"
102
+ charge # => => #<PR::Pin::API::Error>
103
+ ```
104
+
66
105
  ## API Coverage
67
106
 
68
107
  Coverage of https://pinpayments.com/developers/api-reference
@@ -19,7 +19,7 @@ module PR
19
19
  register(:default_error_handler) { |error| error }
20
20
 
21
21
  class << self
22
- def connect(
22
+ def register_connection(
23
23
  identifier = :default,
24
24
  secret_key:,
25
25
  sandbox: true,
@@ -1,5 +1,5 @@
1
1
  module PR
2
2
  module Pin
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pr-pin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AMHOL
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-18 00:00:00.000000000 Z
11
+ date: 2019-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler