class Mellat::BpPayRequest

Attributes

additionalData[RW]
amount[RW]
callBackUrl[RW]
localDate[RW]
localTime[RW]
orderId[RW]
payerId[RW]
respond[R]

Public Class Methods

new(args = {}) click to toggle source
# File lib/mellat/requisition.rb, line 9
def initialize(args = {})
  @orderId          = args.fetch(:orderId)
  @amount             = args.fetch(:amount)
  @localDate            = args.fetch(:localDate,Time.now.strftime("%Y%d%m"))
  @localTime                  = args.fetch(:localTime,Time.now.strftime("%H%M%S"))
  @additionalData   = args.fetch(:additionalData,' ')
  @payerId                = args.fetch(:payerId,0)
  @callBackUrl                = args.fetch(:callBackUrl,Mellat.configuration.callBackUrl)
  @terminalId                   = args.fetch(:terminalId,Mellat.configuration.terminalId) 
  @userName               = args.fetch(:userName,Mellat.configuration.userName) 
  @userPassword               = args.fetch(:userPassword,Mellat.configuration.userPassword)
  @wsdl                       = Savon.client(wsdl: Mellat.configuration.wsdl, pretty_print_xml: true,namespace: 'http://interfaces.core.sw.bps.com/')
  @response             = RespondBpPayRequest.new()
end

Public Instance Methods

call() click to toggle source
# File lib/mellat/requisition.rb, line 24
def call
  response = @wsdl.call :bp_pay_request, message: {
    'terminalId'     => @terminalId,
    'userName'       => @userName,
    'userPassword'   => @userPassword,
    'orderId'        => @orderId,
    'amount'         => @amount,
    'localDate'      => @localDate.to_s,
    'localTime'      => @localTime.to_s,
    'additionalData' => @additionalData,
    'payerId'                  => @payerId,
    'callBackUrl'      => @callBackUrl
  }
  @response.validate(response.body)
end