Class: Spree::PaymentCreate
- Inherits:
-
Object
- Object
- Spree::PaymentCreate
- Defined in:
- app/models/spree/payment_create.rb
Overview
Service object for creating new payments on an Order
Instance Method Summary collapse
-
#build ⇒ Payment
Build the new Payment.
-
#initialize(order, attributes, payment: nil, request_env: {}) ⇒ PaymentCreate
constructor
A new instance of PaymentCreate.
Constructor Details
#initialize(order, attributes, payment: nil, request_env: {}) ⇒ PaymentCreate
Returns a new instance of PaymentCreate.
13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/spree/payment_create.rb', line 13 def initialize(order, attributes, payment: nil, request_env: {}) @order = order @payment = payment # If AC::Params are passed in, attributes.to_h gives us a hash of only # the permitted attributes. @attributes = attributes.to_h.with_indifferent_access @source_attributes = @attributes.delete(:source_attributes) || {} @request_env = request_env end |
Instance Method Details
#build ⇒ Payment
Build the new Payment
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/spree/payment_create.rb', line 26 def build @payment ||= order.payments.new @payment.request_env = @request_env if @request_env @payment.attributes = @attributes if source_attributes[:wallet_payment_source_id].present? build_from_wallet_payment_source else build_source end @payment end |