class Paytrail::MerchantApi

Public Class Methods

new(apiKey, secret, uri) click to toggle source
# File lib/paytrail/merchantapi.rb, line 48
def initialize(apiKey, secret, uri)
    @paytrail = Paytrail.new(@@apiName, apiKey, secret)
    @uri = uri
end

Public Instance Methods

createRefund(orderNumber, email, refundRows, notifyUrl) click to toggle source
# File lib/paytrail/merchantapi.rb, line 53
def createRefund(orderNumber, email, refundRows, notifyUrl)
    data = {
        :email => email,
        :rows => refundRows
    }

    if notifyUrl
        data[:notifyUrl] = notifyUrl
    end

    data = data.to_json
    location = '/merchant/v1/payments/%s/refunds' % [orderNumber]
    headers = @paytrail.makeHeaders('POST', location, @paytrail.makeTimestamp, data)

    @paytrail.post(@uri + location, headers, data)
end
deleteRefund(refundToken) click to toggle source
# File lib/paytrail/merchantapi.rb, line 70
def deleteRefund(refundToken)
    location = '/merchant/v1/refunds/%s' % [refundToken]
    headers = @paytrail.makeHeaders('DELETE', location, @paytrail.makeTimestamp, '')

    @paytrail.delete(@uri + location, headers)
end