pay-asaas 0.1.0 → 0.1.2
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/CHANGELOG.md +9 -0
- data/README.md +24 -5
- data/lib/pay/asaas/charge.rb +10 -7
- data/lib/pay/asaas/client.rb +2 -2
- data/lib/pay/asaas/version.rb +1 -1
- data/lib/pay/asaas/webhooks/payment_sync.rb +0 -2
- 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: f9c0abf056f9632fcf2ae9d5d4e0ac9af92bc7254d1697eae95fa24fd27b4bf2
|
4
|
+
data.tar.gz: e230f47f0a38676111d70e4f29481882733d0f24f534dc59424b474a9375fa10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30cd84ebd3a4414a13bdbf6804f5077f80ec0c927599316dfa9dd97e084f7afb7ee700f963599e70fd70fa9e93f95af1d1bbc9c468c68a3fd2afa9b09baaefae
|
7
|
+
data.tar.gz: 5d2d0f029d5a459621b6453cae9de0b8f8badf2720f419a7c601673ffc4c64c471e3f523bddad645242afb23ba6ca1e51ea0e53c82675d839cf68996fecc73f0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.2] - 2025-06-17
|
4
|
+
|
5
|
+
- Fixes credentials configuration for api key and api url
|
6
|
+
|
7
|
+
## [0.1.1] - 2025-06-13
|
8
|
+
|
9
|
+
- Fixes payment sync in webhooks
|
10
|
+
- Does not create charge the not exists inside the webhook processor
|
11
|
+
|
3
12
|
## [0.1.0] - 2024-12-26
|
4
13
|
|
5
14
|
- Initial release
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ bundle add pay-asaas;
|
|
37
37
|
```yml
|
38
38
|
asaas:
|
39
39
|
api_key: xxxx
|
40
|
-
api_url: https://sandbox.asaas.com/
|
40
|
+
api_url: https://api-sandbox.asaas.com/v3 # or https://api.asaas.com/v3
|
41
41
|
webhook_access_key: xxxx
|
42
42
|
```
|
43
43
|
|
@@ -72,16 +72,35 @@ This first version of the gem will only support PIX payments.
|
|
72
72
|
|
73
73
|
## Webhooks
|
74
74
|
|
75
|
-
The gem
|
75
|
+
The gem provides a built-in controller to handle webhooks from Asaas. These webhooks are essential for keeping your payment records in sync with Asaas's systems.
|
76
76
|
|
77
|
-
|
78
|
-
domain:
|
77
|
+
### Configuration
|
79
78
|
|
80
|
-
|
79
|
+
To configure webhooks in your Asaas dashboard, use the following URL (replace `example.org` with your domain):
|
80
|
+
|
81
|
+
- **Asaas Webhook URL**: `https://example.org/pay/webhooks/asaas`
|
82
|
+
|
83
|
+
### Supported Events
|
84
|
+
|
85
|
+
The main goal of the webhooks right now is to sync payment statuses.
|
81
86
|
|
82
87
|
> For now we listen to the events that are important for pix transactions. For more configuration options
|
83
88
|
> see: https://github.com/pay-rails/pay/blob/main/docs/7_webhooks.md
|
84
89
|
|
90
|
+
### Verify Webhooks
|
91
|
+
|
92
|
+
All incoming webhooks from Asaas will be verified using the `webhook_access_key` provided in the gem configuration.
|
93
|
+
|
94
|
+
## Debugging
|
95
|
+
|
96
|
+
To debug HTTP requests made by our gem, which uses the httparty library, you can enable logging of all outgoing HTTP calls. Just add the following line to one of your initializers:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
HTTParty::Basement.debug_output($stdout)
|
100
|
+
```
|
101
|
+
|
102
|
+
This will print the full request and response details to the console, making it easier to troubleshoot issues during development.
|
103
|
+
|
85
104
|
## Development
|
86
105
|
|
87
106
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
|
data/lib/pay/asaas/charge.rb
CHANGED
@@ -10,27 +10,30 @@ module Pay
|
|
10
10
|
def self.sync(charge_id, object: nil, try: 0, retries: 1)
|
11
11
|
object ||= Pay::Asaas::Api::Payment.find(id: charge_id)
|
12
12
|
|
13
|
-
|
13
|
+
customer_processor_id = get_attribute(object, :customer)
|
14
|
+
charge_processor_id = get_attribute(object, :id)
|
15
|
+
pay_customer = Pay::Customer.find_by(processor: :asaas, processor_id: customer_processor_id)
|
16
|
+
|
17
|
+
# rubocop:disable Layout/LineLength
|
14
18
|
if pay_customer.blank?
|
15
19
|
Rails.logger.debug do
|
16
|
-
"Pay::Customer #{
|
20
|
+
"Pay::Customer #{customer_processor_id} is not in the database while syncing Asaas Charge #{charge_processor_id}"
|
17
21
|
end
|
18
22
|
return
|
19
23
|
end
|
24
|
+
# rubocop:enable Layout/LineLength
|
20
25
|
|
21
26
|
attrs = {
|
22
27
|
amount: get_attribute(object, :value).to_f * 100,
|
23
28
|
status: get_attribute(object, :status),
|
24
29
|
}
|
25
30
|
|
26
|
-
# Update
|
27
|
-
if (pay_charge = pay_customer.charges.find_by(processor_id:
|
31
|
+
# Update the charge
|
32
|
+
if (pay_charge = pay_customer.charges.find_by(processor_id: charge_processor_id))
|
28
33
|
pay_charge.with_lock do
|
29
34
|
pay_charge.update!(attrs)
|
30
35
|
end
|
31
36
|
pay_charge
|
32
|
-
else
|
33
|
-
pay_customer.charges.create!(attrs.merge(processor_id: object.id))
|
34
37
|
end
|
35
38
|
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
36
39
|
try += 1
|
@@ -56,7 +59,7 @@ module Pay
|
|
56
59
|
end
|
57
60
|
|
58
61
|
def refund!(amount_to_refund)
|
59
|
-
raise NotImplementedError, "Refunding charges is not supported yet by the Asaas
|
62
|
+
raise NotImplementedError, "Refunding charges is not supported yet by the Asaas processor"
|
60
63
|
end
|
61
64
|
|
62
65
|
def sync_pix_qr_code
|
data/lib/pay/asaas/client.rb
CHANGED
@@ -10,8 +10,8 @@ module Pay::Asaas
|
|
10
10
|
attr_accessor :api_key, :base_url
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@api_key =
|
14
|
-
@base_url =
|
13
|
+
@api_key = Pay::Asaas.api_key
|
14
|
+
@base_url = Pay::Asaas.api_url || "https://sandbox.asaas.com/api/v3"
|
15
15
|
end
|
16
16
|
|
17
17
|
def validate!
|
data/lib/pay/asaas/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pay-asaas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PedroAugustoRamalhoDuarte
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-06-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|