tipalti-ruby 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e37b79098df7e8046fedbea14803044851d44347bbda381f355824d8ba60adc6
4
- data.tar.gz: 439fcc44613745ed6e6d21e7ee232c274959e555cf43e08f233ece4a5c69244b
3
+ metadata.gz: 6c31c8896d94b7f278e2b9dbd549e41a491d99a2321ea35d6589672325575e59
4
+ data.tar.gz: df548617c330afde839ea4029a3df016a2547646d2dd9441b8be8e8ba395f16b
5
5
  SHA512:
6
- metadata.gz: 0e00bf980e2487d0f9f8af3c9bd178340f23ed8f89df1277ab02731cf63a2bcae7f72ea1d7980bce3cc977479b6124287d2f842458408d52dc1c23b478df0d71
7
- data.tar.gz: 1433b3cc4992fdf63d5ccab4b8fc1de771b1fa7815f3db1f924712ab73afc248a463a337a310c3814328a3269252d902a68a8cee026c191210acb0592a538bcd
6
+ metadata.gz: 0f593b4f11033f7340b46c441a673ff8e4df3b05ed7331f46ac8dbaa771aa2a0737bbf37eb2a67102960159dd57d1d63f6623320fe3dc410a4636df57dde75d7
7
+ data.tar.gz: c8589eb5007b3ec5e0f60342ea65902d8de7b40367f9a509ed3dae6b12bfdf197f485f65759d72da3ce6badff6186fd2564e56981ee9f2e01ac68f8756320a9e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v0.4.0
2
+
3
+ - Added IPN verification
4
+
5
+ ## v0.3.0
6
+
7
+ - Added payment get endpoint
8
+ - Added payment batch create endpoint
9
+ - Added payment batch instructions get endpoint
10
+
1
11
  ## v0.2.0
2
12
 
3
13
  - Added payees get endpoint
data/README.md CHANGED
@@ -18,6 +18,8 @@ Then `bundle install`.
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### API Client
22
+
21
23
  The Tipalti API uses OAuth to authenticate API requests.
22
24
 
23
25
  First you need ot get an access code externally by following the [Tipalti authorization flow](https://documentation.tipalti.com/docs/authorization-flow).
@@ -43,7 +45,7 @@ client = Tipalti::Client.new(
43
45
  )
44
46
  ```
45
47
 
46
- ### Endpoints
48
+ ### API Endpoints
47
49
 
48
50
  For use of each endpoint and available attributes or filtering criteria, please consult the [Tipalti API reference](https://documentation.tipalti.com/reference/introduction).
49
51
 
@@ -65,6 +67,37 @@ Example: `client.payee_get('123abc')`
65
67
 
66
68
  Example: `client.payee_list(filter: 'status=="ACTIVE"')`
67
69
 
70
+ #### Payment batches create
71
+
72
+ [API docs](https://documentation.tipalti.com/reference/post_api-v1-payment-batches)
73
+
74
+ Example:
75
+
76
+ ```ruby
77
+ client.payment_batch_create({
78
+ paymentInstructions: [
79
+ {
80
+ payeeId: '123456',
81
+ amountSubmitted: { amount: 5, currency: 'USD' },
82
+ refCode: '123ref'
83
+ }
84
+ ]
85
+ })
86
+ ```
87
+
88
+ #### Payment batches instructions get
89
+
90
+ [API docs](https://documentation.tipalti.com/reference/get_api-v1-payment-batches-id-instructions)
91
+
92
+ Example: `client.payment_batch_instructions_get('3456789')`
93
+
94
+ #### Payments get
95
+
96
+ [API docs](https://documentation.tipalti.com/reference/get_api-v1-payments-id)
97
+
98
+
99
+ Example: `client.payment_get('123abc')`
100
+
68
101
  ### Token Management
69
102
 
70
103
  #### Refresh
@@ -93,6 +126,33 @@ Any error code returned by the Tipalti API will result in one of the following e
93
126
  |503| Tipalti::ServiceUnavailable|
94
127
  |500| Tipalti::ServerError|
95
128
 
129
+ ### IPNs
130
+
131
+ Tiplati uses an IPN (instance payment notification) messaging service that enables you to receive notifications from Tipalti. Notifications are triggered when defined events occur (e.g., changes in payee details, system events and payment statuses).
132
+
133
+ To manage IPNs you will need to instantiate a IPN instance like so.
134
+
135
+ ```ruby
136
+ ipn = Tipalti::Ipn.new(
137
+ payload: '...', # The raw payload received to your server from the Tipalti IPN
138
+ )
139
+ ```
140
+
141
+ You can use the Tipalti sandbox by setting `ipn.sanbox = true` or as part of the initialization
142
+
143
+ ```ruby
144
+ ipn = Tipalti::Ipn.new(
145
+ ...
146
+ sandbox: true
147
+ )
148
+ ```
149
+
150
+ #### Verify
151
+
152
+ [API docs](https://support.tipalti.com/Content/Topics/Development/IPNs/ipnprotocol.htm#AcknowledgeAndVerifyIPN)
153
+
154
+ Example: `ipn.verify`
155
+
96
156
  ## License
97
157
 
98
158
  Copyright (C) 2023 Jordan Ell. See [LICENSE](https://github.com/riipen/tipalti-ruby/blob/master/LICENSE.md) for details.
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tipalti
4
+ module Actions
5
+ module Payment
6
+ def payment_get(id)
7
+ connection.get("/api/v1/payments/#{id}")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tipalti
4
+ module Actions
5
+ module PaymentBatch
6
+ def payment_batch_create(**params)
7
+ connection.post("/api/v1/payment-batches", **params)
8
+ end
9
+
10
+ def payment_batch_instructions_get(id)
11
+ connection.get("/api/v1/payment-batches/#{id}/instructions")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -3,6 +3,8 @@
3
3
  module Tipalti
4
4
  class Client
5
5
  include Tipalti::Actions::Payee
6
+ include Tipalti::Actions::Payment
7
+ include Tipalti::Actions::PaymentBatch
6
8
  include Tipalti::Actions::Token
7
9
 
8
10
  BASE_URL_P = "https://api-p.tipalti.com"
@@ -31,8 +31,6 @@ module Tipalti
31
31
  request(:put, path, params)
32
32
  end
33
33
 
34
- private
35
-
36
34
  def request(method, path, params)
37
35
  response = connection.public_send(method, path, params) do |request|
38
36
  request.headers["accept"] = "application/json"
@@ -46,6 +44,8 @@ module Tipalti
46
44
  response.body
47
45
  end
48
46
 
47
+ private
48
+
49
49
  def connection
50
50
  @connection ||= Faraday.new(url: @url) do |c|
51
51
  c.request :json, content_type: /\bjson$/
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Tipalti
4
4
  class Error < StandardError
5
+ attr_reader :response
6
+
5
7
  def self.from_response(response) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength:
6
8
  klass =
7
9
  case response.status
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tipalti
4
+ class Ipn
5
+ BASE_URL_P = "https://console.tipalti.com"
6
+ BASE_URL_S = "https://console.sandbox.tipalti.com"
7
+
8
+ attr_accessor :sandbox
9
+
10
+ def initialize(payload:, sandbox: false)
11
+ @payload = payload
12
+ @sandbox = sandbox
13
+ end
14
+
15
+ def base_url
16
+ @sandbox ? BASE_URL_S : BASE_URL_P
17
+ end
18
+
19
+ def connection
20
+ Connection.new(url: base_url)
21
+ end
22
+
23
+ def verify
24
+ connection.request(:post, "/notif/ipn.aspx", @payload)
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tipalti
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/tipalti-ruby.rb CHANGED
@@ -3,8 +3,11 @@
3
3
  $LOAD_PATH.unshift File.dirname(__FILE__)
4
4
 
5
5
  require "tipalti-ruby/actions/payee"
6
+ require "tipalti-ruby/actions/payment"
7
+ require "tipalti-ruby/actions/payment_batch"
6
8
  require "tipalti-ruby/actions/token"
7
9
  require "tipalti-ruby/client"
8
10
  require "tipalti-ruby/connection"
9
11
  require "tipalti-ruby/error"
12
+ require "tipalti-ruby/ipn"
10
13
  require "tipalti-ruby/version"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipalti-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Ell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-04 00:00:00.000000000 Z
11
+ date: 2023-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -44,7 +44,7 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.0'
47
- description: An API client for Tipalti in ruby.
47
+ description: Access the Tipalti REST API via OAuth2.
48
48
  email:
49
49
  - me@jordanell.com
50
50
  executables: []
@@ -62,12 +62,14 @@ files:
62
62
  - Rakefile
63
63
  - lib/tipalti-ruby.rb
64
64
  - lib/tipalti-ruby/actions/payee.rb
65
+ - lib/tipalti-ruby/actions/payment.rb
66
+ - lib/tipalti-ruby/actions/payment_batch.rb
65
67
  - lib/tipalti-ruby/actions/token.rb
66
68
  - lib/tipalti-ruby/client.rb
67
69
  - lib/tipalti-ruby/connection.rb
68
70
  - lib/tipalti-ruby/error.rb
71
+ - lib/tipalti-ruby/ipn.rb
69
72
  - lib/tipalti-ruby/version.rb
70
- - tipalti-ruby-0.1.0.gem
71
73
  homepage: https://github.com/riipen/tipalti-ruby
72
74
  licenses:
73
75
  - MIT
Binary file