class Hipay::Payment

Public Class Methods

new(wsLogin, wsPassword, websiteId, categoryId, test: false) click to toggle source
# File lib/hipay.rb, line 17
def initialize(wsLogin, wsPassword, websiteId, categoryId, test: false)
  @wsLogin = wsLogin
  @wsPassword = wsPassword
  @websiteId = websiteId
  @categoryId = categoryId
  @test = test
end

Public Instance Methods

build_basic_request() click to toggle source
# File lib/hipay.rb, line 73
def build_basic_request()
  { wsLogin: @wsLogin, wsPassword: @wsPassword, websiteId: @websiteId, categoryId: @categoryId }
end
generate(amount, customerIpAddress, urlCallback, executionDate, description, currency: "EUR", rating: "ALL", locale: "en_GB", manualCapture: 0, customerEmail: nil, urlAccept: nil, urlDecline: nil, urlCancel: nil, urlLogo: nil, merchantReference: nil, merchantComment: nil, emailCallback: nil, freeData: nil) click to toggle source
# File lib/hipay.rb, line 25
def generate(amount, customerIpAddress,  urlCallback, executionDate, description, currency: "EUR",
             rating: "ALL", locale: "en_GB", manualCapture: 0, customerEmail: nil,
             urlAccept: nil, urlDecline: nil, urlCancel: nil, urlLogo: nil,
             merchantReference: nil, merchantComment: nil, emailCallback: nil, freeData: nil)

  operation = :generate
  parameters = build_basic_request
  parameters[:currency] = currency
  parameters[:amount] = amount
  parameters[:rating] = rating
  parameters[:locale] = locale
  parameters[:customerIpAddress] = customerIpAddress
  parameters[:manualCapture] = manualCapture
  parameters[:executionDate] = executionDate
  parameters[:description] = description
  parameters[:urlCallback] = urlCallback

  if !customerEmail.nil?
    parameters[:customerEmail] = customerEmail
  end
  if !urlAccept.nil?
    parameters[:urlAccept] = urlAccept
  end
  if !urlCancel.nil?
  parameters[:urlCancel] = urlCancel
  end
  if !urlDecline.nil?
  parameters[:urlDecline] = urlDecline
  end
  if !urlLogo.nil?
  parameters[:urlLogo] = urlLogo
  end
  if !merchantReference.nil?
  parameters[:merchantReference] = merchantReference
  end
  if !merchantComment.nil?
  parameters[:merchantComment] = merchantComment
  end
  if !emailCallback.nil?
  parameters[:emailCallback] = emailCallback
  end
  if !freeData.nil?
  parameters[:freeData] = freeData
  end

  Hipay::call_api("payment-v2", operation, @test, {parameters: parameters})[:generate_response][:generate_result]
end