Class: PayuPl::Refunds::Create

Inherits:
Operations::Base show all
Defined in:
lib/payu_pl/refunds/create.rb

Instance Method Summary collapse

Instance Method Details

#call(order_id, description:, amount: nil, ext_refund_id: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/payu_pl/refunds/create.rb', line 6

def call(order_id, description:, amount: nil, ext_refund_id: nil)
  params = {
    order_id: order_id.to_s,
    description: description,
    amount: amount,
    ext_refund_id: ext_refund_id
  }
  validate_contract!(Contracts::RefundCreateContract, params, input: params)

  refund = {
    description: description,
    amount: amount,
    extRefundId: ext_refund_id
  }.compact

  transport.request(
    :post,
    Endpoints.order_refunds(order_id),
    json: { refund: refund }
  )
end