Class: Multicard::Resources::Holds

Inherits:
Base
  • Object
show all
Defined in:
lib/multicard/resources/holds.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Multicard::Resources::Base

Instance Method Details

#cancel(hold_id) ⇒ Response

Cancel a hold (release blocked funds).

Parameters:

  • hold_id (String)

    hold ID

Returns:



55
56
57
# File 'lib/multicard/resources/holds.rb', line 55

def cancel(hold_id)
  delete("/hold/#{encode_path(hold_id)}")
end

#capture(hold_id, amount: nil) ⇒ Response

Capture (debit) held funds. Full or partial.

Parameters:

  • hold_id (String)

    hold ID

  • amount (Integer, nil) (defaults to: nil)

    partial capture amount (nil = full capture)

Returns:



38
39
40
41
# File 'lib/multicard/resources/holds.rb', line 38

def capture(hold_id, amount: nil)
  body = amount ? { amount: amount } : {}
  post("/hold/#{encode_path(hold_id)}/charge", body)
end

#confirm(hold_id, otp_code: nil) ⇒ Response

Confirm a hold (block funds on card).

Parameters:

  • hold_id (String)

    hold ID

  • otp_code (String, nil) (defaults to: nil)

    SMS OTP code if required

Returns:



28
29
30
31
# File 'lib/multicard/resources/holds.rb', line 28

def confirm(hold_id, otp_code: nil)
  body = otp_code ? { code: otp_code } : {}
  post("/hold/#{encode_path(hold_id)}/confirm", body)
end

#create(card_token:, amount:, invoice_id:, store_id: nil, **options) ⇒ Response

Create a hold (pre-authorization).

Parameters:

  • card_token (String)

    card token

  • amount (Integer)

    amount in tiyin

  • invoice_id (String)

    your order ID

  • store_id (Integer, nil) (defaults to: nil)

    register ID

Returns:



13
14
15
16
17
18
19
20
21
# File 'lib/multicard/resources/holds.rb', line 13

def create(card_token:, amount:, invoice_id:, store_id: nil, **options)
  post('/hold', {
    card: { token: card_token },
    amount: amount,
    store_id: store_id || default_store_id,
    invoice_id: invoice_id,
    **options
  }.compact)
end

#retrieve(hold_id) ⇒ Response

Retrieve hold info.

Parameters:

  • hold_id (String)

    hold ID

Returns:



47
48
49
# File 'lib/multicard/resources/holds.rb', line 47

def retrieve(hold_id)
  get("/hold/#{encode_path(hold_id)}")
end