app/models/solidus/gateway/culqi_gateway.rb in solidus_culqi-0.1.1 vs app/models/solidus/gateway/culqi_gateway.rb in solidus_culqi-1.0.0
- old
+ new
@@ -1,17 +1,20 @@
# frozen_string_literal: true
module Solidus
- class Gateway::CulqiGateway < SolidusCulqi::Gateway.parent_class
- extend SolidusCulqi::Gateway
-
+ class Gateway::CulqiGateway < Spree::PaymentMethod::CreditCard
preference :public_key, :string
preference :secret_key, :string
- partial_method 'culqi'
- provider_method self.class
+ def partial_name
+ 'culqi'
+ end
+ def gateway_class
+ self.class
+ end
+
def default_currency
"PEN"
end
def authorize(amount, creditcard, gateway_options)
@@ -57,14 +60,14 @@
init_culqi
customer = get_customer(payment)
token = payment.source.gateway_payment_profile_id
card_token = generate_card(customer, token)
unless customer.nil? || card_token.nil?
- payment.source.update({
+ payment.source.update(
gateway_customer_profile_id: customer,
gateway_payment_profile_id: card_token
- })
+ )
end
end
private
@@ -72,10 +75,10 @@
Culqi.public_key = preferred_public_key
Culqi.secret_key = preferred_secret_key
end
def commit(amount, creditcard, gateway_options, capture)
- installments = gateway_options[:installments]
+ installments = gateway_options.try(:installments)
authorization = creditcard[:gateway_payment_profile_id]
charge = Culqi::Charge.create(
amount: amount,
capture: capture,
currency_code: default_currency,