nequi 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91bc719ff78273f0ebcd98941b1dc4d70c068bb6f1474b6ea628739c05e848c0
4
- data.tar.gz: 7838f1e6c3b1843a680ab92743ad056d084695ff22a4c53033190a385c6226c3
3
+ metadata.gz: 7f30a9b6d8ab5828e13366b702e83530b20a68b0a9c40d3b8ed6a7e75ee9c042
4
+ data.tar.gz: 0ca6e203683b1cdd68c9cdd6b59c31e223c5ac57151a077c155f1fb05f2e8b34
5
5
  SHA512:
6
- metadata.gz: 2c7c34585ef89632d8ad499675ad24aeb0c1149c7abfca9048e0e23c43b4a6e4cdeafbe79916bf569d3c47f1883347ae226c3f96c69be9258dd62225d31c0ae3
7
- data.tar.gz: e50824fcc51c1618e269f5b455758d909c5f019518b9dbc5e89c987b2a61398ee878f10bfc6d1ebf1a3857135a73d04daa1a33d570f5daffd54b3433e02ca851
6
+ metadata.gz: 4a053e6817c8cd60b67fe3920d96d801e6330a543e126b5fe3badd76299d6daa52aa0613b476d0d1d59beeef64e158f1987a65754e3818cf09db7841bdb878b2
7
+ data.tar.gz: 42492b86efbdfcc54e98479d54442d8015474c949ab850e0dae8067071608914c628c7059696fd8e061e49341ebcaafe8fe79f1cd425e247dd2ef4a8dc8a949a
data/lib/nequi.rb CHANGED
@@ -3,6 +3,10 @@
3
3
  require_relative "nequi/version"
4
4
 
5
5
  module Nequi
6
+ ERRORS_MESSAGES = {
7
+ "20-07A": "Nequi resive the payload but got an error from them."
8
+ }
9
+
6
10
  class Error < StandardError; end
7
11
  require 'httparty'
8
12
  require 'base64'
@@ -91,18 +95,18 @@ module Nequi
91
95
 
92
96
  response_status = response["ResponseMessage"]["ResponseHeader"]["Status"]
93
97
  status_code = response_status["StatusCode"]
94
- status_description = response_status["StatusDesc"]
98
+ status_description = response_status["StatusDesc"]
99
+
95
100
 
96
101
  return {
97
102
  type: 'Error',
98
103
  status: status_code,
99
- api_status: status_code,
100
- message: status_description
101
- } unless response_status.include?({ "StatusCode"=>"0", "StatusDesc"=>"SUCCESS" })
104
+ message: ERRORS_MESSAGES[:"#{status_code}"] || "#{status_code} #{status_description}",
105
+ } unless response_status == { "StatusCode" => "0", "StatusDesc" => "SUCCESS" }
102
106
 
103
107
  response_any = response["ResponseMessage"]["ResponseBody"]["any"]
104
108
  success_id = response_any["unregisteredPaymentRS"]["transactionId"]
105
- Nequi::StatusCheckJob.set(wait: 2.minutes).perform_later(product_id, configuration, access_token, success_id)
106
- { type: 'success', status: response.code, api_status: status_code, message: 'Payment request send success fully'}
109
+
110
+ {token: access_token, success_id: success_id, type: 'success', status: response.code, api_status: status_code, message: 'Payment request send success fully'}
107
111
  end
108
112
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nequi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - geocodinglife
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2023-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -78,26 +78,6 @@ dependencies:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: 3.18.1
81
- - !ruby/object:Gem::Dependency
82
- name: sidekiq
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '7.1'
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 7.1.2
91
- type: :runtime
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '7.1'
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: 7.1.2
101
81
  description: Nequi gem provides a convenient way to integrate with Nequi payments
102
82
  systems for processing payments and other related operations.
103
83
  email:
@@ -108,7 +88,6 @@ extra_rdoc_files: []
108
88
  files:
109
89
  - lib/nequi.rb
110
90
  - lib/nequi/version.rb
111
- - lib/nequi_status_check_job.rb
112
91
  homepage: https://github.com/geocodinglife/nequi
113
92
  licenses:
114
93
  - MIT
@@ -1,79 +0,0 @@
1
- # lib/nequi_status_check_job.rb
2
-
3
- module Nequi
4
- class StatusCheckJob < Struct.new(:product_id, :configuration, :token, :success_id)
5
- require 'httparty'
6
- require 'base64'
7
- require 'json'
8
- require 'time'
9
- require 'active_support/core_ext/integer/time'
10
-
11
- MAX_RETRIES = 4
12
-
13
- def perform
14
-
15
- @attempts ||= 0
16
-
17
- if @attempts >= MAX_RETRIES
18
- logs = { type: 'error', message: 'Job stopped due to maximum retries exceeded.' }
19
- Rails.logger.error(logs)
20
- return
21
- end
22
-
23
- @attempts += 1
24
-
25
- current_time = Time.now
26
- utc_time = current_time.utc
27
- formatted_timestamp = utc_time.strftime('%Y-%m-%dT%H:%M:%S.%LZ')
28
-
29
- headers = {
30
- 'Content-Type' => 'application/json',
31
- 'Accept' => 'application/json',
32
- 'Authorization' => "Bearer #{token}",
33
- 'x-api-key' => configuration.api_key
34
- }
35
-
36
- body = {
37
- "RequestMessage" => {
38
- "RequestHeader" => {
39
- "Channel" => "PNP04-C001",
40
- "RequestDate" => formatted_timestamp,
41
- "MessageID" => product_id,
42
- "ClientID" => configuration.client_id,
43
- "Destination" => {
44
- "ServiceName" => "PaymentsService",
45
- "ServiceOperation" => "getStatusPayment",
46
- "ServiceRegion" => "C001",
47
- "ServiceVersion" => "1.0.0"
48
- }
49
- },
50
- "RequestBody" => {
51
- "any" => {
52
- "getStatusPaymentRQ" => {
53
- "codeQR": success_id
54
- }
55
- }
56
- }
57
- }
58
- }.to_json
59
-
60
- nequi_status_payment_url = configuration.api_base_path + configuration.nequi_status_payment
61
-
62
- response = HTTParty.post(nequi_status_payment_url, body: body, headers: headers)
63
-
64
-
65
- response_status = response["ResponseMessage"]["ResponseHeader"]["Status"]
66
- status_code = response_status["StatusCode"]
67
- status_description = response_status["StatusDesc"]
68
-
69
- if status_description == 'SUCCESS'
70
- logs = { type: 'success', status: response.code, api_status: status_code, message: 'Payment request sent successfully' }
71
- Rails.logger.info(logs)
72
- else
73
- StatusCheckJob.set(wait: 2.minutes).perform_later(product_id, configuration, token, success_id)
74
- logs = { type: 'info', message: 'Retrying the job in 2 minutes...' }
75
- Rails.logger.info(logs)
76
- end
77
- end
78
- end
79
- end