Class: Spree::BillingIntegration::PaypalExpressBase
- Inherits:
-
Spree::BillingIntegration
- Object
- Spree::BillingIntegration
- Spree::BillingIntegration::PaypalExpressBase
show all
- Defined in:
- app/models/spree/billing_integration/paypal_express_base.rb
Instance Method Summary
collapse
Instance Method Details
#amount_in_cents(amount) ⇒ Object
58
59
60
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 58
def amount_in_cents(amount)
(100 * amount).to_i
end
|
#capture(payment_or_amount, account_or_response_code, gateway_options) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 20
def capture(payment_or_amount, account_or_response_code, gateway_options)
if payment_or_amount.is_a?(Spree::Payment)
authorization = find_authorization(payment_or_amount)
provider.capture(amount_in_cents(payment_or_amount.amount), authorization.params["transaction_id"], :currency => preferred_currency)
else
provider.capture(payment_or_amount, account_or_response_code, :currency => preferred_currency)
end
end
|
#credit(*args) ⇒ Object
29
30
31
32
33
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 29
def credit(*args)
amount = args.shift
response_code = args.first.is_a?(String) ? args.first : args[1]
provider.credit(amount, response_code, :currency => preferred_currency)
end
|
#find_authorization(payment) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 35
def find_authorization(payment)
logs = payment.log_entries.all(:order => 'created_at DESC')
logs.each do |log|
details = YAML.load(log.details) if (details.params['payment_status'] == 'Pending' && details.params['pending_reason'] == 'authorization')
return details
end
end
return nil
end
|
#find_capture(payment) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 46
def find_capture(payment)
logs = payment.log_entries.all(:order => 'created_at DESC')
logs.each do |log|
details = YAML.load(log.details) if details.params['payment_status'] == 'Completed'
return details
end
end
return nil
end
|
#payment_profiles_supported? ⇒ Boolean
16
17
18
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 16
def payment_profiles_supported?
!!preferred_review
end
|
#provider_class ⇒ Object
12
13
14
|
# File 'app/models/spree/billing_integration/paypal_express_base.rb', line 12
def provider_class
ActiveMerchant::Billing::PaypalExpressGateway
end
|