Class: PayU::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration, http_client) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/pay_u/client.rb', line 9

def initialize(configuration, http_client)
  @configuration = configuration
  @http_client = http_client
end

Instance Method Details

#authorizeObject



14
15
16
# File 'lib/pay_u/client.rb', line 14

def authorize
  authorization.authorize
end

#cancel_order(order_id) ⇒ Object



32
33
34
# File 'lib/pay_u/client.rb', line 32

def cancel_order(order_id)
  orders_service.cancel_order(order_id, PayU::BaseRequest.new(headers))
end

#place_order(buyer, products, total_amount, meta = {}) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/pay_u/client.rb', line 18

def place_order(buyer, products, total_amount, meta = {})
  request_hash = order_meta(meta).merge({ buyer: buyer,
                                          products: products,
                                          total_amount: total_amount })

  request = PayU::BaseRequest.new(headers, request_hash)
  orders_service.place_order(request)
end

#refund_order(order_id, amount = nil) ⇒ Object



27
28
29
30
# File 'lib/pay_u/client.rb', line 27

def refund_order(order_id, amount = nil)
  request_hash = { refund: { description: "Refund" } }.merge(refund_amount(amount))
  orders_service.refund_order(order_id, PayU::BaseRequest.new(headers, request_hash))
end