mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Handle setting of payment amount during checkout in OrderUpdater
This commit is contained in:
@@ -35,6 +35,14 @@ module OrderManagement
|
||||
end
|
||||
|
||||
persist_totals
|
||||
update_pending_payment
|
||||
end
|
||||
|
||||
def update_pending_payment
|
||||
return unless order.state.in? ["payment", "confirmation"]
|
||||
return unless order.pending_payments.any?
|
||||
|
||||
order.pending_payments.first.update_attribute :amount, order.total
|
||||
end
|
||||
|
||||
# Updates the following Order total values:
|
||||
|
||||
@@ -165,6 +165,7 @@ describe SplitCheckoutController, type: :controller do
|
||||
|
||||
expect(order.state).to eq "confirmation"
|
||||
expect(order.payments.first.adjustment.amount).to eq 1.23
|
||||
expect(order.payments.first.amount).to eq order.item_total + order.adjustment_total
|
||||
expect(order.adjustment_total).to eq 1.23
|
||||
expect(order.total).to eq order.item_total + order.adjustment_total
|
||||
end
|
||||
|
||||
@@ -129,6 +129,8 @@ describe ProcessPaymentIntent do
|
||||
|
||||
it "completes the order, but with failed payment state recorded" do
|
||||
service.call!
|
||||
order.reload
|
||||
|
||||
expect(order.state).to eq("complete")
|
||||
expect(order.payment_state).to eq("failed")
|
||||
expect(order).to have_received(:deliver_order_confirmation_email)
|
||||
|
||||
Reference in New Issue
Block a user