Class: Multicard::Resources::Payments

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

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#confirm(payment_id, otp_code: nil) ⇒ Response

Confirm a payment (submit OTP code if required).

Parameters:

  • payment_id (String)

    payment ID

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

    SMS confirmation code

Returns:



93
94
95
96
# File 'lib/multicard/resources/payments.rb', line 93

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

#create_by_card(card_number:, card_expiry:, amount:, invoice_id:, store_id: nil, callback_url: nil, ofd: nil, **options) ⇒ Response

Pay by card number (requires PCI DSS).

Parameters:

  • card_number (String)

    card number

  • card_expiry (String)

    card expiry (MMYY or MM/YY)

  • amount (Integer)

    amount in tiyin

  • invoice_id (String)

    your order ID

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/multicard/resources/payments.rb', line 35

def create_by_card(card_number:, card_expiry:, amount:, invoice_id:, store_id: nil,
                   callback_url: nil, ofd: nil, **options)
  post('/payment/card', {
    card: { number: card_number, expiry: card_expiry },
    amount: amount,
    store_id: store_id || default_store_id,
    invoice_id: invoice_id,
    callback_url: callback_url,
    ofd: ofd,
    **options
  }.compact)
end

#create_by_token(card_token:, amount:, invoice_id:, store_id: nil, callback_url: nil, ofd: nil, **options) ⇒ Response

Pay by saved card token.

Parameters:

  • card_token (String)

    card token from binding

  • amount (Integer)

    amount in tiyin

  • invoice_id (String)

    your order ID

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

    register ID

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

    webhook URL

  • ofd (Array<Hash>, nil) (defaults to: nil)

    fiscal receipt items

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/multicard/resources/payments.rb', line 15

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

#create_split(card_token:, amount:, invoice_id:, split:, store_id: nil, callback_url: nil, ofd: nil, **options) ⇒ Response

Split payment across multiple recipients.

Parameters:

  • card_token (String)

    card token

  • amount (Integer)

    total amount in tiyin

  • invoice_id (String)

    your order ID

  • split (Array<Hash>)

    split recipients [amount:, details:, recipient:]

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/multicard/resources/payments.rb', line 55

def create_split(card_token:, amount:, invoice_id:, split:, store_id: nil,
                 callback_url: nil, ofd: nil, **options)
  post('/payment/split', {
    card: { token: card_token },
    amount: amount,
    store_id: store_id || default_store_id,
    invoice_id: invoice_id,
    callback_url: callback_url,
    split: split,
    ofd: ofd,
    **options
  }.compact)
end

#create_wallet(service:, amount:, invoice_id:, store_id: nil, callback_url: nil, ofd: nil, **options) ⇒ Response

Pay via wallet app (Payme, Click, Uzum, etc.).

Parameters:

  • service (String)

    wallet service name

  • amount (Integer)

    amount in tiyin

  • invoice_id (String)

    your order ID

Returns:



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/multicard/resources/payments.rb', line 75

def create_wallet(service:, amount:, invoice_id:, store_id: nil,
                  callback_url: nil, ofd: nil, **options)
  post('/payment/app', {
    service: service,
    amount: amount,
    store_id: store_id || default_store_id,
    invoice_id: invoice_id,
    callback_url: callback_url,
    ofd: ofd,
    **options
  }.compact)
end

#partial_refund(payment_id, refund_amount:, ofd:, card_pan: nil) ⇒ Response

Partial refund.

Cancels the original fiscal receipt and issues a new one for the remaining items (the ofd array is mandatory for partial refunds).

Parameters:

  • payment_id (String)

    payment ID (UUID)

  • refund_amount (Integer)

    refund amount in tiyin

  • ofd (Array<Hash>)

    fiscal receipt items for the remaining goods

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

    masked PAN — required only for wallet apps (Payme/Click)

Returns:



124
125
126
127
128
129
130
# File 'lib/multicard/resources/payments.rb', line 124

def partial_refund(payment_id, refund_amount:, ofd:, card_pan: nil)
  delete("/payment/#{encode_path(payment_id)}/partial", body: {
    refund_amount: refund_amount,
    ofd: ofd,
    card_pan: card_pan
  }.compact)
end

#refund(payment_id) ⇒ Response

Full refund.

Parameters:

  • payment_id (String)

    payment ID (UUID)

Returns:



110
111
112
# File 'lib/multicard/resources/payments.rb', line 110

def refund(payment_id)
  delete("/payment/#{encode_path(payment_id)}")
end

#retrieve(payment_id) ⇒ Response

Retrieve payment info.

Parameters:

  • payment_id (String)

    payment ID (UUID)

Returns:



102
103
104
# File 'lib/multicard/resources/payments.rb', line 102

def retrieve(payment_id)
  get("/payment/#{encode_path(payment_id)}")
end

Submit a fiscal receipt link.

Parameters:

  • payment_id (String)

    payment ID (UUID)

  • fiscal_url (String)

    URL of the fiscal receipt

Returns:



137
138
139
# File 'lib/multicard/resources/payments.rb', line 137

def send_fiscal_link(payment_id, fiscal_url:)
  post("/payment/#{encode_path(payment_id)}/fiscal", { fiscal_url: fiscal_url })
end