class Charge

Public Class Methods

new(endpoints, username, password) click to toggle source
# File lib/payment/Charge.rb, line 11
def initialize(endpoints, username, password)
  @endpoints=endpoints
  @username=username
  @password=password
end

Public Instance Methods

charge(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId) click to toggle source
# File lib/payment/Charge.rb, line 41
def charge(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountChargeEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('code',code)
  formparameters.put('clientCorrelator',clientCorrelator)
  formparameters.put('onBehalfOf',onBehalfOf)
  formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
  formparameters.put('channel',channel)
  formparameters.put('taxAmount',taxAmount)
  formparameters.put('serviceId',serviceId)
  formparameters.put('productId',productId)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=AmountResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountTransaction']!=nil) then
      response.setAmountTransactionJSON(jsondata['amountTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
chargeWithCallback(endUserId,referenceCode,description,currency,amount,code,callbackURL,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId) click to toggle source
# File lib/payment/Charge.rb, line 82
def chargeWithCallback(endUserId,referenceCode,description,currency,amount,code,callbackURL,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountChargeEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('code',code)
  formparameters.put('callbackURL',callbackURL)
  formparameters.put('clientCorrelator',clientCorrelator)
  formparameters.put('onBehalfOf',onBehalfOf)
  formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
  formparameters.put('channel',channel)
  formparameters.put('taxAmount',taxAmount)
  formparameters.put('serviceId',serviceId)
  formparameters.put('productId',productId)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=AmountResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountTransaction']!=nil) then
      response.setAmountTransactionJSON(jsondata['amountTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
getEndpoints() click to toggle source
# File lib/payment/Charge.rb, line 16
def getEndpoints
  @endpoints
end
getPassword() click to toggle source
# File lib/payment/Charge.rb, line 32
def getPassword
  @password
end
getUsername() click to toggle source
# File lib/payment/Charge.rb, line 24
def getUsername
  @username
end
refund(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,originalServerReferenceCode,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId) click to toggle source
# File lib/payment/Charge.rb, line 124
def refund(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,originalServerReferenceCode,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountRefundEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('code',code)
  formparameters.put('clientCorrelator',clientCorrelator)
  formparameters.put('originalServerReferenceCode',originalServerReferenceCode)
  formparameters.put('onBehalfOf',onBehalfOf)
  formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
  formparameters.put('channel',channel)
  formparameters.put('taxAmount',taxAmount)
  formparameters.put('serviceId',serviceId)
  formparameters.put('productId',productId)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=AmountResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountTransaction']!=nil) then
      response.setAmountTransactionJSON(jsondata['amountTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
setEndpoints(endpoints) click to toggle source
# File lib/payment/Charge.rb, line 20
def setEndpoints(endpoints)
  @endpoints=endpoints
end
setPassword(password) click to toggle source
# File lib/payment/Charge.rb, line 36
def setPassword(password)
  @password=password
end
setUsername(username) click to toggle source
# File lib/payment/Charge.rb, line 28
def setUsername(username)
  @username=username
end