mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Stop storing now redundant redirect URL
The Taler gem now computes it from the order id. No need to store it.
This commit is contained in:
@@ -38,10 +38,9 @@ module Spree
|
||||
|
||||
payment.source ||= self
|
||||
payment.response_code ||= create_taler_order(payment)
|
||||
payment.redirect_auth_url ||= taler_order.status_url
|
||||
payment.save! if payment.changed?
|
||||
|
||||
payment.redirect_auth_url
|
||||
taler_order.status_url
|
||||
end
|
||||
|
||||
# Main method called by Spree::Payment::Processing during checkout
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: https://backend.demo.taler.net/instances/sandbox/private/orders
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"order":{"amount":"KUDOS:5","summary":"OFN Order","fulfillment_url":"https://ofn.example.net"},"create_token":false}'
|
||||
headers:
|
||||
Authorization:
|
||||
- "<HIDDEN-AUTHORIZATION-HEADER>"
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- Taler Ruby
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx/1.26.3
|
||||
Date:
|
||||
- Thu, 15 Jan 2026 04:18:27 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '42'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- "*"
|
||||
Cache-Control:
|
||||
- no-store
|
||||
Via:
|
||||
- 1.1 Caddy
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: |-
|
||||
{
|
||||
"order_id": "2026.015-02T676V4VARMT"
|
||||
}
|
||||
recorded_at: Thu, 15 Jan 2026 04:18:28 GMT
|
||||
- request:
|
||||
method: get
|
||||
uri: https://backend.demo.taler.net/instances/sandbox/private/orders/2026.015-02T676V4VARMT
|
||||
body:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
Authorization:
|
||||
- "<HIDDEN-AUTHORIZATION-HEADER>"
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- Taler Ruby
|
||||
Accept-Encoding:
|
||||
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Server:
|
||||
- nginx/1.26.3
|
||||
Date:
|
||||
- Thu, 15 Jan 2026 04:18:29 GMT
|
||||
Content-Type:
|
||||
- application/json
|
||||
Content-Length:
|
||||
- '336'
|
||||
Connection:
|
||||
- keep-alive
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Access-Control-Expose-Headers:
|
||||
- "*"
|
||||
Cache-Control:
|
||||
- no-store
|
||||
Via:
|
||||
- 1.1 Caddy
|
||||
Strict-Transport-Security:
|
||||
- max-age=63072000; includeSubDomains; preload
|
||||
body:
|
||||
encoding: ASCII-8BIT
|
||||
string: |-
|
||||
{
|
||||
"taler_pay_uri": "taler://pay/backend.demo.taler.net/instances/sandbox/2026.015-02T676V4VARMT/",
|
||||
"order_status_url": "https://backend.demo.taler.net/instances/sandbox/orders/2026.015-02T676V4VARMT",
|
||||
"order_status": "unpaid",
|
||||
"total_amount": "KUDOS:5",
|
||||
"summary": "OFN Order",
|
||||
"creation_time": {
|
||||
"t_s": 1768450707
|
||||
}
|
||||
}
|
||||
recorded_at: Thu, 15 Jan 2026 04:18:29 GMT
|
||||
recorded_with: VCR 6.3.1
|
||||
@@ -12,14 +12,14 @@ RSpec.describe Spree::PaymentMethod::Taler do
|
||||
let(:backend_url) { "https://backend.demo.taler.net/instances/sandbox" }
|
||||
|
||||
describe "#external_payment_url", vcr: true do
|
||||
it "retrieves a URL to pay at and stores it on the payment record" do
|
||||
it "creates an order reference and retrieves a URL to pay at" do
|
||||
order = create(:order_ready_for_confirmation, payment_method: taler)
|
||||
|
||||
url = subject.external_payment_url(order:)
|
||||
expect(url).to start_with backend_url
|
||||
expect(url).to eq "#{backend_url}/orders/2026.022-0284X4GE8WKMJ"
|
||||
|
||||
payment = order.payments.last.reload
|
||||
expect(payment.response_code).to match "2026.022-0284X4GE8WKMJ"
|
||||
expect(payment.redirect_auth_url).to eq url
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -358,13 +358,13 @@ RSpec.describe "As a consumer, I want to checkout my order" do
|
||||
.to receive(:create).and_return(taler_order_id)
|
||||
|
||||
# And fake the payment status to avoid user interaction.
|
||||
allow_any_instance_of(Taler::Client)
|
||||
.to receive(:fetch_order) do
|
||||
allow_any_instance_of(Taler::Order)
|
||||
.to receive(:status_url) do
|
||||
payment = Spree::Payment.last
|
||||
url = payment_gateways_confirm_taler_path(payment_id: payment.id)
|
||||
|
||||
{ "order_status_url" => url, "order_status" => "paid" }
|
||||
payment_gateways_confirm_taler_path(payment_id: payment.id)
|
||||
end
|
||||
allow_any_instance_of(Taler::Order)
|
||||
.to receive(:fetch).with("order_status").and_return("paid")
|
||||
end
|
||||
|
||||
it_behaves_like "different payment methods", "Taler"
|
||||
|
||||
Reference in New Issue
Block a user