-
Notifications
You must be signed in to change notification settings - Fork 0
/
directApi.rb
33 lines (28 loc) · 1.33 KB
/
directApi.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class PayInfo
def initialize(pan, amnt, ordId, crdHolder, exMonth, exYear, sCode)
@pan, @amount, @orderId, @cardHolder, @eMonth, @eYear, @secureCode = pan, amnt, ordId, crdHolder, exMonth, exYear, sCode
end
def plain
return "OrderId=#{@orderId};Amount=#{@amount};CardHolder=#{@cardHolder};PAN=#{@pan};EMonth=#{@eMonth};EYear=#{@eYear};SecureCode=#{@secureCode};"
end
end
class APITransaction
def initialize(key, pInfo, order, custKey, paytureId, custFields)
@key, @payInfo, @payment, @customerKey, @paytureId, @customerFields = key, pInfo, order, custKey, paytureId, custFields
end
end
class APIManager < OrderManager
def initialize(merch)
super(merch, 'api')
end
def pay(order, pInfo, custKey, custParams, paytureId)
prms = Hash['Key' => @merchant.name, 'Amount' => order.amount, 'OrderId' => order.orderId,
'CustomerKey' => 'RubyTestCustomer', 'PayInfo' => pInfo.plain, 'PaytureId' => '' ]
return requestToPayture(prms, Commands::PAY)
end
def block(order, pInfo, custKey, custParams, paytureId)
prms = Hash['Key' => @merchant.name, 'Amount' => order.amount, 'OrderId' => order.orderId,
'CustomerKey' => 'RubyTestCustomer', 'PayInfo' => pInfo.plain, 'PaytureId' => '' ]
return requestToPayture(prms, Commands::BLOCK)
end
end