Class: Payline::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



4
5
6
7
# File 'lib/payline/client.rb', line 4

def initialize(config)
  @config = config
  @response_handler = Payline::ResponseHandler.new
end

Instance Method Details

#capture(reserve_response, amount) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/payline/client.rb', line 39

def capture(reserve_response, amount)
  params = {
      'PRESENTATION.CURRENCY' => @config.currency,
      'PAYMENT.CODE' => "CC.CP",
      'PRESENTATION.AMOUNT' => amount,
      'IDENTIFICATION.TRANSACTIONID'=>reserve_response.merchant_reference,
      'IDENTIFICATION.REFERENCEID'=> reserve_response.transaction_id
  }
  do_request(params)
end

#reserve(guid, amount, credit_card) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/payline/client.rb', line 9

def reserve(guid, amount, credit_card)
  params = {
      'PAYMENT.CODE' => "CC.PA",
      'PRESENTATION.AMOUNT' => amount,
      'PRESENTATION.CURRENCY' => @config.currency,

      'ACCOUNT.BRAND' => credit_card[:account_type],
      'ACCOUNT.NUMBER' => credit_card[:card_number],
      'ACCOUNT.EXPIRY_MONTH' => credit_card[:expiry_month],
      'ACCOUNT.EXPIRY_YEAR' => credit_card[:expiry_year],
      'ACCOUNT.HOLDER' => credit_card[:card_holder],
      'ACCOUNT.VERIFICATION' => credit_card[:cvv],

      'NAME.COMPANY' => @config.company_name,
      'CONTACT.EMAIL' => @config.contact_email,

      # need to be here but currently not being passed in
      'ADDRESS.STREET' => 'na',
      'ADDRESS.ZIP' => 'na',
      'ADDRESS.CITY' => 'na',
      'ADDRESS.STATE' => 'na',
      'ADDRESS.COUNTRY' => 'ZA',

  }
  hash = do_request(params)
  merchant_id = hash['IDENTIFICATION.TRANSACTIONID']
  ref_id = hash['IDENTIFICATION.UNIQUEID']
  Payline::ReserveResponse.new(merchant_id, ref_id)
end

#reverse(reserve_response, amount) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/payline/client.rb', line 50

def reverse(reserve_response, amount)
  params = {
      'PRESENTATION.CURRENCY' => @config.currency,
      'PAYMENT.CODE' => "CC.RV",
      'PRESENTATION.AMOUNT' => amount,
      'IDENTIFICATION.TRANSACTIONID'=> reserve_response.merchant_reference,
      'IDENTIFICATION.REFERENCEID'=> reserve_response.transaction_id
  }
  do_request(params)
end