Class: Mundipagg::CreditCard

Inherits:
ActiveMerchant::Billing::CreditCard
  • Object
show all
Defined in:
lib/mundipagg/credit_card.rb

Defined Under Namespace

Classes: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



3
4
5
# File 'lib/mundipagg/credit_card.rb', line 3

def currency
  @currency
end

#installment_countObject

Returns the value of attribute installment_count.



3
4
5
# File 'lib/mundipagg/credit_card.rb', line 3

def installment_count
  @installment_count
end

Instance Method Details

#brand_nameObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mundipagg/credit_card.rb', line 5

def brand_name
  return "" if !brand.present?

  case brand
  when "master"
    "Mastercard"
  when "american_express"
    "Amex"
  when "diners_club"
    "Diners"
  else
    brand.capitalize
  end
end

#payload(amount) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mundipagg/credit_card.rb', line 20

def payload(amount)
  content = {
    amount_in_cents: amount,
    credit_card_brand_enum: brand_name,
    credit_card_number: number,
    credit_card_operation_enum: "AuthAndCapture",
    exp_month: month,
    exp_year: year,
    holder_name: name,
    installment_count: installment_count || 1,
    security_code: verification_value,
  }

  if ::ActiveMerchant::Billing::Base.test?
    content.merge!(payment_method_code: 1)
  end

  {
    amount_in_cents: amount,
    currency_iso_enum: currency || "BRL",
    credit_card_transaction_collection: { credit_card_transaction: content }
  }
end