16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/solidus_graphql_api/mutations/checkout/add_payment_to_checkout.rb', line 16
def resolve(payment_method:, source:, amount: nil)
current_order.update(state: :payment)
update_params = {
payments_attributes: [{
payment_method_id: payment_method.id,
amount: amount || current_order.total,
source_attributes: source
}]
}
if Spree::OrderUpdateAttributes.new(current_order, update_params).apply
current_order.recalculate
errors = []
else
errors = current_order.errors
end
{ errors: user_errors('order', errors), order: current_order }
end
|