leanweb 0.5.0 → 0.5.1
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 +4 -4
- data/contrib/lib/hawese.rb +26 -0
- data/lib/leanweb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54fc1b8b4dff318eb3ccc51e8f0862706c0b8de9879dadf403580f00a224b9df
|
4
|
+
data.tar.gz: e2a5d17a9f7a2f13f0cb2983031f91127387021a26d70a7bc91e0722ffb19bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0563e596c38aefdd7af7150ed4f87dbbb55c6bee5459d397574e5fb1da18fe31e5091d6f8346e952729118fed9fda8f6e0b3f2579e0b39fc54d426cee76b81ed
|
7
|
+
data.tar.gz: 579991147e69766158a1168d28ec58f8da90a94ad4383e2fe8001b15cc4460895892600d53968e063e067a7be2c12347f25e37ec94cb2237e5adc32c04333a1a
|
data/contrib/lib/hawese.rb
CHANGED
@@ -20,6 +20,7 @@ require 'uri'
|
|
20
20
|
# - HAWESE_RETURN_URL defaults to `LEANWEB_ENDPOINT/checkout`.
|
21
21
|
# - HAWESE_ENDPOINT
|
22
22
|
# - HAWESE_ORIGIN
|
23
|
+
# - HAWESE_AUTH_TOKEN
|
23
24
|
class Hawese
|
24
25
|
class << self
|
25
26
|
ENDPOINT = ENV.fetch('HAWESE_ENDPOINT')
|
@@ -54,6 +55,21 @@ class Hawese
|
|
54
55
|
JSON.parse(response.body, symbolize_names: true)
|
55
56
|
end
|
56
57
|
|
58
|
+
def receipt(gateway, payment_uuid, fields = {})
|
59
|
+
uri = URI(
|
60
|
+
"#{ENDPOINT}/#{ORIGIN}/gateways/#{gateway}/receipt/#{payment_uuid}"
|
61
|
+
)
|
62
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
63
|
+
req = Net::HTTP::Post.new(uri, {
|
64
|
+
'Authorization' => "Bearer #{ENV.fetch('HAWESE_AUTH_TOKEN')}",
|
65
|
+
'Content-Type' => 'application/json'
|
66
|
+
})
|
67
|
+
req.body = fields.to_json
|
68
|
+
response = http.request(req)
|
69
|
+
receipt_process_response(response)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
57
73
|
def purchase_from_schema(gateway, schema)
|
58
74
|
purchase(gateway, fields_to_schema_defaults(schema))
|
59
75
|
end
|
@@ -81,5 +97,15 @@ class Hawese
|
|
81
97
|
end
|
82
98
|
fields
|
83
99
|
end
|
100
|
+
|
101
|
+
def receipt_process_response(response)
|
102
|
+
response_body = JSON.parse(response.body, symbolize_names: true)
|
103
|
+
|
104
|
+
case response.code
|
105
|
+
when '401' then raise(response_body)
|
106
|
+
when '200' then response_body
|
107
|
+
else raise(response_body[:error][:message])
|
108
|
+
end
|
109
|
+
end
|
84
110
|
end
|
85
111
|
end
|
data/lib/leanweb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leanweb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Freeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|