Class: SolidusPaypalCommercePlatform::PaymentMethod
- Inherits:
-
Spree::PaymentMethod
- Object
- Spree::PaymentMethod
- SolidusPaypalCommercePlatform::PaymentMethod
show all
- Includes:
- ButtonOptionsHelper
- Defined in:
- app/models/solidus_paypal_commerce_platform/payment_method.rb
Instance Method Summary
collapse
#preferred_paypal_button_color_options, #preferred_paypal_button_layout_options, #preferred_paypal_button_shape_options, #preferred_paypal_button_size_options, #preferred_venmo_standalone_options
Instance Method Details
69
70
71
72
73
74
75
76
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 69
def button_style
{
color: options[:paypal_button_color] || "gold",
size: options[:paypal_button_size] || "responsive",
shape: options[:paypal_button_shape] || "rect",
layout: options[:paypal_button_layout] || "vertical"
}
end
|
#cart_partial_name ⇒ Object
41
42
43
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 41
def cart_partial_name
"paypal_commerce_platform"
end
|
#client_id ⇒ Object
53
54
55
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 53
def client_id
options[:client_id]
end
|
#client_secret ⇒ Object
57
58
59
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 57
def client_secret
options[:client_secret]
end
|
#display_on_cart ⇒ Object
37
38
39
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 37
def display_on_cart
options[:display_on_cart] || false
end
|
#display_on_product_page ⇒ Object
45
46
47
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 45
def display_on_product_page
options[:display_on_product_page] || false
end
|
#gateway_class ⇒ Object
65
66
67
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 65
def gateway_class
Gateway
end
|
#javascript_sdk_url(order: nil, currency: nil) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 78
def javascript_sdk_url(order: nil, currency: nil)
step_names = order ? order.checkout_steps : ::Spree::Order.checkout_steps.keys
commit_immediately = step_names.include? "confirm"
parameters = {
'client-id': client_id,
intent: auto_capture? ? "capture" : "authorize",
commit: commit_immediately ? "false" : "true",
components: options[:display_credit_messaging] ? "buttons,messages" : "buttons",
currency: currency,
}
parameters['enable-funding'] = 'venmo' if venmo_standalone_enabled?
unless Rails.env.production?
parameters['buyer-country'] = options[:force_buyer_country].presence
end
"https://www.paypal.com/sdk/js?#{parameters.compact.to_query}".html_safe end
|
#partial_name ⇒ Object
33
34
35
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 33
def partial_name
"paypal_commerce_platform"
end
|
#payment_source_class ⇒ Object
61
62
63
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 61
def payment_source_class
PaymentSource
end
|
#product_page_partial_name ⇒ Object
49
50
51
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 49
def product_page_partial_name
"paypal_commerce_platform"
end
|
#render_only_venmo_standalone? ⇒ Boolean
29
30
31
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 29
def render_only_venmo_standalone?
options[:venmo_standalone] == 'render only standalone'
end
|
#try_void(payment) ⇒ Response|FalseClass
113
114
115
116
117
118
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 113
def try_void(payment)
void_attempt = void(nil, { originator: payment })
return void_attempt if void_attempt.success?
false
end
|
#venmo_standalone_enabled? ⇒ Boolean
25
26
27
|
# File 'app/models/solidus_paypal_commerce_platform/payment_method.rb', line 25
def venmo_standalone_enabled?
options[:venmo_standalone] != 'disabled'
end
|