Class: Gateway::CulqiGateway
- Inherits:
-
Spree::PaymentMethod::CreditCard
- Object
- Spree::PaymentMethod::CreditCard
- Gateway::CulqiGateway
- Defined in:
- app/models/solidus/gateway/culqi_gateway.rb
Instance Method Summary collapse
- #authorize(amount, creditcard, gateway_options) ⇒ Object
- #capture(_amount, response_code, _gateway_options) ⇒ Object
- #create_profile(payment) ⇒ Object
- #credit(amount, _creditcard, response_code, _gateway_options) ⇒ Object
- #default_currency ⇒ Object
- #gateway_class ⇒ Object
- #partial_name ⇒ Object
- #payment_profiles_supported? ⇒ Boolean
- #purchase(amount, creditcard, gateway_options) ⇒ Object
- #void(response_code, creditcard, gateway_options) ⇒ Object
Instance Method Details
#authorize(amount, creditcard, gateway_options) ⇒ Object
20 21 22 23 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 20 def (amount, creditcard, ) init_culqi commit(amount, creditcard, , false) end |
#capture(_amount, response_code, _gateway_options) ⇒ Object
30 31 32 33 34 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 30 def capture(_amount, response_code, ) init_culqi charge = Culqi::Charge.capture(response_code) parse_response(charge) end |
#create_profile(payment) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 57 def create_profile(payment) return unless payment.source.gateway_customer_profile_id.nil? 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( gateway_customer_profile_id: customer, gateway_payment_profile_id: card_token ) end end |
#credit(amount, _creditcard, response_code, _gateway_options) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 36 def credit(amount, _creditcard, response_code, ) init_culqi # Culqi only accepts 'duplicado','fraudulento' o 'solicitud_comprador' # like reason's value refund = Culqi::Refund.create( amount: amount, charge_id: response_code, reason: "solicitud_comprador" ) parse_response(refund) end |
#default_currency ⇒ Object
16 17 18 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 16 def default_currency "PEN" end |
#gateway_class ⇒ Object
12 13 14 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 12 def gateway_class self.class end |
#partial_name ⇒ Object
8 9 10 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 8 def partial_name 'culqi' end |
#payment_profiles_supported? ⇒ Boolean
53 54 55 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 53 def payment_profiles_supported? true end |
#purchase(amount, creditcard, gateway_options) ⇒ Object
25 26 27 28 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 25 def purchase(amount, creditcard, ) init_culqi commit(amount, creditcard, , true) end |
#void(response_code, creditcard, gateway_options) ⇒ Object
48 49 50 51 |
# File 'app/models/solidus/gateway/culqi_gateway.rb', line 48 def void(response_code, creditcard, ) amount = [:subtotal].to_i credit(amount, creditcard, response_code, ) end |