diff --git a/app/models/spree/payment_method/taler.rb b/app/models/spree/payment_method/taler.rb index 5df12fe8a8..747015f048 100644 --- a/app/models/spree/payment_method/taler.rb +++ b/app/models/spree/payment_method/taler.rb @@ -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 diff --git a/spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/retrieves_a_URL_to_pay_at_and_stores_it_on_the_payment_record.yml b/spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/creates_an_order_reference_and_retrieves_a_URL_to_pay_at.yml similarity index 100% rename from spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/retrieves_a_URL_to_pay_at_and_stores_it_on_the_payment_record.yml rename to spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/creates_an_order_reference_and_retrieves_a_URL_to_pay_at.yml diff --git a/spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/retrieves_a_URL_to_pay_at.yml b/spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/retrieves_a_URL_to_pay_at.yml deleted file mode 100644 index 89a829b59d..0000000000 --- a/spec/fixtures/vcr_cassettes/Spree_PaymentMethod_Taler/_external_payment_url/retrieves_a_URL_to_pay_at.yml +++ /dev/null @@ -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: - - "" - 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: - - "" - 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 diff --git a/spec/models/spree/payment_method/taler_spec.rb b/spec/models/spree/payment_method/taler_spec.rb index fb314043b1..176c8aecc0 100644 --- a/spec/models/spree/payment_method/taler_spec.rb +++ b/spec/models/spree/payment_method/taler_spec.rb @@ -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 diff --git a/spec/system/consumer/checkout/payment_spec.rb b/spec/system/consumer/checkout/payment_spec.rb index 207e2268c1..da6e7bc1a5 100644 --- a/spec/system/consumer/checkout/payment_spec.rb +++ b/spec/system/consumer/checkout/payment_spec.rb @@ -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"