Class: ShopeePayService::CreateInvoice

Inherits:
Base
  • Object
show all
Defined in:
app/services/shopee_pay_service/create_invoice.rb

Instance Method Summary collapse

Constructor Details

#initialize(reservation, options = {}) ⇒ CreateInvoice

Returns a new instance of CreateInvoice.



6
7
8
9
# File 'app/services/shopee_pay_service/create_invoice.rb', line 6

def initialize(reservation, options = {})
  @reservation = reservation
  @options = options.reverse_merge(platform_type: 'pc')
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
# File 'app/services/shopee_pay_service/create_invoice.rb', line 11

def execute
  response = super

  ActiveRecord::Base.transaction do
    @reservation.charges.build(charge_attribute(response))
    @reservation.charges.each(&:save!)
  end

  response
end