lavenda-pay-ruby 0.0.2 → 0.0.3
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 +4 -0
- data/README.md +13 -0
- data/lib/lavenda_pay/payments/confirm.rb +16 -0
- data/lib/lavenda_pay/resources/payment.rb +6 -0
- data/lib/lavenda_pay/version.rb +1 -1
- data/lib/lavenda_pay.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39b5e1f0ee482056108e319e7c1231913d9cc2c34947b884176ee26214df40dd
|
|
4
|
+
data.tar.gz: 14d74a9dfec2e429cdc6f7f18099384b2d19162a1c3a0eb992f5d3ac3b7f9dfa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e771c230db541ff2f90b2e1178891a9d4cc341df303e457f8af55a6f80ebc6761a8f3cd9b88385405b0f29b41920c32792bb662daf3b76d73a4b79ec763f4dd
|
|
7
|
+
data.tar.gz: 2962469cbe01f0bd57645dfb997504f482e678ad7c1b02ba9d44281aaeec63bafc665fde208e218fc2829ae076f5e095d63e2c663936b808afbf518c541e193b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -88,6 +88,19 @@ LavendaPay::Orders::Find.call(order.pid)
|
|
|
88
88
|
LavendaPay::Url.order_path(order.pid) # => "https://pay.example.com/orders/order_..."
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
## Payments
|
|
92
|
+
|
|
93
|
+
Sandbox only: confirm a pending payment as if the customer had paid it, to test your payment flow
|
|
94
|
+
end to end. LavendaPay marks it as paid and, when the gateway supports it, confirms it there too.
|
|
95
|
+
The endpoint does not exist in production, where it raises `LavendaPay::NotFoundError`.
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
# The payment pid comes from the payment outcome webhooks.
|
|
99
|
+
payment = LavendaPay::Payments::Confirm.call("pay_...")
|
|
100
|
+
payment.status # => "paid"
|
|
101
|
+
payment.gateway_confirmation # => "confirmed", "failed" or "unsupported"
|
|
102
|
+
```
|
|
103
|
+
|
|
91
104
|
## Errors
|
|
92
105
|
|
|
93
106
|
Non-2xx responses raise a `LavendaPay::ApiError` subclass exposing `status`, `body` and `errors`:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module LavendaPay
|
|
2
|
+
module Payments
|
|
3
|
+
# Sandbox only: marks a pending payment as paid, and confirms it on the
|
|
4
|
+
# gateway when the gateway supports it. Production answers 404 (NotFoundError).
|
|
5
|
+
#
|
|
6
|
+
# LavendaPay::Payments::Confirm.call("pay_...") # => LavendaPay::Payment
|
|
7
|
+
class Confirm < Operation
|
|
8
|
+
def call(pid)
|
|
9
|
+
body = http.post("/v1/payments/#{escape(pid)}/confirmation")
|
|
10
|
+
gateway_confirmation = body.dig("meta", "gateway_confirmation")
|
|
11
|
+
|
|
12
|
+
Payment.new((body["payment"] || body).merge("gateway_confirmation" => gateway_confirmation))
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/lavenda_pay/version.rb
CHANGED
data/lib/lavenda_pay.rb
CHANGED
|
@@ -5,6 +5,7 @@ require_relative "lavenda_pay/http"
|
|
|
5
5
|
require_relative "lavenda_pay/resource"
|
|
6
6
|
require_relative "lavenda_pay/resources/customer"
|
|
7
7
|
require_relative "lavenda_pay/resources/order"
|
|
8
|
+
require_relative "lavenda_pay/resources/payment"
|
|
8
9
|
require_relative "lavenda_pay/client"
|
|
9
10
|
require_relative "lavenda_pay/operation"
|
|
10
11
|
require_relative "lavenda_pay/customers/create"
|
|
@@ -13,6 +14,7 @@ require_relative "lavenda_pay/customers/list"
|
|
|
13
14
|
require_relative "lavenda_pay/customers/find_by"
|
|
14
15
|
require_relative "lavenda_pay/orders/create"
|
|
15
16
|
require_relative "lavenda_pay/orders/find"
|
|
17
|
+
require_relative "lavenda_pay/payments/confirm"
|
|
16
18
|
require_relative "lavenda_pay/url"
|
|
17
19
|
require_relative "lavenda_pay/webhooks"
|
|
18
20
|
require_relative "lavenda_pay/engine" if defined?(Rails::Engine)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lavenda-pay-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- La Venda Software
|
|
@@ -118,9 +118,11 @@ files:
|
|
|
118
118
|
- lib/lavenda_pay/operation.rb
|
|
119
119
|
- lib/lavenda_pay/orders/create.rb
|
|
120
120
|
- lib/lavenda_pay/orders/find.rb
|
|
121
|
+
- lib/lavenda_pay/payments/confirm.rb
|
|
121
122
|
- lib/lavenda_pay/resource.rb
|
|
122
123
|
- lib/lavenda_pay/resources/customer.rb
|
|
123
124
|
- lib/lavenda_pay/resources/order.rb
|
|
125
|
+
- lib/lavenda_pay/resources/payment.rb
|
|
124
126
|
- lib/lavenda_pay/url.rb
|
|
125
127
|
- lib/lavenda_pay/version.rb
|
|
126
128
|
- lib/lavenda_pay/webhooks.rb
|
|
@@ -151,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
153
|
- !ruby/object:Gem::Version
|
|
152
154
|
version: '0'
|
|
153
155
|
requirements: []
|
|
154
|
-
rubygems_version: 4.0.
|
|
156
|
+
rubygems_version: 4.0.22
|
|
155
157
|
specification_version: 4
|
|
156
158
|
summary: Ruby client for the Lavenda Pay payments API.
|
|
157
159
|
test_files: []
|