k2-connect-ruby 3.0.0 → 4.0.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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +31 -0
  3. data/.gitignore +2 -0
  4. data/Gemfile.lock +38 -5
  5. data/README.md +499 -198
  6. data/k2-connect-ruby.gemspec +39 -35
  7. data/lib/k2-connect-ruby/entity.rb +39 -9
  8. data/lib/k2-connect-ruby/http_client.rb +43 -0
  9. data/lib/k2-connect-ruby/k2_entity/k2_entity.rb +12 -11
  10. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/destination_request.rb +27 -0
  11. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_bank_account.rb +32 -0
  12. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb +38 -0
  13. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_paybill.rb +31 -0
  14. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_till.rb +30 -0
  15. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_bank_account.rb +27 -0
  16. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_mpesa_wallet.rb +27 -0
  17. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/bank_account.rb +17 -0
  18. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/mobile_wallet.rb +24 -0
  19. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/paybill.rb +17 -0
  20. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/recipient_request.rb +32 -0
  21. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/till.rb +17 -0
  22. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient.rb +54 -0
  23. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_stk.rb +14 -31
  24. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_link.rb +53 -0
  25. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_links/payment_link_request.rb +43 -0
  26. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversal.rb +39 -0
  27. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversals/reversal_request.rb +39 -0
  28. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money/send_money_request.rb +53 -0
  29. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money.rb +73 -0
  30. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/stk_push/stk_push_request.rb +51 -0
  31. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_bank_account.rb +35 -0
  32. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_mpesa_wallet.rb +38 -0
  33. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/transfer_account_request.rb +25 -0
  34. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account.rb +49 -0
  35. data/lib/k2-connect-ruby/k2_entity/k2_polling.rb +16 -13
  36. data/lib/k2-connect-ruby/k2_entity/k2_subscribe.rb +16 -14
  37. data/lib/k2-connect-ruby/k2_entity/k2_token.rb +14 -39
  38. data/lib/k2-connect-ruby/k2_entity/polling/polling_request.rb +48 -0
  39. data/lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb +66 -0
  40. data/lib/k2-connect-ruby/k2_errors.rb +15 -71
  41. data/lib/k2-connect-ruby/k2_services/base_service.rb +25 -0
  42. data/lib/k2-connect-ruby/k2_services/k2_client.rb +7 -6
  43. data/lib/k2-connect-ruby/k2_services/payloads/daraja_webhooks.rb +43 -0
  44. data/lib/k2-connect-ruby/k2_services/payloads/k2_transaction.rb +20 -18
  45. data/lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb +36 -32
  46. data/lib/k2-connect-ruby/k2_services/payloads/transactions/incoming_payment.rb +31 -29
  47. data/lib/k2-connect-ruby/k2_services/payloads/transactions/outgoing_payment.rb +3 -1
  48. data/lib/k2-connect-ruby/k2_services/payloads/transactions/payment_link.rb +38 -0
  49. data/lib/k2-connect-ruby/k2_services/payloads/transactions/reversal.rb +35 -0
  50. data/lib/k2-connect-ruby/k2_services/payloads/transactions/send_money_payment.rb +25 -0
  51. data/lib/k2-connect-ruby/k2_services/payloads/transactions/transfer.rb +2 -0
  52. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_received.rb +9 -3
  53. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_reversed.rb +22 -0
  54. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_received.rb +6 -0
  55. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_reversed.rb +4 -0
  56. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_received.rb +18 -0
  57. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_reversed.rb +17 -0
  58. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_voided.rb +17 -0
  59. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/customer_created.rb +11 -7
  60. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb +50 -0
  61. data/lib/k2-connect-ruby/k2_services/send_introspect_token_request_service.rb +56 -0
  62. data/lib/k2-connect-ruby/k2_services/send_k2_connect_get_request_service.rb +42 -0
  63. data/lib/k2-connect-ruby/k2_services/send_k2_connect_post_request_service.rb +44 -0
  64. data/lib/k2-connect-ruby/k2_services/send_request_token_request_service.rb +55 -0
  65. data/lib/k2-connect-ruby/k2_services/send_revoke_token_request_service.rb +56 -0
  66. data/lib/k2-connect-ruby/k2_services/send_token_info_request_service.rb +44 -0
  67. data/lib/k2-connect-ruby/k2_services.rb +29 -0
  68. data/lib/k2-connect-ruby/k2_utilities/config/k2_config.rb +18 -26
  69. data/lib/k2-connect-ruby/k2_utilities/config/k2_config.yml +9 -10
  70. data/lib/k2-connect-ruby/k2_utilities/k2_authenticator.rb +12 -5
  71. data/lib/k2-connect-ruby/k2_utilities/k2_connection.rb +0 -48
  72. data/lib/k2-connect-ruby/k2_utilities/k2_connection_helper.rb +21 -0
  73. data/lib/k2-connect-ruby/k2_utilities/k2_process_result.rb +16 -15
  74. data/lib/k2-connect-ruby/k2_utilities/k2_process_webhook.rb +34 -21
  75. data/lib/k2-connect-ruby/k2_utilities/k2_url_parse.rb +3 -1
  76. data/lib/k2-connect-ruby/k2_utilities/phone_number_validator.rb +15 -0
  77. data/lib/k2-connect-ruby/k2_utilities.rb +9 -20
  78. data/lib/k2-connect-ruby/version.rb +1 -1
  79. data/lib/k2-connect-ruby.rb +14 -13
  80. metadata +119 -36
  81. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_pay.rb +0 -98
  82. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb +0 -48
  83. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb +0 -44
  84. data/lib/k2-connect-ruby/k2_entity/k2_notification.rb +0 -40
  85. data/lib/k2-connect-ruby/k2_services/payload_process.rb +0 -19
  86. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb +0 -44
  87. data/lib/k2-connect-ruby/k2_utilities/k2_validation.rb +0 -128
metadata CHANGED
@@ -1,43 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k2-connect-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DavidKar1uk1
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2026-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.2.2
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 8.1.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 7.2.2
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 8.1.1
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: activesupport
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
- - - "~>"
37
+ - - ">="
18
38
  - !ruby/object:Gem::Version
19
39
  version: 7.2.2
40
+ - - "<="
41
+ - !ruby/object:Gem::Version
42
+ version: 8.1.1
20
43
  type: :runtime
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
24
- - - "~>"
47
+ - - ">="
25
48
  - !ruby/object:Gem::Version
26
49
  version: 7.2.2
50
+ - - "<="
51
+ - !ruby/object:Gem::Version
52
+ version: 8.1.1
27
53
  - !ruby/object:Gem::Dependency
28
- name: activemodel
54
+ name: json
29
55
  requirement: !ruby/object:Gem::Requirement
30
56
  requirements:
31
57
  - - "~>"
32
58
  - !ruby/object:Gem::Version
33
- version: 7.2.2
59
+ version: 2.8.2
34
60
  type: :runtime
35
61
  prerelease: false
36
62
  version_requirements: !ruby/object:Gem::Requirement
37
63
  requirements:
38
64
  - - "~>"
39
65
  - !ruby/object:Gem::Version
40
- version: 7.2.2
66
+ version: 2.8.2
41
67
  - !ruby/object:Gem::Dependency
42
68
  name: rest-client
43
69
  requirement: !ruby/object:Gem::Requirement
@@ -53,33 +79,33 @@ dependencies:
53
79
  - !ruby/object:Gem::Version
54
80
  version: 2.1.0
55
81
  - !ruby/object:Gem::Dependency
56
- name: json
82
+ name: bundler
57
83
  requirement: !ruby/object:Gem::Requirement
58
84
  requirements:
59
85
  - - "~>"
60
86
  - !ruby/object:Gem::Version
61
- version: 2.8.2
62
- type: :runtime
87
+ version: 4.0.3
88
+ type: :development
63
89
  prerelease: false
64
90
  version_requirements: !ruby/object:Gem::Requirement
65
91
  requirements:
66
92
  - - "~>"
67
93
  - !ruby/object:Gem::Version
68
- version: 2.8.2
94
+ version: 4.0.3
69
95
  - !ruby/object:Gem::Dependency
70
- name: bundler
96
+ name: faker
71
97
  requirement: !ruby/object:Gem::Requirement
72
98
  requirements:
73
99
  - - "~>"
74
100
  - !ruby/object:Gem::Version
75
- version: 2.5.16
101
+ version: 3.5.1
76
102
  type: :development
77
103
  prerelease: false
78
104
  version_requirements: !ruby/object:Gem::Requirement
79
105
  requirements:
80
106
  - - "~>"
81
107
  - !ruby/object:Gem::Version
82
- version: 2.5.16
108
+ version: 3.5.1
83
109
  - !ruby/object:Gem::Dependency
84
110
  name: guard
85
111
  requirement: !ruby/object:Gem::Requirement
@@ -151,56 +177,71 @@ dependencies:
151
177
  - !ruby/object:Gem::Version
152
178
  version: 0.3.0
153
179
  - !ruby/object:Gem::Dependency
154
- name: vcr
180
+ name: rubocop
155
181
  requirement: !ruby/object:Gem::Requirement
156
182
  requirements:
157
183
  - - "~>"
158
184
  - !ruby/object:Gem::Version
159
- version: 6.3.1
185
+ version: 1.80.1
160
186
  type: :development
161
187
  prerelease: false
162
188
  version_requirements: !ruby/object:Gem::Requirement
163
189
  requirements:
164
190
  - - "~>"
165
191
  - !ruby/object:Gem::Version
166
- version: 6.3.1
192
+ version: 1.80.1
167
193
  - !ruby/object:Gem::Dependency
168
- name: webmock
194
+ name: rubocop-shopify
169
195
  requirement: !ruby/object:Gem::Requirement
170
196
  requirements:
171
197
  - - "~>"
172
198
  - !ruby/object:Gem::Version
173
- version: '3.24'
199
+ version: 2.17.1
174
200
  type: :development
175
201
  prerelease: false
176
202
  version_requirements: !ruby/object:Gem::Requirement
177
203
  requirements:
178
204
  - - "~>"
179
205
  - !ruby/object:Gem::Version
180
- version: '3.24'
206
+ version: 2.17.1
181
207
  - !ruby/object:Gem::Dependency
182
- name: faker
208
+ name: vcr
183
209
  requirement: !ruby/object:Gem::Requirement
184
210
  requirements:
185
211
  - - "~>"
186
212
  - !ruby/object:Gem::Version
187
- version: 3.5.1
213
+ version: 6.3.1
188
214
  type: :development
189
215
  prerelease: false
190
216
  version_requirements: !ruby/object:Gem::Requirement
191
217
  requirements:
192
218
  - - "~>"
193
219
  - !ruby/object:Gem::Version
194
- version: 3.5.1
220
+ version: 6.3.1
221
+ - !ruby/object:Gem::Dependency
222
+ name: webmock
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: '3.24'
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: '3.24'
195
235
  description: Ruby SDK for the Kopo Kopo K2 Connect API, with webhook subscriptions,
196
- STK Push, Pay and Settlement Transfer capabilities. Allows decomposition and break
197
- down of results and webhooks returned from the K2 Connect APIx``.
236
+ STK Push and Send Money capabilities. Allows decomposition and break down of results
237
+ and webhooks returned from the K2 Connect API.
198
238
  email:
199
239
  - David.mwangi@kopokopo.com
200
240
  executables: []
201
241
  extensions: []
202
242
  extra_rdoc_files: []
203
243
  files:
244
+ - ".github/pull_request_template.md"
204
245
  - ".gitignore"
205
246
  - ".gitmodules"
206
247
  - ".rspec"
@@ -219,37 +260,76 @@ files:
219
260
  - k2-connect-ruby.gemspec
220
261
  - lib/k2-connect-ruby.rb
221
262
  - lib/k2-connect-ruby/entity.rb
263
+ - lib/k2-connect-ruby/http_client.rb
222
264
  - lib/k2-connect-ruby/k2_entity/k2_entity.rb
223
- - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_pay.rb
224
- - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb
265
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/destination_request.rb
266
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_bank_account.rb
267
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb
268
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_paybill.rb
269
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_till.rb
270
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_bank_account.rb
271
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_mpesa_wallet.rb
272
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient.rb
273
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/bank_account.rb
274
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/mobile_wallet.rb
275
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/paybill.rb
276
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/recipient_request.rb
277
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/till.rb
225
278
  - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_stk.rb
226
- - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb
227
- - lib/k2-connect-ruby/k2_entity/k2_notification.rb
279
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_link.rb
280
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_links/payment_link_request.rb
281
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversal.rb
282
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversals/reversal_request.rb
283
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money.rb
284
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money/send_money_request.rb
285
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/stk_push/stk_push_request.rb
286
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account.rb
287
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_bank_account.rb
288
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_mpesa_wallet.rb
289
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/transfer_account_request.rb
228
290
  - lib/k2-connect-ruby/k2_entity/k2_polling.rb
229
291
  - lib/k2-connect-ruby/k2_entity/k2_subscribe.rb
230
292
  - lib/k2-connect-ruby/k2_entity/k2_token.rb
293
+ - lib/k2-connect-ruby/k2_entity/polling/polling_request.rb
294
+ - lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb
231
295
  - lib/k2-connect-ruby/k2_errors.rb
296
+ - lib/k2-connect-ruby/k2_services.rb
297
+ - lib/k2-connect-ruby/k2_services/base_service.rb
232
298
  - lib/k2-connect-ruby/k2_services/k2_client.rb
233
- - lib/k2-connect-ruby/k2_services/payload_process.rb
299
+ - lib/k2-connect-ruby/k2_services/payloads/daraja_webhooks.rb
234
300
  - lib/k2-connect-ruby/k2_services/payloads/k2_transaction.rb
235
301
  - lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb
236
302
  - lib/k2-connect-ruby/k2_services/payloads/transactions/incoming_payment.rb
237
303
  - lib/k2-connect-ruby/k2_services/payloads/transactions/outgoing_payment.rb
304
+ - lib/k2-connect-ruby/k2_services/payloads/transactions/payment_link.rb
305
+ - lib/k2-connect-ruby/k2_services/payloads/transactions/reversal.rb
306
+ - lib/k2-connect-ruby/k2_services/payloads/transactions/send_money_payment.rb
238
307
  - lib/k2-connect-ruby/k2_services/payloads/transactions/transfer.rb
239
308
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_received.rb
309
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_reversed.rb
240
310
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_received.rb
241
311
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_reversed.rb
312
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_received.rb
313
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_reversed.rb
314
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_voided.rb
242
315
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/customer_created.rb
243
- - lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb
316
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb
317
+ - lib/k2-connect-ruby/k2_services/send_introspect_token_request_service.rb
318
+ - lib/k2-connect-ruby/k2_services/send_k2_connect_get_request_service.rb
319
+ - lib/k2-connect-ruby/k2_services/send_k2_connect_post_request_service.rb
320
+ - lib/k2-connect-ruby/k2_services/send_request_token_request_service.rb
321
+ - lib/k2-connect-ruby/k2_services/send_revoke_token_request_service.rb
322
+ - lib/k2-connect-ruby/k2_services/send_token_info_request_service.rb
244
323
  - lib/k2-connect-ruby/k2_utilities.rb
245
324
  - lib/k2-connect-ruby/k2_utilities/config/k2_config.rb
246
325
  - lib/k2-connect-ruby/k2_utilities/config/k2_config.yml
247
326
  - lib/k2-connect-ruby/k2_utilities/k2_authenticator.rb
248
327
  - lib/k2-connect-ruby/k2_utilities/k2_connection.rb
328
+ - lib/k2-connect-ruby/k2_utilities/k2_connection_helper.rb
249
329
  - lib/k2-connect-ruby/k2_utilities/k2_process_result.rb
250
330
  - lib/k2-connect-ruby/k2_utilities/k2_process_webhook.rb
251
331
  - lib/k2-connect-ruby/k2_utilities/k2_url_parse.rb
252
- - lib/k2-connect-ruby/k2_utilities/k2_validation.rb
332
+ - lib/k2-connect-ruby/k2_utilities/phone_number_validator.rb
253
333
  - lib/k2-connect-ruby/version.rb
254
334
  homepage: https://github.com/kopokopo/k2-connect-ruby.git
255
335
  licenses:
@@ -259,15 +339,18 @@ metadata:
259
339
  homepage_uri: https://github.com/kopokopo/k2-connect-ruby.git
260
340
  source_code_uri: https://github.com/kopokopo/k2-connect-ruby.git
261
341
  changelog_uri: https://github.com/kopokopo/k2-connect-ruby.git/CHANGELOG.MD
262
- post_install_message:
342
+ post_install_message:
263
343
  rdoc_options: []
264
344
  require_paths:
265
345
  - lib
266
346
  required_ruby_version: !ruby/object:Gem::Requirement
267
347
  requirements:
268
- - - "~>"
348
+ - - ">="
269
349
  - !ruby/object:Gem::Version
270
350
  version: 3.3.5
351
+ - - "<="
352
+ - !ruby/object:Gem::Version
353
+ version: 3.4.7
271
354
  required_rubygems_version: !ruby/object:Gem::Requirement
272
355
  requirements:
273
356
  - - ">="
@@ -275,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
358
  version: '0'
276
359
  requirements: []
277
360
  rubygems_version: 3.5.16
278
- signing_key:
361
+ signing_key:
279
362
  specification_version: 4
280
363
  summary: Ruby SDK for the Kopo Kopo K2 Connect API.
281
364
  test_files: []
@@ -1,98 +0,0 @@
1
- module K2ConnectRuby
2
- module K2Entity
3
- class K2Pay < K2ConnectRuby::K2Entity::K2Entity
4
- attr_reader :recipients_location_url, :payments_location_url
5
-
6
- # Adding PAY Recipients with either mobile_wallets or bank_accounts as destination of your payments.
7
- def add_recipient(params)
8
- params = params.with_indifferent_access
9
- @exception_array += %w[type]
10
- # In the case of mobile pay recipient
11
- k2_request_pay_recipient = if params[:type].eql?('mobile_wallet')
12
- params = validate_input(params, @exception_array += %w[first_name last_name phone_number email network])
13
- {
14
- first_name: params[:first_name],
15
- last_name: params[:last_name],
16
- phone_number: validate_phone(params[:phone_number]),
17
- email: validate_email(params[:email]),
18
- network: params[:network]
19
- }
20
- # In the case of bank pay recipient
21
- elsif params[:type].eql?('bank_account')
22
- params = validate_input(params, @exception_array += %w[account_name account_number bank_branch_ref settlement_method])
23
- {
24
- account_name: params[:account_name],
25
- account_number: params[:account_number],
26
- bank_branch_ref: params[:bank_branch_ref],
27
- settlement_method: params[:settlement_method]
28
- }
29
- # In the case of till pay recipient
30
- elsif params[:type].eql?('till')
31
- params = validate_input(params, @exception_array += %w[till_name till_number])
32
- {
33
- till_name: params[:till_name],
34
- till_number: params[:till_number]
35
- }
36
- # In the case of bank pay recipient
37
- elsif params[:type].eql?('paybill')
38
- params = validate_input(params, @exception_array += %w[paybill_name paybill_number paybill_account_number])
39
- {
40
- paybill_name: params[:paybill_name],
41
- paybill_number: params[:paybill_number],
42
- paybill_account_number: params[:paybill_account_number]
43
- }
44
- else
45
- raise ArgumentError, 'Undefined Payment Method.'
46
- end
47
- recipients_body = {
48
- type: params[:type],
49
- #type: params['pay_type'],
50
- pay_recipient: k2_request_pay_recipient
51
- }
52
- pay_recipient_hash = make_hash(K2ConnectRuby::K2Utilities::Config::K2Config.path_url('pay_recipient'), 'post', @access_token, 'PAY', recipients_body)
53
- @recipients_location_url = K2ConnectRuby::K2Utilities::K2Connection.make_request(pay_recipient_hash)
54
- end
55
-
56
- # Create an outgoing Payment to a third party.
57
- def create_payment(params)
58
- # Validation
59
- params = validate_input(params, @exception_array += %w[destination_reference destination_type description category tags currency value callback_url metadata])
60
- # The Request Body Parameters
61
- k2_request_pay_amount = {
62
- currency: params[:currency],
63
- value: params[:value]
64
- }
65
- k2_request_pay_metadata = params[:metadata]
66
- k2_request_links = {
67
- callback_url: params[:callback_url]
68
- }
69
- create_payment_body = {
70
- destination_reference: params[:destination_reference],
71
- destination_type: params[:destination_type],
72
- description: params[:description],
73
- category: params[:category],
74
- tags: params[:tags],
75
- amount: k2_request_pay_amount,
76
- meta_data: k2_request_pay_metadata,
77
- _links: k2_request_links
78
- }
79
- create_payment_hash = make_hash(K2ConnectRuby::K2Utilities::Config::K2Config.path_url('payments'), 'post', @access_token, 'PAY', create_payment_body)
80
- @payments_location_url = K2ConnectRuby::K2Utilities::K2Connection.make_request(create_payment_hash)
81
- end
82
-
83
- # Query/Check the status of a previously initiated PAY Payment request
84
- def query_status(method_type)
85
- if method_type.eql?('recipients')
86
- super('PAY', @recipients_location_url)
87
- elsif method_type.eql?('payments')
88
- super('PAY', @payments_location_url)
89
- end
90
- end
91
-
92
- # Query Location URL
93
- def query_resource(url)
94
- super('PAY', url)
95
- end
96
- end
97
- end
98
- end
@@ -1,48 +0,0 @@
1
- module K2ConnectRuby
2
- module K2Entity
3
- class K2Settlement < K2ConnectRuby::K2Entity::K2Entity
4
- # Create a Verified Settlement Account via API (Mobile Wallet and Bank Account)
5
- def add_settlement_account(params)
6
- params=params.with_indifferent_access
7
- the_path_url = ''
8
- settlement_body = {}
9
- @exception_array += %w[type]
10
- # The Request Body Parameters
11
- settlement_body = if params[:type].eql?('merchant_wallet')
12
- params = validate_input(params, @exception_array += %w[first_name last_name phone_number network])
13
- the_path_url = K2ConnectRuby::K2Utilities::Config::K2Config.path_url('settlement_mobile_wallet')
14
- {
15
- first_name: params[:first_name],
16
- last_name: params[:last_name],
17
- phone_number: validate_phone(params[:phone_number]),
18
- network: params[:network]
19
- }
20
- elsif params[:type].eql?('merchant_bank_account')
21
- params = validate_input(params, @exception_array += %w[account_name bank_ref bank_branch_ref account_number currency value, settlement_method])
22
- the_path_url = K2ConnectRuby::K2Utilities::Config::K2Config.path_url('settlement_bank_account')
23
- {
24
- account_name: params[:account_name],
25
- bank_branch_ref: params[:bank_branch_ref],
26
- account_number: params[:account_number],
27
- settlement_method: params[:settlement_method]
28
- }
29
- else
30
- raise ArgumentError, 'Unknown Settlement Account'
31
- end
32
-
33
- settlement_hash = make_hash(the_path_url, 'post', @access_token, 'Transfer', settlement_body)
34
- @location_url = K2ConnectRuby::K2Utilities::K2Connection.make_request(settlement_hash)
35
- end
36
-
37
- # Check the status of a prior initiated Transfer. Make sure to add the id to the url
38
- def query_status
39
- super('Settlement', path_url=@location_url)
40
- end
41
-
42
- # Query Location URL
43
- def query_resource(url)
44
- super('Settlement', url)
45
- end
46
- end
47
- end
48
- end
@@ -1,44 +0,0 @@
1
- module K2ConnectRuby
2
- module K2Entity
3
- class K2Transfer < K2ConnectRuby::K2Entity::K2Entity
4
- # Create a either a 'blind' transfer, for when destination is specified, and a 'targeted' transfer which has a specified destination.
5
- def transfer_funds(params)
6
- # Validation
7
- unless params["destination_reference"].blank? && params["destination_type"].blank?
8
- params = validate_input(params, @exception_array += %w[destination_reference destination_type callback_url metadata])
9
- end
10
- params = params.with_indifferent_access
11
- # The Request Body Parameters
12
- k2_request_transfer = {
13
- destination_reference: params[:destination_reference],
14
- destination_type: params[:destination_type],
15
- amount: {
16
- currency: params[:currency],
17
- value: params[:value]
18
- }
19
- }
20
- metadata = params[:metadata]
21
- transfer_body = k2_request_transfer.merge(
22
- {
23
- _links:
24
- {
25
- callback_url: params[:callback_url]
26
- },
27
- metadata: metadata
28
- })
29
- transfer_hash = make_hash(K2ConnectRuby::K2Utilities::Config::K2Config.path_url('transfers'), 'post', @access_token, 'Transfer', transfer_body)
30
- @location_url = K2ConnectRuby::K2Utilities::K2Connection.make_request(transfer_hash)
31
- end
32
-
33
- # Check the status of a prior initiated Transfer. Make sure to add the id to the url
34
- def query_status
35
- super('Transfer', path_url=@location_url)
36
- end
37
-
38
- # Query Location URL
39
- def query_resource(url)
40
- super('Transfer', url)
41
- end
42
- end
43
- end
44
- end
@@ -1,40 +0,0 @@
1
- module K2ConnectRuby
2
- module K2Entity
3
- class K2Notification
4
- include K2ConnectRuby::K2Utilities::K2Validation, K2ConnectRuby::K2Utilities
5
- attr_reader :location_url, :k2_response_body
6
- attr_accessor :access_token
7
-
8
- # Initialize with access_token
9
- def initialize(access_token)
10
- raise ArgumentError, 'Nil or Empty Access Token Given!' if access_token.blank?
11
- @access_token = access_token
12
- end
13
-
14
- # Sends transaction notifications via SMS
15
- def send_sms_transaction_notification(params)
16
- k2_request_links = {
17
- callback_url: params[:callback_url]
18
- }
19
- k2_request_body = {
20
- webhook_event_reference: params[:webhook_event_reference],
21
- message: params[:message],
22
- _links: k2_request_links,
23
- }
24
- subscribe_hash = make_hash(K2ConnectRuby::K2Utilities::Config::K2Config.path_url('transaction_sms_notifications'), 'post', @access_token,'Notification', k2_request_body)
25
- @location_url = K2ConnectRuby::K2Utilities::K2Connection.make_request(subscribe_hash)
26
- end
27
-
28
- # Query Recent Webhook
29
- def query_resource(location_url = @location_url)
30
- query_hash = make_hash(location_url, 'get', @access_token, 'Notification', nil)
31
- @k2_response_body = K2ConnectRuby::K2Utilities::K2Connection.make_request(query_hash)
32
- end
33
-
34
- # Query Specific Webhook URL
35
- def query_resource_url(url)
36
- query_resource(url)
37
- end
38
- end
39
- end
40
- end
@@ -1,19 +0,0 @@
1
- require 'k2-connect-ruby/k2_services/k2_client'
2
-
3
- require 'k2-connect-ruby/k2_services/payloads/k2_webhooks'
4
- require 'k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_received'
5
- require 'k2-connect-ruby/k2_services/payloads/webhooks/customer_created'
6
- require 'k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_received'
7
- require 'k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_reversed'
8
- require 'k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook'
9
-
10
- require 'k2-connect-ruby/k2_services/payloads/k2_transaction'
11
- require 'k2-connect-ruby/k2_services/payloads/transactions/transfer'
12
- require 'k2-connect-ruby/k2_services/payloads/transactions/incoming_payment'
13
- require 'k2-connect-ruby/k2_services/payloads/transactions/outgoing_payment'
14
-
15
- module K2ConnectRuby
16
- module K2Services
17
- module PayloadProcess; end
18
- end
19
- end
@@ -1,44 +0,0 @@
1
- module K2ConnectRuby
2
- module K2Services
3
- module Payloads
4
- module Webhooks
5
- class SettlementWebhook < K2CommonEvents
6
- attr_reader :disbursements,
7
- :destination_type,
8
- :destination_network,
9
- :destination_reference,
10
- :destination_last_name,
11
- :destination_first_name,
12
- :destination_account_name,
13
- :destination_phone_number,
14
- :destination_account_number,
15
- :destination_bank_branch_ref,
16
- :destination_settlement_method
17
-
18
- def initialize(payload)
19
- super
20
- # Destination
21
- @disbursements = payload.dig('event', 'resource', 'disbursements')
22
- @destination_type = payload.dig('event', 'resource', 'destination', 'type')
23
- @destination_reference = payload.dig('event', 'resource', 'destination', 'resource', 'reference')
24
- destination_assets(payload)
25
- end
26
-
27
- def destination_assets(payload)
28
- if @destination_type.eql?('Mobile Wallet')
29
- @destination_network = payload.dig('event', 'resource', 'destination', 'resource', 'network')
30
- @destination_last_name = payload.dig('event', 'resource', 'destination', 'resource', 'last_name')
31
- @destination_first_name = payload.dig('event', 'resource', 'destination', 'resource', 'first_name')
32
- @destination_phone_number = payload.dig('event', 'resource', 'destination', 'resource', 'phone_number')
33
- elsif @destination_type.eql?('Bank Account')
34
- @destination_account_name = payload.dig('event', 'resource', 'destination', 'resource', 'account_name')
35
- @destination_account_number = payload.dig('event', 'resource', 'destination', 'resource', 'account_number')
36
- @destination_bank_branch_ref = payload.dig('event', 'resource', 'destination', 'resource', 'bank_branch_ref')
37
- @destination_settlement_method = payload.dig('event', 'resource', 'destination', 'resource', 'settlement_method')
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end