kody-clientsdk-ruby 1.6.14 → 1.6.16

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: 4a8bb43a172f7c0200dfcfcdea60904a5c4afed9f3a5c18c9762c0f2381370fe
4
- data.tar.gz: 4a0cfbae738e945b5ad5f9b8fdbc63c41bc62367d52ba1501ab267eac2086253
3
+ metadata.gz: 7ec4860466627d2a80a8ff0cc97908ff9a89a9eaef21002a816e00b0e421a20f
4
+ data.tar.gz: aa58a62425ca75939731d86f741328c51ec9215cea10963788c510be3bf02015
5
5
  SHA512:
6
- metadata.gz: cda9d9d04bace30d567c6fd8bcff3a161ad5016ad899aca89736f1c0068b30cc1fd69507f0f0bef8d7fe305aeda7739f652a2b0a20f8497b6db24b59a493fec3
7
- data.tar.gz: f4fc9af1179eb5ce3d192ca76b18c06f9a66d41f83544758910199d2e47336749198632a66ac9f958c182d84060dcaf67bd47074d360393f14aa92668e0b380f
6
+ metadata.gz: f5c5d70939c8db2e42b516eb120c310ae7d376d51c2653655728baffe73846fb30d86fba1bc1338a35593e0c19514a07b81312c4959d3057c12886551bf8e8f4
7
+ data.tar.gz: 7d4fbf3c253b5050ed057d57fa10594cf2b74452890afaad6d147e5e52d4a133b3d9b8eafeb03ed67c0f74daf9eb8dfcac082ead2d181c03ea631063d372bda1
data/README.md CHANGED
@@ -1,211 +1,128 @@
1
1
  # Kody API - Ruby SDK
2
2
 
3
- This guide provides an overview of using the Kody API and its reference documentation for Ruby.
3
+ This guide provides an overview of using the Kody API and its reference documentation.
4
4
 
5
- - [Installation](#installation)
5
+ - [Client Libraries](#client-libraries)
6
+ - [Ruby Installation](#ruby-installation)
6
7
  - [Authentication](#authentication)
7
- - [Quick Start](#quick-start)
8
+ - [Documentation](#documentation)
8
9
  - [Sample code](#sample-code)
9
10
 
10
- ## Installation
11
+ ## Client Libraries
11
12
 
12
- Add this line to your application's Gemfile:
13
+ Kody provides client libraries for many popular languages to access the APIs. If your desired programming language is supported by the client libraries, we recommend that you use this option.
13
14
 
14
- ```ruby
15
- gem 'kody-clientsdk-ruby'
16
- ```
15
+ Available languages:
16
+ - Java: https://github.com/KodyPay/kody-clientsdk-java/
17
+ - Python: https://github.com/KodyPay/kody-clientsdk-python/
18
+ - PHP: https://github.com/KodyPay/kody-clientsdk-php/
19
+ - .Net: https://github.com/KodyPay/kody-clientsdk-dotnet/
20
+ - Ruby: https://github.com/KodyPay/kody-clientsdk-ruby/
17
21
 
18
- And then execute:
22
+ The advantages of using the Kody Client library instead of a REST API are:
23
+ - Maintained by Kody.
24
+ - Built-in authentication and increased security.
25
+ - Built-in retries.
26
+ - Idiomatic for each language.
27
+ - Quicker development.
28
+ - Backwards compatibility with new versions.
19
29
 
20
- ```bash
21
- bundle install
22
- ```
30
+ If your coding language is not listed, please let the Kody team know and we will be able to create it for you.
23
31
 
24
- Or install it yourself as:
32
+ ## Ruby Installation
33
+ ### Requirements
34
+ - Ruby 2.6.10 and above
35
+ - Bundler (optional), recommended way to manage dependencies
36
+
37
+ Install the Kody Ruby Client SDK using gem:
25
38
 
26
39
  ```bash
27
40
  gem install kody-clientsdk-ruby
28
41
  ```
29
42
 
30
- ### Requirements
31
- - Ruby 2.6.10 or higher
32
- - gRPC support
33
-
34
- ## Authentication
35
-
36
- The client library uses a combination of a `Store ID` and an `API key`.
37
- These will be shared with you during the technical integration onboarding or by your Kody contact.
38
-
39
- During development, you will have access to a **test Store** and **test API key**, and when the integration is ready for live access, the production credentials will be shared securely with you and associated with a live store that was onboarded on Kody.
40
-
41
- The test and live API calls are always compatible, only changing credentials and the service hostname is required to enable the integration in production.
42
-
43
- ### Host names
44
-
45
- - Development and test: `grpc-staging.kodypay.com`
46
- - Live: `grpc.kodypay.com`
47
-
48
- ## Quick Start
43
+ Or add to your Gemfile:
49
44
 
50
45
  ```ruby
51
- require 'kody'
52
-
53
- # Configure the Kody client
54
- Kody.configure do |config|
55
- config.api_key = 'your-api-key'
56
- config.store_id = 'your-store-id'
57
- config.staging! # Use staging environment for testing
58
- end
59
-
60
- # Create a client instance
61
- client = Kody::Client.new
62
-
63
- # Initiate a payment
64
- begin
65
- response = client.ecom.initiate_payment(
66
- payment_reference: Kody::EcomClient.generate_payment_reference,
67
- amount_minor_units: 2000, # £20.00 in pence
68
- currency: 'GBP',
69
- order_id: Kody::EcomClient.generate_order_id,
70
- return_url: 'https://your-website.com/payment-return'
71
- )
72
-
73
- puts "Payment initiated successfully!"
74
- puts "Payment ID: #{response.response.payment_id}"
75
- puts "Payment URL: #{response.response.payment_url}"
76
-
77
- rescue Kody::Error => e
78
- puts "Error: #{e.message}"
79
- rescue GRPC::BadStatus => e
80
- puts "gRPC Error: #{e.message}"
81
- end
46
+ gem 'kody-clientsdk-ruby'
82
47
  ```
83
48
 
84
- ## Configuration Options
49
+ The library can also be downloaded from [RubyGems](https://rubygems.org/gems/kody-clientsdk-ruby).
85
50
 
86
- ### Environment Configuration
51
+ ### Import in code
87
52
 
88
53
  ```ruby
89
- # Production environment (default)
90
- Kody.configure do |config|
91
- config.api_key = 'your-production-api-key'
92
- config.store_id = 'your-production-store-id'
93
- # config.host defaults to 'grpc.kodypay.com'
94
- end
95
-
96
- # Staging environment
97
- Kody.configure do |config|
98
- config.api_key = 'your-test-api-key'
99
- config.store_id = 'your-test-store-id'
100
- config.staging! # Sets host to 'grpc-staging.kodypay.com'
101
- end
54
+ require 'kody'
102
55
 
103
- # Local development
56
+ # Configure SDK
104
57
  Kody.configure do |config|
58
+ config.staging_ap! # Use Asia-Pacific staging
105
59
  config.api_key = 'your-api-key'
106
60
  config.store_id = 'your-store-id'
107
- config.development! # Sets host to 'localhost:8080' with TLS disabled
108
61
  end
109
- ```
110
-
111
- ### Environment Variables
112
62
 
113
- You can also configure using environment variables:
63
+ # eCommerce API
64
+ ecom_stub = Com::Kodypay::Grpc::Ecom::V1::KodyEcomPaymentsService::Stub.new(
65
+ Kody.configuration.endpoint,
66
+ GRPC::Core::ChannelCredentials.new
67
+ )
114
68
 
115
- ```bash
116
- export KODY_API_KEY="your-api-key"
117
- export KODY_STORE_ID="your-store-id"
118
- ```
69
+ # Terminal API
70
+ terminal_stub = Com::Kodypay::Grpc::Pay::V1::KodyPayTerminalService::Stub.new(
71
+ Kody.configuration.endpoint,
72
+ GRPC::Core::ChannelCredentials.new
73
+ )
119
74
 
120
- ```ruby
121
- Kody.configure do |config|
122
- config.api_key = ENV['KODY_API_KEY']
123
- config.store_id = ENV['KODY_STORE_ID']
124
- config.staging! # or production/development
125
- end
75
+ # Ordering API
76
+ ordering_stub = Com::Kodypay::Grpc::Ordering::V1::KodyOrderingService::Stub.new(
77
+ Kody.configuration.endpoint,
78
+ GRPC::Core::ChannelCredentials.new
79
+ )
126
80
  ```
127
81
 
128
- ## Available Methods
129
-
130
- ### E-commerce Payments
131
-
132
- #### Initiate Payment
82
+ ## Authentication
133
83
 
134
- ```ruby
135
- response = client.ecom.initiate_payment(
136
- payment_reference: 'unique-payment-ref',
137
- amount_minor_units: 2000, # Amount in minor units (e.g., pence for GBP)
138
- currency: 'GBP',
139
- order_id: 'order-123',
140
- return_url: 'https://your-site.com/payment-return',
141
- # Optional parameters:
142
- order_metadata: '{"item": "Product Name"}',
143
- expiry: {
144
- show_timer: true,
145
- expiring_seconds: 1800 # 30 minutes
146
- },
147
- locale: 'en_GB',
148
- show_order_summary: true,
149
- show_merchant_name: true
150
- )
151
- ```
84
+ The client library uses a combination of a `Store ID` and an `API key`.
85
+ These will be shared with you during the technical integration onboarding or by your Kody contact.
152
86
 
153
- #### Get Payments
87
+ During development, you will have access to a **test Store** and **test API key**, and when the integration is ready for live access, the production credentials will be shared securely with you and associated with a live store that was onboarded on Kody.
154
88
 
155
- ```ruby
156
- response = client.ecom.get_payments(
157
- page: 1,
158
- page_size: 10,
159
- # Optional filter:
160
- filter: {
161
- order_id: 'specific-order-id' # Optional: filter by order ID
162
- }
163
- )
89
+ The test and live API calls are always compatible, only changing credentials and the service hostname is required to enable the integration in production.
164
90
 
165
- puts "Total payments: #{response.response.total}"
166
- response.response.payments.each do |payment|
167
- puts "Payment ID: #{payment.payment_id}"
168
- puts "Status: #{payment.status}"
169
- puts "Amount: #{payment.sale_data.amount_minor_units}" if payment.has_sale_data?
170
- end
171
- ```
91
+ ### Host names
172
92
 
173
- **Note:** Currently, `initiate_payment` and `get_payments` methods are implemented. Additional methods (payment details, refunds, etc.) will be added in future versions.
93
+ Development and Test:
94
+ - Default: `grpc-staging.kodypay.com`
95
+ - For Asia-specific region: `grpc-staging-ap.kodypay.com`
96
+ - For Europe-specific region: `grpc-staging-eu.kodypay.com`
174
97
 
175
- ## Helper Methods
98
+ Live:
99
+ - Default: `grpc.kodypay.com`
100
+ - For Asia-specific region: `grpc-ap.kodypay.com`
101
+ - For Europe-specific region: `grpc-eu.kodypay.com`
176
102
 
177
- The SDK provides convenient helper methods:
103
+ ### Endpoints Configuration
178
104
 
179
105
  ```ruby
180
- # Generate unique payment reference
181
- payment_ref = Kody::EcomClient.generate_payment_reference
182
- # Returns: "pay_a1b2c3d4e5f6g7h8"
183
-
184
- # Generate unique order ID
185
- order_id = Kody::EcomClient.generate_order_id
186
- # Returns: "order_a1b2c3d4e5f6g7h8"
106
+ # Production
107
+ config.production! # grpc.kodypay.com:443
108
+ config.production_ap! # grpc-ap.kodypay.com:443
109
+ config.production_eu! # grpc-eu.kodypay.com:443
110
+
111
+ # Staging
112
+ config.staging! # grpc-staging.kodypay.com:443
113
+ config.staging_ap! # grpc-staging-ap.kodypay.com:443
114
+ config.staging_eu! # grpc-staging-eu.kodypay.com:443
187
115
  ```
188
116
 
189
- ## Sample code
190
-
191
- Complete examples can be found in the `samples/` directory:
192
-
193
- - [Initiate Payment](samples/ecom/initiate_payment.rb)
194
- - [Get Payments](samples/ecom/get_payments.rb)
195
-
196
117
  ## Documentation
197
118
 
198
119
  For complete API documentation, examples, and integration guides, please visit:
199
120
  šŸ“š https://api-docs.kody.com
200
121
 
201
- ## Development Status
202
-
203
- This is a minimal initial version of the Ruby SDK focusing on the core payment initiation functionality. The SDK follows the same patterns as other Kody client SDKs and will be extended with additional features in future releases.
204
-
205
- ## Contributing
206
-
207
- Bug reports and pull requests are welcome on GitHub at https://github.com/KodyPay/kody-clientsdk-ruby.
208
-
209
- ## License
122
+ ## Sample code
210
123
 
211
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
124
+ - Java: https://github.com/KodyPay/kody-clientsdk-java/tree/main/samples
125
+ - Python: https://github.com/KodyPay/kody-clientsdk-python/tree/main/versions/3_12/samples
126
+ - PHP: https://github.com/KodyPay/kody-clientsdk-php/tree/main/samples
127
+ - .Net: https://github.com/KodyPay/kody-clientsdk-dotnet/tree/main/samples
128
+ - Ruby: https://github.com/KodyPay/kody-clientsdk-ruby/tree/main/samples
@@ -1,8 +1,15 @@
1
1
  module Kody
2
2
  class Configuration
3
- # Common KodyPay gRPC endpoints
4
- PRODUCTION_ENDPOINT = 'grpc.kodypay.com:443'
5
- STAGING_ENDPOINT = 'grpc-staging-ap.kodypay.com:443'
3
+ # KodyPay gRPC endpoints by region
4
+ # Production endpoints
5
+ PRODUCTION_ENDPOINT = 'grpc.kodypay.com:443' # Default
6
+ PRODUCTION_AP_ENDPOINT = 'grpc-ap.kodypay.com:443' # Asia-Pacific
7
+ PRODUCTION_EU_ENDPOINT = 'grpc-eu.kodypay.com:443' # Europe
8
+
9
+ # Staging endpoints
10
+ STAGING_ENDPOINT = 'grpc-staging.kodypay.com:443' # Default
11
+ STAGING_AP_ENDPOINT = 'grpc-staging-ap.kodypay.com:443' # Asia-Pacific
12
+ STAGING_EU_ENDPOINT = 'grpc-staging-eu.kodypay.com:443' # Europe
6
13
 
7
14
  attr_accessor :api_key, :store_id, :endpoint
8
15
 
@@ -13,5 +20,25 @@ module Kody
13
20
  def staging!
14
21
  @endpoint = STAGING_ENDPOINT
15
22
  end
23
+
24
+ def staging_ap!
25
+ @endpoint = STAGING_AP_ENDPOINT
26
+ end
27
+
28
+ def staging_eu!
29
+ @endpoint = STAGING_EU_ENDPOINT
30
+ end
31
+
32
+ def production!
33
+ @endpoint = PRODUCTION_ENDPOINT
34
+ end
35
+
36
+ def production_ap!
37
+ @endpoint = PRODUCTION_AP_ENDPOINT
38
+ end
39
+
40
+ def production_eu!
41
+ @endpoint = PRODUCTION_EU_ENDPOINT
42
+ end
16
43
  end
17
44
  end
data/lib/kody/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kody
2
- VERSION = "1.6.14"
2
+ VERSION = "1.6.16"
3
3
  end
@@ -10,25 +10,31 @@ puts
10
10
  # Configuration - replace with your actual credentials
11
11
  api_key = ENV['KODY_API_KEY'] || 'your-api-key-here'
12
12
  store_id = ENV['KODY_STORE_ID'] || 'your-store-id-here'
13
- endpoint = ENV['KODY_ENDPOINT'] || 'grpc-staging-ap.kodypay.com:443'
14
-
15
- puts "šŸ“” Endpoint: #{endpoint}"
16
- puts "šŸ”‘ Store ID: #{store_id[0..8]}..."
17
- puts "šŸ—ļø API Key: #{api_key[0..10]}..."
18
- puts
19
13
 
20
14
  begin
21
15
  # Require the published gem
22
16
  require 'kody'
23
17
 
24
- # Create the stub and make the API call
18
+ # Configure KodyPay SDK
19
+ Kody.configure do |config|
20
+ config.staging_ap! # Use Asia-Pacific staging endpoint
21
+ config.api_key = api_key
22
+ config.store_id = store_id
23
+ end
24
+
25
+ puts "šŸ“” Endpoint: #{Kody.configuration.endpoint}"
26
+ puts "šŸ”‘ Store ID: #{Kody.configuration.store_id[0..8]}..."
27
+ puts "šŸ—ļø API Key: #{Kody.configuration.api_key[0..10]}..."
28
+ puts
29
+
30
+ # Create the stub using configuration
25
31
  stub = Com::Kodypay::Grpc::Ecom::V1::KodyEcomPaymentsService::Stub.new(
26
- endpoint,
32
+ Kody.configuration.endpoint,
27
33
  GRPC::Core::ChannelCredentials.new
28
34
  )
29
35
 
30
36
  request = Com::Kodypay::Grpc::Ecom::V1::GetPaymentsRequest.new(
31
- store_id: store_id,
37
+ store_id: Kody.configuration.store_id,
32
38
  page_cursor: Com::Kodypay::Grpc::Ecom::V1::GetPaymentsRequest::PageCursor.new(
33
39
  page: 1,
34
40
  page_size: 10
@@ -36,7 +42,7 @@ begin
36
42
  )
37
43
 
38
44
  puts "šŸ“¤ Making gRPC call to GetPayments API..."
39
- response = stub.get_payments(request, metadata: { 'x-api-key' => api_key })
45
+ response = stub.get_payments(request, metadata: { 'x-api-key' => Kody.configuration.api_key })
40
46
 
41
47
  puts "šŸŽ‰ SUCCESS! Response from KodyPay API:"
42
48
  puts "šŸ“Š Total payments: #{response.response.total}"
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "šŸš€ KodyPay Ruby SDK Sample - GetTerminals API"
4
+ puts "============================================="
5
+ puts "šŸ“¦ Using kody-clientsdk-ruby gem from RubyGems"
6
+ puts
7
+
8
+ # Configuration - replace with your actual credentials
9
+ api_key = ENV['KODY_API_KEY'] || 'your-api-key-here'
10
+ store_id = ENV['KODY_STORE_ID'] || 'your-store-id-here'
11
+
12
+ begin
13
+ # Require the published gem
14
+ require 'kody'
15
+
16
+ # Configure KodyPay SDK
17
+ Kody.configure do |config|
18
+ config.staging_ap! # Use Asia-Pacific staging endpoint
19
+ config.api_key = api_key
20
+ config.store_id = store_id
21
+ end
22
+
23
+ puts "šŸ“” Endpoint: #{Kody.configuration.endpoint}"
24
+ puts "šŸ”‘ Store ID: #{Kody.configuration.store_id[0..8]}..."
25
+ puts "šŸ—ļø API Key: #{Kody.configuration.api_key[0..10]}..."
26
+ puts
27
+
28
+ # Create the Terminal API stub using configuration
29
+ stub = Com::Kodypay::Grpc::Pay::V1::KodyPayTerminalService::Stub.new(
30
+ Kody.configuration.endpoint,
31
+ GRPC::Core::ChannelCredentials.new
32
+ )
33
+
34
+ request = Com::Kodypay::Grpc::Pay::V1::TerminalsRequest.new(
35
+ store_id: Kody.configuration.store_id
36
+ )
37
+
38
+ puts "šŸ“¤ Making gRPC call to GetTerminals API..."
39
+ response = stub.terminals(request, metadata: { 'x-api-key' => Kody.configuration.api_key })
40
+
41
+ puts "šŸŽ‰ SUCCESS! Response from KodyPay Terminal API:"
42
+ puts "šŸ–„ļø Total terminals: #{response.terminals.length}"
43
+
44
+ if response.terminals.empty?
45
+ puts "šŸ“­ No terminals found for this store"
46
+ else
47
+ response.terminals.each_with_index do |terminal, index|
48
+ status = terminal.online ? "🟢 Online" : "šŸ”“ Offline"
49
+ puts "\nšŸ–„ļø Terminal #{index + 1}:"
50
+ puts " ID: #{terminal.terminal_id}"
51
+ puts " Status: #{status}"
52
+
53
+ if terminal.respond_to?(:last_activity_at) && terminal.last_activity_at
54
+ last_activity = Time.at(terminal.last_activity_at.seconds).strftime('%Y-%m-%d %H:%M:%S')
55
+ puts " Last Activity: #{last_activity}"
56
+ end
57
+
58
+ if terminal.respond_to?(:version) && terminal.version && !terminal.version.empty?
59
+ puts " Version: #{terminal.version}"
60
+ end
61
+ end
62
+ end
63
+
64
+ rescue GRPC::BadStatus => e
65
+ puts "āŒ gRPC API Error: #{e.code} - #{e.message}"
66
+ puts "šŸ’” Check your API credentials and store permissions"
67
+ rescue LoadError => e
68
+ puts "āŒ Missing dependency: #{e.message}"
69
+ puts "šŸ’” Install the gem with: gem install kody-clientsdk-ruby"
70
+ rescue => e
71
+ puts "āŒ Error: #{e.message}"
72
+ puts "šŸ” #{e.backtrace.first}"
73
+ end
74
+
75
+ puts "\nšŸ“š Documentation:"
76
+ puts " RubyGems: https://rubygems.org/gems/kody-clientsdk-ruby"
77
+ puts " GitHub: https://github.com/KodyPay/kody-clientsdk-ruby"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kody-clientsdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.14
4
+ version: 1.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kody Tech Team
@@ -134,6 +134,7 @@ files:
134
134
  - lib/pay_pb.rb
135
135
  - lib/pay_services_pb.rb
136
136
  - samples/ecom/get_payments.rb
137
+ - samples/pos/get_terminals.rb
137
138
  homepage: https://github.com/KodyPay/kody-clientsdk-ruby
138
139
  licenses:
139
140
  - MIT