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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b22bd19fa8ee233967739f90119ba9159e36b5650f69a40ceb1aaf4283886e2
4
- data.tar.gz: 90b7d4524c3a098c0f497945b6905e134872070449a308129d6a089ab38d8462
3
+ metadata.gz: 39b5e1f0ee482056108e319e7c1231913d9cc2c34947b884176ee26214df40dd
4
+ data.tar.gz: 14d74a9dfec2e429cdc6f7f18099384b2d19162a1c3a0eb992f5d3ac3b7f9dfa
5
5
  SHA512:
6
- metadata.gz: 8ed16222d6590470b455d4dfb41657dc70716aee12f530faea840bfeab13b369e0fc2be5516bdbb06c21687f360aee9388495d7597689a6e17b6fdbb12a8bae1
7
- data.tar.gz: e535aed1df0e7727729e7dae40dc987ac33bc9ac5a1cfe64e9fdb98965c5810fa35488156102d81aea2aea0efa37d52e1aabe0f09bc084c06ec8ad1f44c2664b
6
+ metadata.gz: 4e771c230db541ff2f90b2e1178891a9d4cc341df303e457f8af55a6f80ebc6761a8f3cd9b88385405b0f29b41920c32792bb662daf3b76d73a4b79ec763f4dd
7
+ data.tar.gz: 2962469cbe01f0bd57645dfb997504f482e678ad7c1b02ba9d44281aaeec63bafc665fde208e218fc2829ae076f5e095d63e2c663936b808afbf518c541e193b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.3
4
+
5
+ - Add `LavendaPay::Payments::Confirm` to confirm a pending payment outside production.
6
+
3
7
  ## 0.0.2
4
8
 
5
9
  - Read settings from the `lavenda_pay` Rails credentials when the environment variable is not set.
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
@@ -0,0 +1,6 @@
1
+ module LavendaPay
2
+ class Payment < Resource
3
+ # Attributes: pid, status, and gateway_confirmation after a sandbox
4
+ # confirmation ("confirmed", "failed" or "unsupported").
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module LavendaPay
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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.13
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: []