Class: MercadoPagoApi::PaymentMethod
- Inherits:
-
Object
- Object
- MercadoPagoApi::PaymentMethod
- Defined in:
- lib/mercado_pago_api/payment_method.rb
Instance Attribute Summary collapse
-
#installments ⇒ Object
readonly
Returns the value of attribute installments.
-
#issuer_id ⇒ Object
readonly
Returns the value of attribute issuer_id.
-
#payment_method_id ⇒ Object
readonly
Returns the value of attribute payment_method_id.
Class Method Summary collapse
- .build_hash(response, credit) ⇒ Object
- .build_query(first_six_digits) ⇒ Object
- .find_by_first_six_digits(first_six_digits, credit: true) ⇒ Object
Instance Method Summary collapse
-
#initialize(payment_method_id:, issuer_id:, installments:) ⇒ PaymentMethod
constructor
A new instance of PaymentMethod.
Constructor Details
#initialize(payment_method_id:, issuer_id:, installments:) ⇒ PaymentMethod
Returns a new instance of PaymentMethod.
29 30 31 32 33 |
# File 'lib/mercado_pago_api/payment_method.rb', line 29 def initialize(payment_method_id: , issuer_id: , installments:) @payment_method_id = payment_method_id @issuer_id = issuer_id @installments = installments end |
Instance Attribute Details
#installments ⇒ Object (readonly)
Returns the value of attribute installments.
28 29 30 |
# File 'lib/mercado_pago_api/payment_method.rb', line 28 def installments @installments end |
#issuer_id ⇒ Object (readonly)
Returns the value of attribute issuer_id.
28 29 30 |
# File 'lib/mercado_pago_api/payment_method.rb', line 28 def issuer_id @issuer_id end |
#payment_method_id ⇒ Object (readonly)
Returns the value of attribute payment_method_id.
28 29 30 |
# File 'lib/mercado_pago_api/payment_method.rb', line 28 def payment_method_id @payment_method_id end |
Class Method Details
.build_hash(response, credit) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/mercado_pago_api/payment_method.rb', line 18 def self.build_hash(response, credit) payment_type_id = credit ? 'credit_card' : 'debit_card' payment_method = response.dig('results').find {|pm| pm['payment_type_id'] == payment_type_id} { payment_method_id: payment_method.dig('id'), issuer_id: payment_method.dig('issuer', 'id'), installments: payment_method.dig('payer_costs') } end |
.build_query(first_six_digits) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mercado_pago_api/payment_method.rb', line 10 def self.build_query(first_six_digits) { marketplace: 'NONE', status: 'active', bins: first_six_digits } end |
.find_by_first_six_digits(first_six_digits, credit: true) ⇒ Object
5 6 7 8 |
# File 'lib/mercado_pago_api/payment_method.rb', line 5 def self.find_by_first_six_digits(first_six_digits, credit: true) response = Client.new.search_payment_methods(build_query(first_six_digits)) new(**build_hash(response, credit)) end |