k2-connect-ruby 3.1.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 -49
  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 +101 -33
  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,23 +1,23 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DavidKar1uk1
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-01-08 00:00:00.000000000 Z
11
+ date: 2026-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 7.2.2
20
- - - "<"
20
+ - - "<="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 8.1.1
23
23
  type: :runtime
@@ -27,17 +27,17 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 7.2.2
30
- - - "<"
30
+ - - "<="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 8.1.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: activemodel
34
+ name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 7.2.2
40
- - - "<"
40
+ - - "<="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 8.1.1
43
43
  type: :runtime
@@ -47,9 +47,23 @@ dependencies:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 7.2.2
50
- - - "<"
50
+ - - "<="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 8.1.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: json
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 2.8.2
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 2.8.2
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: rest-client
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -65,33 +79,33 @@ dependencies:
65
79
  - !ruby/object:Gem::Version
66
80
  version: 2.1.0
67
81
  - !ruby/object:Gem::Dependency
68
- name: json
82
+ name: bundler
69
83
  requirement: !ruby/object:Gem::Requirement
70
84
  requirements:
71
85
  - - "~>"
72
86
  - !ruby/object:Gem::Version
73
- version: 2.8.2
74
- type: :runtime
87
+ version: 4.0.3
88
+ type: :development
75
89
  prerelease: false
76
90
  version_requirements: !ruby/object:Gem::Requirement
77
91
  requirements:
78
92
  - - "~>"
79
93
  - !ruby/object:Gem::Version
80
- version: 2.8.2
94
+ version: 4.0.3
81
95
  - !ruby/object:Gem::Dependency
82
- name: bundler
96
+ name: faker
83
97
  requirement: !ruby/object:Gem::Requirement
84
98
  requirements:
85
99
  - - "~>"
86
100
  - !ruby/object:Gem::Version
87
- version: 2.5.16
101
+ version: 3.5.1
88
102
  type: :development
89
103
  prerelease: false
90
104
  version_requirements: !ruby/object:Gem::Requirement
91
105
  requirements:
92
106
  - - "~>"
93
107
  - !ruby/object:Gem::Version
94
- version: 2.5.16
108
+ version: 3.5.1
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: guard
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -163,56 +177,71 @@ dependencies:
163
177
  - !ruby/object:Gem::Version
164
178
  version: 0.3.0
165
179
  - !ruby/object:Gem::Dependency
166
- name: vcr
180
+ name: rubocop
167
181
  requirement: !ruby/object:Gem::Requirement
168
182
  requirements:
169
183
  - - "~>"
170
184
  - !ruby/object:Gem::Version
171
- version: 6.3.1
185
+ version: 1.80.1
172
186
  type: :development
173
187
  prerelease: false
174
188
  version_requirements: !ruby/object:Gem::Requirement
175
189
  requirements:
176
190
  - - "~>"
177
191
  - !ruby/object:Gem::Version
178
- version: 6.3.1
192
+ version: 1.80.1
179
193
  - !ruby/object:Gem::Dependency
180
- name: webmock
194
+ name: rubocop-shopify
181
195
  requirement: !ruby/object:Gem::Requirement
182
196
  requirements:
183
197
  - - "~>"
184
198
  - !ruby/object:Gem::Version
185
- version: '3.24'
199
+ version: 2.17.1
186
200
  type: :development
187
201
  prerelease: false
188
202
  version_requirements: !ruby/object:Gem::Requirement
189
203
  requirements:
190
204
  - - "~>"
191
205
  - !ruby/object:Gem::Version
192
- version: '3.24'
206
+ version: 2.17.1
193
207
  - !ruby/object:Gem::Dependency
194
- name: faker
208
+ name: vcr
195
209
  requirement: !ruby/object:Gem::Requirement
196
210
  requirements:
197
211
  - - "~>"
198
212
  - !ruby/object:Gem::Version
199
- version: 3.5.1
213
+ version: 6.3.1
200
214
  type: :development
201
215
  prerelease: false
202
216
  version_requirements: !ruby/object:Gem::Requirement
203
217
  requirements:
204
218
  - - "~>"
205
219
  - !ruby/object:Gem::Version
206
- 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'
207
235
  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``.
236
+ STK Push and Send Money capabilities. Allows decomposition and break down of results
237
+ and webhooks returned from the K2 Connect API.
210
238
  email:
211
239
  - David.mwangi@kopokopo.com
212
240
  executables: []
213
241
  extensions: []
214
242
  extra_rdoc_files: []
215
243
  files:
244
+ - ".github/pull_request_template.md"
216
245
  - ".gitignore"
217
246
  - ".gitmodules"
218
247
  - ".rspec"
@@ -231,37 +260,76 @@ files:
231
260
  - k2-connect-ruby.gemspec
232
261
  - lib/k2-connect-ruby.rb
233
262
  - lib/k2-connect-ruby/entity.rb
263
+ - lib/k2-connect-ruby/http_client.rb
234
264
  - 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
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
237
278
  - 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
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
240
290
  - lib/k2-connect-ruby/k2_entity/k2_polling.rb
241
291
  - lib/k2-connect-ruby/k2_entity/k2_subscribe.rb
242
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
243
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
244
298
  - lib/k2-connect-ruby/k2_services/k2_client.rb
245
- - lib/k2-connect-ruby/k2_services/payload_process.rb
299
+ - lib/k2-connect-ruby/k2_services/payloads/daraja_webhooks.rb
246
300
  - lib/k2-connect-ruby/k2_services/payloads/k2_transaction.rb
247
301
  - lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb
248
302
  - lib/k2-connect-ruby/k2_services/payloads/transactions/incoming_payment.rb
249
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
250
307
  - lib/k2-connect-ruby/k2_services/payloads/transactions/transfer.rb
251
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
252
310
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/buygoods_transaction_received.rb
253
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
254
315
  - lib/k2-connect-ruby/k2_services/payloads/webhooks/customer_created.rb
255
- - 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
256
323
  - lib/k2-connect-ruby/k2_utilities.rb
257
324
  - lib/k2-connect-ruby/k2_utilities/config/k2_config.rb
258
325
  - lib/k2-connect-ruby/k2_utilities/config/k2_config.yml
259
326
  - lib/k2-connect-ruby/k2_utilities/k2_authenticator.rb
260
327
  - lib/k2-connect-ruby/k2_utilities/k2_connection.rb
328
+ - lib/k2-connect-ruby/k2_utilities/k2_connection_helper.rb
261
329
  - lib/k2-connect-ruby/k2_utilities/k2_process_result.rb
262
330
  - lib/k2-connect-ruby/k2_utilities/k2_process_webhook.rb
263
331
  - lib/k2-connect-ruby/k2_utilities/k2_url_parse.rb
264
- - lib/k2-connect-ruby/k2_utilities/k2_validation.rb
332
+ - lib/k2-connect-ruby/k2_utilities/phone_number_validator.rb
265
333
  - lib/k2-connect-ruby/version.rb
266
334
  homepage: https://github.com/kopokopo/k2-connect-ruby.git
267
335
  licenses:
@@ -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