.medium-6#checkout-payment-methods
  - if @order.distributor.vouchers.present?
    %div.checkout-substep
      = render partial: "checkout/voucher_section", locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }

  = form_with url: checkout_update_path(local_assigns[:step] || checkout_step), model: @order, method: :put, data: { remote: "true" } do |f|
    %div.checkout-substep{"data-controller": "paymentmethod"}
      %div.checkout-title
        = t("checkout.step2.payment_method.title")

      - if @order.zero_priced_order?
        %h3= t(:no_payment_required)
        = hidden_field_tag "order[payments_attributes][][amount]", 0
      - else
        - selected_payment_method = @order.payments&.with_state(:checkout)&.first&.payment_method_id
        - selected_payment_method ||= available_payment_methods[0].id if available_payment_methods.length == 1
        - available_payment_methods.each do |payment_method|
          %div.checkout-input.checkout-input-radio
            = f.radio_button :payment_method_id, payment_method.id,
              id: "payment_method_#{payment_method.id}",
              name: "order[payments_attributes][][payment_method_id]",
              checked: (payment_method.id == selected_payment_method),
              "data-action": "paymentmethod#selectPaymentMethod",
              "data-paymentmethod-id": "#{payment_method.id}",
              "data-paymentmethod-target": "input"
            = f.label :payment_method_id, "#{payment_method.name}", for: "payment_method_#{payment_method.id}"
            %em.fees=payment_or_shipping_price(payment_method, @order)

          .paymentmethod-container{"data-paymentmethod-id": "#{payment_method.id}", style: "display: #{payment_method.id == selected_payment_method ? "block" : "none"}"}
            - if payment_method.description && !payment_method.description.empty?
              .paymentmethod-description.panel
                #{payment_method.description}
            .paymentmethod-form
              = render partial: "checkout/payment/#{payment_method.method_type}", locals: { payment_method: payment_method, f: f }

        = f.error_message_on :payment_method, standalone: true

    %div.checkout-substep
      = t("checkout.step2.explaination")

    %div.checkout-submit
      = f.submit t("checkout.step2.submit"), class: "button primary", disabled: @terms_and_conditions_accepted == false || @platform_tos_accepted == false
      %a.button.cancel{href: main_app.checkout_step_path(:details)}
        = t("checkout.step2.cancel")
