Class: PaymentMethod::SisowBilling
- Inherits:
-
PaymentMethod
- Object
- PaymentMethod
- PaymentMethod::SisowBilling
show all
- Defined in:
- app/models/spree/payment_method/sisow_billing/creditcard.rb,
app/models/spree/payment_method/sisow_billing/bancontact.rb,
app/models/spree/payment_method/sisow_billing/paypalec.rb,
app/models/spree/payment_method/sisow_billing/sofort.rb,
app/models/spree/payment_method/sisow_billing/ideal.rb,
app/models/spree/payment_method/sisow_billing.rb
Defined Under Namespace
Classes: Bancontact, Creditcard, Ideal, Paypalec, Sofort
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SisowBilling.
4
5
6
7
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 4
def initialize(order)
@order = order
PaymentMethod::SisowBilling.configure
end
|
Class Method Details
75
76
77
78
79
80
81
82
83
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 75
def self.configure
Sisow.configure do |config|
config.merchant_id = Spree::Config.sisow_merchant_id
config.merchant_key = Spree::Config.sisow_merchant_key
config.test_mode = Spree::Config.sisow_test_mode
config.debug_mode = Spree::Config.sisow_debug_mode
end
HTTPI.logger = logger
end
|
Instance Method Details
#cancelled? ⇒ Boolean
19
20
21
22
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 19
def cancelled?
return false unless @payment
@payment.void?
end
|
#failed? ⇒ Boolean
14
15
16
17
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 14
def failed?
return true unless @payment
@payment.failed?
end
|
#process_response(response) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 24
def process_response(response)
if @order.payments.where(:source_type => 'Spree::SisowTransaction').present?
initialize_callback(response)
if @callback.valid?
@sisow_transaction.update_attributes(
status: @callback.status,
sha1: @callback.sha1)
@payment = @order.payments.where(
amount: @order.total,
source_id: @sisow_transaction,
payment_method_id: payment_method).first
if @callback.cancelled? && !@payment.void?
cancel_payment
end
end
end
end
|
#start_transaction(transaction_type, opts = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 46
def start_transaction(transaction_type, opts = {})
@sisow_transaction = SisowTransaction.create(
transaction_type: transaction_type,
status: "pending")
@payment = @order.payments.create(amount: @order.total,
source: @sisow_transaction,
payment_method: payment_method)
@sisow_transaction.update(entrance_code: @payment.number)
opts[:description] = "#{Spree::Store.current.name} - Order: #{@order.number}"
opts[:purchase_id] = @order.number
opts[:amount] = (@order.total * 100).to_i
opts[:entrance_code] = @payment.number
sisow = payment_provider(transaction_type, opts)
@sisow_transaction.update_attributes(
transaction_id: sisow.transaction_id,
entrance_code: @payment.number)
sisow.payment_url
end
|
#success? ⇒ Boolean
9
10
11
12
|
# File 'app/models/spree/payment_method/sisow_billing.rb', line 9
def success?
return false unless @payment
(@payment.completed? && @order.completed?)
end
|