Class: Rubyplat::Client

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

Constant Summary collapse

InvalidSignature =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(key = Rubyplat.config.key, pubkey = Rubyplat.config.pubkey) ⇒ Client

Returns a new instance of Client.

Parameters:

  • key (CyberplatPKI::Key) (defaults to: Rubyplat.config.key)

    cyberplat secret key to sign request

  • pubkey (CyberplatPKI::Key) (defaults to: Rubyplat.config.pubkey)

    cyberplat pubkey to verify request



7
8
9
# File 'lib/rubyplat/client.rb', line 7

def initialize(key=Rubyplat.config.key, pubkey=Rubyplat.config.pubkey)
  @key, @pubkey = key, pubkey
end

Instance Method Details

#pay(params = {}, vendor_or_uri) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/rubyplat/client.rb', line 33

def pay(params = {}, vendor_or_uri)
  uri = vendor_or_uri.kind_of?(String) ? URI(vendor_or_uri) : vendor_or_uri.pay_check_uri
  request = Rubyplat::Requests::PaymentRequest.new(params)
  response = send_request(request, uri)

  read_response(response, Rubyplat::Responses::PaymentResponse)
end

#pay_check(params = {}, vendor_or_uri) ⇒ Rubyplat::Responses::PaymentPermissionResponse, Net::HTTPBadRequest

Parameters:

  • params (Hash) (defaults to: {})

    arguments to create request

  • vendor_or_uri (String, Rubyplat::Gateways::Gateway)

    string or gateway for cyberplat

Options Hash (params):

  • :sender (String)

    sender of request

  • :receiver (String)

    request receiver

  • :operator (String)

    operator

  • :date (String)

    request date

  • :session (String)

    uniq session identifier non longer than 20

  • :number (String)

    phone number or payer’s account number(can be blank)

  • :account (String)

    payer’s identifier or payees service identifier. Can be blank.

  • :amount (Float)

    amount to be payed. example: 1234.12

Returns:

Raises:



25
26
27
28
29
30
31
# File 'lib/rubyplat/client.rb', line 25

def pay_check(params = {}, vendor_or_uri)
  uri = vendor_or_uri.kind_of?(String) ? URI(vendor_or_uri) : vendor_or_uri.pay_check_uri
  request = Rubyplat::Requests::PaymentPermission.new(params)
  response = send_request(request, uri)

  read_response(response, Rubyplat::Responses::PaymentPermissionResponse)
end

#pay_status(params = {}, vendor_or_uri) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/rubyplat/client.rb', line 41

def pay_status(params = {}, vendor_or_uri)
  uri = vendor_or_uri.kind_of?(String) ? URI(vendor_or_uri) : vendor_or_uri.pay_check_uri
  request = Rubyplat::Requests::PaymentStatus.new(params)
  response = send_request(request, uri)

  read_response(response, Rubyplat::Responses::PaymentStatusResponse)
end