k2-connect-ruby 3.1.0 → 4.0.3

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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +31 -0
  3. data/.gitignore +2 -0
  4. data/.ruby-version +1 -1
  5. data/Gemfile.lock +58 -22
  6. data/README.md +499 -198
  7. data/k2-connect-ruby.gemspec +39 -35
  8. data/lib/k2-connect-ruby/entity.rb +39 -9
  9. data/lib/k2-connect-ruby/http_client.rb +43 -0
  10. data/lib/k2-connect-ruby/k2_entity/k2_entity.rb +12 -11
  11. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/destination_request.rb +27 -0
  12. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_bank_account.rb +32 -0
  13. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb +38 -0
  14. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_paybill.rb +31 -0
  15. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_till.rb +30 -0
  16. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_bank_account.rb +27 -0
  17. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_mpesa_wallet.rb +27 -0
  18. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/bank_account.rb +17 -0
  19. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/mobile_wallet.rb +24 -0
  20. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/paybill.rb +17 -0
  21. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/recipient_request.rb +32 -0
  22. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/till.rb +17 -0
  23. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient.rb +54 -0
  24. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_stk.rb +14 -31
  25. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_link.rb +53 -0
  26. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_links/payment_link_request.rb +43 -0
  27. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversal.rb +39 -0
  28. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversals/reversal_request.rb +39 -0
  29. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money/send_money_request.rb +53 -0
  30. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money.rb +73 -0
  31. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/stk_push/stk_push_request.rb +51 -0
  32. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_bank_account.rb +35 -0
  33. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_mpesa_wallet.rb +38 -0
  34. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/transfer_account_request.rb +25 -0
  35. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account.rb +49 -0
  36. data/lib/k2-connect-ruby/k2_entity/k2_polling.rb +16 -13
  37. data/lib/k2-connect-ruby/k2_entity/k2_subscribe.rb +16 -14
  38. data/lib/k2-connect-ruby/k2_entity/k2_token.rb +14 -39
  39. data/lib/k2-connect-ruby/k2_entity/polling/polling_request.rb +48 -0
  40. data/lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb +66 -0
  41. data/lib/k2-connect-ruby/k2_errors.rb +15 -71
  42. data/lib/k2-connect-ruby/k2_services/base_service.rb +25 -0
  43. data/lib/k2-connect-ruby/k2_services/k2_client.rb +7 -6
  44. data/lib/k2-connect-ruby/k2_services/payloads/daraja_webhooks.rb +43 -0
  45. data/lib/k2-connect-ruby/k2_services/payloads/k2_transaction.rb +20 -18
  46. data/lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb +36 -32
  47. data/lib/k2-connect-ruby/k2_services/payloads/transactions/incoming_payment.rb +31 -29
  48. data/lib/k2-connect-ruby/k2_services/payloads/transactions/outgoing_payment.rb +3 -1
  49. data/lib/k2-connect-ruby/k2_services/payloads/transactions/payment_link.rb +38 -0
  50. data/lib/k2-connect-ruby/k2_services/payloads/transactions/reversal.rb +35 -0
  51. data/lib/k2-connect-ruby/k2_services/payloads/transactions/send_money_payment.rb +25 -0
  52. data/lib/k2-connect-ruby/k2_services/payloads/transactions/transfer.rb +2 -0
  53. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_received.rb +9 -3
  54. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_reversed.rb +22 -0
  55. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_received.rb +6 -0
  56. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_reversed.rb +4 -0
  57. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_received.rb +18 -0
  58. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_reversed.rb +17 -0
  59. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_voided.rb +17 -0
  60. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/customer_created.rb +11 -7
  61. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb +50 -0
  62. data/lib/k2-connect-ruby/k2_services/send_introspect_token_request_service.rb +56 -0
  63. data/lib/k2-connect-ruby/k2_services/send_k2_connect_get_request_service.rb +42 -0
  64. data/lib/k2-connect-ruby/k2_services/send_k2_connect_post_request_service.rb +44 -0
  65. data/lib/k2-connect-ruby/k2_services/send_request_token_request_service.rb +55 -0
  66. data/lib/k2-connect-ruby/k2_services/send_revoke_token_request_service.rb +56 -0
  67. data/lib/k2-connect-ruby/k2_services/send_token_info_request_service.rb +44 -0
  68. data/lib/k2-connect-ruby/k2_services.rb +29 -0
  69. data/lib/k2-connect-ruby/k2_utilities/config/k2_config.rb +18 -26
  70. data/lib/k2-connect-ruby/k2_utilities/config/k2_config.yml +9 -10
  71. data/lib/k2-connect-ruby/k2_utilities/k2_authenticator.rb +12 -5
  72. data/lib/k2-connect-ruby/k2_utilities/k2_connection.rb +0 -49
  73. data/lib/k2-connect-ruby/k2_utilities/k2_connection_helper.rb +21 -0
  74. data/lib/k2-connect-ruby/k2_utilities/k2_process_result.rb +16 -15
  75. data/lib/k2-connect-ruby/k2_utilities/k2_process_webhook.rb +34 -21
  76. data/lib/k2-connect-ruby/k2_utilities/k2_url_parse.rb +3 -1
  77. data/lib/k2-connect-ruby/k2_utilities/phone_number_validator.rb +15 -0
  78. data/lib/k2-connect-ruby/k2_utilities.rb +9 -20
  79. data/lib/k2-connect-ruby/version.rb +3 -1
  80. data/lib/k2-connect-ruby.rb +14 -13
  81. metadata +97 -47
  82. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_pay.rb +0 -98
  83. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb +0 -48
  84. data/lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb +0 -44
  85. data/lib/k2-connect-ruby/k2_entity/k2_notification.rb +0 -40
  86. data/lib/k2-connect-ruby/k2_services/payload_process.rb +0 -19
  87. data/lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb +0 -44
  88. data/lib/k2-connect-ruby/k2_utilities/k2_validation.rb +0 -128
metadata CHANGED
@@ -1,25 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k2-connect-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DavidKar1uk1
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-01-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: activesupport
13
+ name: activemodel
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: 7.2.2
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 8.1.1
23
19
  type: :runtime
24
20
  prerelease: false
25
21
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,19 +23,13 @@ dependencies:
27
23
  - - ">="
28
24
  - !ruby/object:Gem::Version
29
25
  version: 7.2.2
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 8.1.1
33
26
  - !ruby/object:Gem::Dependency
34
- name: activemodel
27
+ name: activesupport
35
28
  requirement: !ruby/object:Gem::Requirement
36
29
  requirements:
37
30
  - - ">="
38
31
  - !ruby/object:Gem::Version
39
32
  version: 7.2.2
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: 8.1.1
43
33
  type: :runtime
44
34
  prerelease: false
45
35
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +37,20 @@ dependencies:
47
37
  - - ">="
48
38
  - !ruby/object:Gem::Version
49
39
  version: 7.2.2
50
- - - "<"
40
+ - !ruby/object:Gem::Dependency
41
+ name: json
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
- version: 8.1.1
46
+ version: 2.8.2
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 2.8.2
53
54
  - !ruby/object:Gem::Dependency
54
55
  name: rest-client
55
56
  requirement: !ruby/object:Gem::Requirement
@@ -65,33 +66,33 @@ dependencies:
65
66
  - !ruby/object:Gem::Version
66
67
  version: 2.1.0
67
68
  - !ruby/object:Gem::Dependency
68
- name: json
69
+ name: bundler
69
70
  requirement: !ruby/object:Gem::Requirement
70
71
  requirements:
71
72
  - - "~>"
72
73
  - !ruby/object:Gem::Version
73
- version: 2.8.2
74
- type: :runtime
74
+ version: 4.0.3
75
+ type: :development
75
76
  prerelease: false
76
77
  version_requirements: !ruby/object:Gem::Requirement
77
78
  requirements:
78
79
  - - "~>"
79
80
  - !ruby/object:Gem::Version
80
- version: 2.8.2
81
+ version: 4.0.3
81
82
  - !ruby/object:Gem::Dependency
82
- name: bundler
83
+ name: faker
83
84
  requirement: !ruby/object:Gem::Requirement
84
85
  requirements:
85
86
  - - "~>"
86
87
  - !ruby/object:Gem::Version
87
- version: 2.5.16
88
+ version: 3.5.1
88
89
  type: :development
89
90
  prerelease: false
90
91
  version_requirements: !ruby/object:Gem::Requirement
91
92
  requirements:
92
93
  - - "~>"
93
94
  - !ruby/object:Gem::Version
94
- version: 2.5.16
95
+ version: 3.5.1
95
96
  - !ruby/object:Gem::Dependency
96
97
  name: guard
97
98
  requirement: !ruby/object:Gem::Requirement
@@ -163,56 +164,71 @@ dependencies:
163
164
  - !ruby/object:Gem::Version
164
165
  version: 0.3.0
165
166
  - !ruby/object:Gem::Dependency
166
- name: vcr
167
+ name: rubocop
167
168
  requirement: !ruby/object:Gem::Requirement
168
169
  requirements:
169
170
  - - "~>"
170
171
  - !ruby/object:Gem::Version
171
- version: 6.3.1
172
+ version: 1.80.1
172
173
  type: :development
173
174
  prerelease: false
174
175
  version_requirements: !ruby/object:Gem::Requirement
175
176
  requirements:
176
177
  - - "~>"
177
178
  - !ruby/object:Gem::Version
178
- version: 6.3.1
179
+ version: 1.80.1
179
180
  - !ruby/object:Gem::Dependency
180
- name: webmock
181
+ name: rubocop-shopify
181
182
  requirement: !ruby/object:Gem::Requirement
182
183
  requirements:
183
184
  - - "~>"
184
185
  - !ruby/object:Gem::Version
185
- version: '3.24'
186
+ version: 2.17.1
186
187
  type: :development
187
188
  prerelease: false
188
189
  version_requirements: !ruby/object:Gem::Requirement
189
190
  requirements:
190
191
  - - "~>"
191
192
  - !ruby/object:Gem::Version
192
- version: '3.24'
193
+ version: 2.17.1
193
194
  - !ruby/object:Gem::Dependency
194
- name: faker
195
+ name: vcr
195
196
  requirement: !ruby/object:Gem::Requirement
196
197
  requirements:
197
198
  - - "~>"
198
199
  - !ruby/object:Gem::Version
199
- version: 3.5.1
200
+ version: 6.3.1
200
201
  type: :development
201
202
  prerelease: false
202
203
  version_requirements: !ruby/object:Gem::Requirement
203
204
  requirements:
204
205
  - - "~>"
205
206
  - !ruby/object:Gem::Version
206
- version: 3.5.1
207
+ version: 6.3.1
208
+ - !ruby/object:Gem::Dependency
209
+ name: webmock
210
+ requirement: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '3.24'
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - "~>"
220
+ - !ruby/object:Gem::Version
221
+ version: '3.24'
207
222
  description: Ruby SDK for the Kopo Kopo K2 Connect API, with webhook subscriptions,
208
- STK Push, Pay and Settlement Transfer capabilities. Allows decomposition and break
209
- down of results and webhooks returned from the K2 Connect APIx``.
223
+ STK Push and Send Money capabilities. Allows decomposition and break down of results
224
+ and webhooks returned from the K2 Connect API.
210
225
  email:
211
226
  - David.mwangi@kopokopo.com
212
227
  executables: []
213
228
  extensions: []
214
229
  extra_rdoc_files: []
215
230
  files:
231
+ - ".github/pull_request_template.md"
216
232
  - ".gitignore"
217
233
  - ".gitmodules"
218
234
  - ".rspec"
@@ -231,37 +247,76 @@ files:
231
247
  - k2-connect-ruby.gemspec
232
248
  - lib/k2-connect-ruby.rb
233
249
  - lib/k2-connect-ruby/entity.rb
250
+ - lib/k2-connect-ruby/http_client.rb
234
251
  - lib/k2-connect-ruby/k2_entity/k2_entity.rb
235
- - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_pay.rb
236
- - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb
252
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/destination_request.rb
253
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_bank_account.rb
254
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_mpesa_wallet.rb
255
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_paybill.rb
256
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/external_till.rb
257
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_bank_account.rb
258
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/destination/merchant_mpesa_wallet.rb
259
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient.rb
260
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/bank_account.rb
261
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/mobile_wallet.rb
262
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/paybill.rb
263
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/recipient_request.rb
264
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/external_recipient/till.rb
237
265
  - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_stk.rb
238
- - lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb
239
- - lib/k2-connect-ruby/k2_entity/k2_notification.rb
266
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_link.rb
267
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/payment_links/payment_link_request.rb
268
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversal.rb
269
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/reversals/reversal_request.rb
270
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money.rb
271
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/send_money/send_money_request.rb
272
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/stk_push/stk_push_request.rb
273
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account.rb
274
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_bank_account.rb
275
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/merchant_mpesa_wallet.rb
276
+ - lib/k2-connect-ruby/k2_entity/k2_financial_entities/transfer_account/transfer_account_request.rb
240
277
  - lib/k2-connect-ruby/k2_entity/k2_polling.rb
241
278
  - lib/k2-connect-ruby/k2_entity/k2_subscribe.rb
242
279
  - lib/k2-connect-ruby/k2_entity/k2_token.rb
280
+ - lib/k2-connect-ruby/k2_entity/polling/polling_request.rb
281
+ - lib/k2-connect-ruby/k2_entity/webhook/webhook_subscription_request.rb
243
282
  - lib/k2-connect-ruby/k2_errors.rb
283
+ - lib/k2-connect-ruby/k2_services.rb
284
+ - lib/k2-connect-ruby/k2_services/base_service.rb
244
285
  - lib/k2-connect-ruby/k2_services/k2_client.rb
245
- - lib/k2-connect-ruby/k2_services/payload_process.rb
286
+ - lib/k2-connect-ruby/k2_services/payloads/daraja_webhooks.rb
246
287
  - lib/k2-connect-ruby/k2_services/payloads/k2_transaction.rb
247
288
  - lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb
248
289
  - lib/k2-connect-ruby/k2_services/payloads/transactions/incoming_payment.rb
249
290
  - lib/k2-connect-ruby/k2_services/payloads/transactions/outgoing_payment.rb
291
+ - lib/k2-connect-ruby/k2_services/payloads/transactions/payment_link.rb
292
+ - lib/k2-connect-ruby/k2_services/payloads/transactions/reversal.rb
293
+ - lib/k2-connect-ruby/k2_services/payloads/transactions/send_money_payment.rb
250
294
  - lib/k2-connect-ruby/k2_services/payloads/transactions/transfer.rb
251
295
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_received.rb
296
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/b2b_transaction_reversed.rb
252
297
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_received.rb
253
298
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_reversed.rb
299
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_received.rb
300
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_reversed.rb
301
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/card_transaction_voided.rb
254
302
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/customer_created.rb
255
- - lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb
303
+ - lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb
304
+ - lib/k2-connect-ruby/k2_services/send_introspect_token_request_service.rb
305
+ - lib/k2-connect-ruby/k2_services/send_k2_connect_get_request_service.rb
306
+ - lib/k2-connect-ruby/k2_services/send_k2_connect_post_request_service.rb
307
+ - lib/k2-connect-ruby/k2_services/send_request_token_request_service.rb
308
+ - lib/k2-connect-ruby/k2_services/send_revoke_token_request_service.rb
309
+ - lib/k2-connect-ruby/k2_services/send_token_info_request_service.rb
256
310
  - lib/k2-connect-ruby/k2_utilities.rb
257
311
  - lib/k2-connect-ruby/k2_utilities/config/k2_config.rb
258
312
  - lib/k2-connect-ruby/k2_utilities/config/k2_config.yml
259
313
  - lib/k2-connect-ruby/k2_utilities/k2_authenticator.rb
260
314
  - lib/k2-connect-ruby/k2_utilities/k2_connection.rb
315
+ - lib/k2-connect-ruby/k2_utilities/k2_connection_helper.rb
261
316
  - lib/k2-connect-ruby/k2_utilities/k2_process_result.rb
262
317
  - lib/k2-connect-ruby/k2_utilities/k2_process_webhook.rb
263
318
  - lib/k2-connect-ruby/k2_utilities/k2_url_parse.rb
264
- - lib/k2-connect-ruby/k2_utilities/k2_validation.rb
319
+ - lib/k2-connect-ruby/k2_utilities/phone_number_validator.rb
265
320
  - lib/k2-connect-ruby/version.rb
266
321
  homepage: https://github.com/kopokopo/k2-connect-ruby.git
267
322
  licenses:
@@ -271,7 +326,6 @@ metadata:
271
326
  homepage_uri: https://github.com/kopokopo/k2-connect-ruby.git
272
327
  source_code_uri: https://github.com/kopokopo/k2-connect-ruby.git
273
328
  changelog_uri: https://github.com/kopokopo/k2-connect-ruby.git/CHANGELOG.MD
274
- post_install_message:
275
329
  rdoc_options: []
276
330
  require_paths:
277
331
  - lib
@@ -280,17 +334,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
280
334
  - - ">="
281
335
  - !ruby/object:Gem::Version
282
336
  version: 3.3.5
283
- - - "<="
284
- - !ruby/object:Gem::Version
285
- version: 3.4.7
286
337
  required_rubygems_version: !ruby/object:Gem::Requirement
287
338
  requirements:
288
339
  - - ">="
289
340
  - !ruby/object:Gem::Version
290
341
  version: '0'
291
342
  requirements: []
292
- rubygems_version: 3.5.16
293
- signing_key:
343
+ rubygems_version: 3.6.9
294
344
  specification_version: 4
295
345
  summary: Ruby SDK for the Kopo Kopo K2 Connect API.
296
346
  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