Class: Hipay::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/hipay.rb

Instance Method Summary collapse

Constructor Details

#initialize(wsLogin, wsPassword, websiteId, categoryId, test: false) ⇒ Payment

Returns a new instance of Payment.



17
18
19
20
21
22
23
# 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

Instance Method Details

#build_basic_requestObject



73
74
75
# 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) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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 !.nil?
  parameters[: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