Class: Payu::Refund
- Inherits:
-
Object
- Object
- Payu::Refund
- Defined in:
- lib/payu/refund.rb
Instance Method Summary collapse
-
#initialize(key:, salt:, test_mode: false) ⇒ Refund
constructor
A new instance of Refund.
-
#initiate(mihpayid:, amount:) ⇒ Object
Initiate a full or partial refund.
-
#status(mihpayid) ⇒ Object
Check refund status by mihpayid.
Constructor Details
#initialize(key:, salt:, test_mode: false) ⇒ Refund
Returns a new instance of Refund.
3 4 5 6 7 8 9 |
# File 'lib/payu/refund.rb', line 3 def initialize(key:, salt:, test_mode: false) @config = Configuration.new @config.key = key @config.salt = salt @config.test_mode = test_mode @config.validate! end |
Instance Method Details
#initiate(mihpayid:, amount:) ⇒ Object
Initiate a full or partial refund. mihpayid: PayU's payment ID (returned in callback as :mihpayid) amount: amount to refund (can be partial)
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/payu/refund.rb', line 14 def initiate(mihpayid:, amount:) hash = Payu::Hash.api( key: @config.key, command: "cancel_refund_transaction", var1: mihpayid, salt: @config.salt ) Payu::Http.post_form( @config.api_url, command: "cancel_refund_transaction", var1: mihpayid, var2: format("%.2f", amount), hash: hash, key: @config.key ) end |
#status(mihpayid) ⇒ Object
Check refund status by mihpayid.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/payu/refund.rb', line 27 def status(mihpayid) hash = Payu::Hash.api( key: @config.key, command: "get_refund_details", var1: mihpayid, salt: @config.salt ) Payu::Http.post_form( @config.api_url, command: "get_refund_details", var1: mihpayid, hash: hash, key: @config.key ) end |