afconwave 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/afconwave/version.rb +1 -1
- data/lib/afconwave.rb +11 -4
- 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: fb281596c1b5976830370d1ab76c8ef17a9e6888d2d5dcf7df871a2dbd8e3bf1
|
|
4
|
+
data.tar.gz: 8c572ca0ea4dfd2be834877c5cff05f01d7f1e1bddf87ac80237e108e65bd535
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74eb3bb6fe7f48eab3721a3b7b162d21c83db35937f967eccea0169a3f4ef0d4e63085dcfe34a3d756acf4f26721c7a0fab52a85a79ab82ce40369c77a29dbfe
|
|
7
|
+
data.tar.gz: 6e016cfd71ca8cad08b2b55e623e795aae2a2927a12af52dca598222aa2b99479d0ee7aa225cf059c7238aa2c07ef64c0aa64aca628a54b369dcead926ec0366
|
data/lib/afconwave/version.rb
CHANGED
data/lib/afconwave.rb
CHANGED
|
@@ -29,13 +29,15 @@ module AfconWave
|
|
|
29
29
|
class Client
|
|
30
30
|
attr_accessor :secret_key, :base_url, :timeout
|
|
31
31
|
|
|
32
|
-
def initialize(secret_key:, base_url: 'https://api.afconwave.com/
|
|
32
|
+
def initialize(secret_key:, base_url: 'https://api.afconwave.com/v1', timeout: 30)
|
|
33
33
|
@secret_key = secret_key
|
|
34
34
|
@base_url = base_url
|
|
35
35
|
@timeout = timeout
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def self.verify_webhook_signature(payload:, signature:, secret:, tolerance: 300)
|
|
39
|
+
return false if signature.nil? || secret.nil?
|
|
40
|
+
|
|
39
41
|
# 1. Verify Signature (timing-safe compare via OpenSSL stdlib)
|
|
40
42
|
expected = OpenSSL::HMAC.hexdigest('sha256', secret, payload)
|
|
41
43
|
|
|
@@ -46,9 +48,12 @@ module AfconWave
|
|
|
46
48
|
# 2. Verify Timestamp (Replay Protection)
|
|
47
49
|
begin
|
|
48
50
|
data = JSON.parse(payload)
|
|
49
|
-
|
|
51
|
+
timestamp = data['timestamp'] || data['created_at'] || data['createdAt']
|
|
52
|
+
|
|
53
|
+
if timestamp
|
|
50
54
|
current_time = Time.now.to_i # seconds
|
|
51
|
-
|
|
55
|
+
# Handle both ms and seconds
|
|
56
|
+
webhook_time = timestamp > 10**10 ? timestamp / 1000 : timestamp
|
|
52
57
|
age = (current_time - webhook_time).abs
|
|
53
58
|
|
|
54
59
|
return false if age > tolerance
|
|
@@ -88,6 +93,7 @@ module AfconWave
|
|
|
88
93
|
req['Authorization'] = "Bearer #{secret_key}"
|
|
89
94
|
req['Content-Type'] = 'application/json'
|
|
90
95
|
req['Accept'] = 'application/json'
|
|
96
|
+
req['User-Agent'] = "AfconWave-Ruby-SDK/1.1.0"
|
|
91
97
|
|
|
92
98
|
response = http.request(req)
|
|
93
99
|
res_data = JSON.parse(response.body) rescue { 'error' => 'Invalid JSON response' }
|
|
@@ -102,8 +108,9 @@ module AfconWave
|
|
|
102
108
|
res_data['data'] || res_data
|
|
103
109
|
end
|
|
104
110
|
|
|
105
|
-
# ─── Top-level Convenience Methods
|
|
111
|
+
# ─── Top-level Convenience Methods ───────────────────────────────────────
|
|
106
112
|
|
|
113
|
+
def get_balances; request(method: 'GET', path: '/balances'); end
|
|
107
114
|
def create_payment(**data); payments.create(**data); end
|
|
108
115
|
def retrieve_payment(id); payments.retrieve(id); end
|
|
109
116
|
def list_payments(**params); payments.list(**params); end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: afconwave
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- AfconWave Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Integrate AfconWave payments, payouts, and refunds into your Ruby or
|
|
14
14
|
Rails applications.
|