Class: Tinker::Model::Dto::InitiatePaymentRequestDto

Inherits:
Object
  • Object
show all
Defined in:
lib/tinker/model/dto/initiate_payment_request_dto.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount:, currency:, gateway:, merchant_reference:, return_url:, customer_phone: nil, customer_email: nil, transaction_desc: nil, metadata: nil) ⇒ InitiatePaymentRequestDto

Returns a new instance of InitiatePaymentRequestDto.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 10

def initialize(amount:, currency:, gateway:, merchant_reference:, return_url:,
               customer_phone: nil, customer_email: nil, transaction_desc: nil, metadata: nil)
  @amount = amount
  @currency = currency
  @gateway = gateway
  @merchant_reference = merchant_reference
  @return_url = return_url
  @customer_phone = customer_phone
  @customer_email = customer_email
  @transaction_desc = transaction_desc
   = 
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def currency
  @currency
end

#customer_emailObject (readonly)

Returns the value of attribute customer_email.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def customer_email
  @customer_email
end

#customer_phoneObject (readonly)

Returns the value of attribute customer_phone.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def customer_phone
  @customer_phone
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def gateway
  @gateway
end

#merchant_referenceObject (readonly)

Returns the value of attribute merchant_reference.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def merchant_reference
  @merchant_reference
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def 
  
end

#return_urlObject (readonly)

Returns the value of attribute return_url.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def return_url
  @return_url
end

#transaction_descObject (readonly)

Returns the value of attribute transaction_desc.



7
8
9
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 7

def transaction_desc
  @transaction_desc
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tinker/model/dto/initiate_payment_request_dto.rb', line 23

def to_hash
  gateway_value = @gateway.is_a?(String) ? @gateway : @gateway.to_s

  payload = {
    amount: @amount,
    currency: @currency,
    gateway: gateway_value,
    merchantReference: @merchant_reference,
    returnUrl: @return_url
  }

  payload[:customerPhone] = @customer_phone if @customer_phone
  payload[:customerEmail] = @customer_email if @customer_email
  payload[:transactionDesc] = @transaction_desc if @transaction_desc
  payload[:metadata] =  if 

  payload
end