Class: Spree::BcashPayment

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/bcash_payment.rb

Instance Method Summary collapse

Instance Method Details

#process!(payment) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/spree/bcash_payment.rb', line 3

def process!(payment)
  order = payment.order

  items = []
  items = order.line_items.map do |item|
    bcash_item = ::Bcash::Item.new(
      {
        id: item.id,
        description: item.product.name,
        amount: item.quantity,
        price: format("%.2f", item.price.round(2))
      }
    )

    bcash_item
  end

  ::Bcash::Package.create(items, tax(order))
end