Spree::Config[:always_include_confirm_step]
go_to_state :confirm, if: ->(order) { order.confirmation_required? }
if states[:payment]
before_transition :to => :complete do |order|
order.process_payments! if order.payment_required?
end
endAlso, as far as I have understood, it should be possible to send the user to a remote page belonging to the payment gateway (i.e. paypal) to login and allow the payment there and then - without actually paying - returning to the shops confirmation page.After confirmation here, the actual payment should be executed (via a token sent to the payment gateways API).Is this correct in principle? Do active merchant and or spree embrace this pattern?Axel
On 6 Dec 2013 at 10:32:36, Jonathan O'Connor (nink...@gmail.com) wrote:
Peter,I'm actually doing similar work on this now. You raise some issues I hadn't considered.I added a confirmed_at timestamp to the spree_orders table. I set this to the current time, when the accept AGBs ( == Terms and Conditions) checkbox is ticked.Then you know when they accepted the terms. The confirmation_required? method just returns confirmed_at.nil?If your gateway is doing an immediate payment, could you not add an accept terms and conditions checkbox to the payment page?Regards,
Jonathan
def accepts_agbs confirmed_at.present? end
def accepts_agbs=(value) self.confirmed_at = value == '1' ? Time.now : nil # This variable is set so that we run the validation for checking acceptance of the AGBs at validation time. # As this is only set here, it can only happen at the time when the order is updating from the confirm page. @requires_checking_agbs_accepted = true end
def confirmation_required? confirmed_at.nil? end
def ensure_agbs_accepted_at_confirm if @requires_checking_agbs_accepted && !accepts_agbs @requires_checking_agbs_accepted = false errors.add(:base, :must_accept)) end end
request+contains+no+creditcard%2C+bank+account+number+or+bank+name#<ActiveMerchant::Billing::MultiResponse:0x007fec89951bb8>
Gateway Error
--- !ruby/object:ActiveMerchant::Billing::MultiResponse
responses:
- !ruby/object:ActiveMerchant::Billing::Response
params:
transaction:
account:
bin: ''
brand: ''
expiry:
month: '01'
year: '2001'
holder: ''
number: "\r\n"
channel: 8a8394c48a83948b42ef22
address:
country: DE
contact:
ip: 78.99.00.99
ipCountry: de
identification:
shortId: 5664.9999.8098
uniqueId: 8a83948b42ef228a83948b42ef22
mode: LIVE
payment:
code: CC.RG
processing:
code: CC.RG.70.40
reason:
code: '40'
message: Account+Validation
result: NOK
return:
code: 100.100.100
message: request+contains+no+creditcard%2C+bank+account+number+or+bank+name
timestamp: 2013-12-16+12%3A52%3A47
response: SYNC
message: request+contains+no+creditcard%2C+bank+account+number+or+bank+name
success: false
test: false
authorization:
fraud_review:
avs_result:
code:
message:
street_match:
postal_match:
cvv_result:
code:
message:
primary_response: :last