Sha256: ad27f640a52d6b3c449af9279a985c3c5c916e3af7c8ad8737bfbb66ed2ddb37
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module SolidusStripe class PaymentRequestController < Spree::BaseController include Spree::Core::ControllerHelpers::Order def shipping_rates rates = SolidusStripe::ShippingRatesService.new( current_order, spree_current_user, params[:shipping_address] ).call if rates.any? render json: { success: true, shipping_rates: rates } else render json: { success: false, error: 'No shipping method available for that address' }, status: 500 end end def update_order current_order.restart_checkout_flow address = SolidusStripe::AddressFromParamsService.new( shipping_address_from_params, spree_current_user ).call if address.valid? SolidusStripe::PrepareOrderForPaymentService.new(address, self).call if current_order.payment? render json: { success: true } else render json: { success: false, error: 'Order not ready for payment. Try manual checkout.' }, status: 500 end else render json: { success: false, error: address.errors.full_messages.to_sentence }, status: 500 end end private def shipping_address_from_params return {} unless params[:shipping_address] return params[:shipping_address] if params.dig(:shipping_address, :phone).present? params[:shipping_address][:phone] = params[:phone] params[:shipping_address] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_stripe-4.3.0 | app/controllers/solidus_stripe/payment_request_controller.rb |