Class: Jpay::PaymentVerification

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

Overview

Verifies transaction with jahanpay

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ PaymentVerification

Note:

A hash of parameters should be send to this class

Returns a new instance of PaymentVerification.

Examples:

PaymentVerification.new(authority: 'xxx-xxx', amount: 10000)

Parameters:

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

    hash of params to verify transaction

Options Hash (args):

  • :authority (String)

    Authority code returned by verify url params

  • :amount (Integer)

    price of the request



15
16
17
18
19
20
21
# File 'lib/jpay/payment_verification.rb', line 15

def initialize(args = {})
  @api = args[:api] || Jpay.configuration.api
  @authority = args.fetch(:authority)
  @amount    = args.fetch(:amount)
  @client  ||= Savon.client(wsdl: Jpay.configuration.client, pretty_print_xml: true)
  @response  = Response.new
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/jpay/payment_verification.rb', line 6

def status
  @status
end

Instance Method Details

#verifyJpay::Response

Send verification request to jahanpay

Returns:



26
27
28
29
30
31
32
33
# File 'lib/jpay/payment_verification.rb', line 26

def verify
  response = @client.call :verification, message: {
    'api' => @api,
    'amount' => @amount,
    'authority' => @authority,
  }
  @response.validate(response.body)
end