module Bygpay::Utils

Attributes

amount[RW]
response[RW]
response_text[RW]
result[RW]
status[RW]
transaction_id[RW]
uuid[RW]

Public Instance Methods

card_deposit_endpoint() click to toggle source

Mobile Deposit transactions endpoint

# File lib/bygpay/utils.rb, line 14
def card_deposit_endpoint
  Bygpay.configuration.deposit_card_path
end
deposit_status_endpoint() click to toggle source

Deposit transactions status check endpoint

# File lib/bygpay/utils.rb, line 19
def deposit_status_endpoint
  Bygpay.configuration.deposit_status_path
end
get_status(endpoint, uuid) click to toggle source

Get transaction status

# File lib/bygpay/utils.rb, line 42
def get_status(endpoint, uuid)
  url = "#{Bygpay.configuration.base_url}#{endpoint}"
  result = http_connect.get("#{url}/#{uuid}")

  parse_response(result.body)
end
http_connect() click to toggle source

global Bygpay connect

# File lib/bygpay/utils.rb, line 62
def http_connect
  HTTP[Authorization: Bygpay.configuration.api_key]
end
mobile_deposit_endpoint() click to toggle source

Mobile Deposit transactions endpoint

# File lib/bygpay/utils.rb, line 9
def mobile_deposit_endpoint
  Bygpay.configuration.deposit_mobile_path
end
mobile_withdraw_endpoint() click to toggle source

Mobile Withdrawal transactions endpoint

# File lib/bygpay/utils.rb, line 24
def mobile_withdraw_endpoint
  Bygpay.configuration.withdraw_mobile_path
end
parse_response(json_payload) click to toggle source

Parse on JSON Body to BygResponse for parsing and processing

# File lib/bygpay/utils.rb, line 50
def parse_response(json_payload)
  @response = Bygpay::BygResponse.parse_response(json_payload)
  resp = @response.data
  @transaction_id = @response.transaction_id
  @response_text = resp.message
  @uuid = @response.uuid
  @amount = @response.amount
  @status = @response.transaction_status
  @result = @response.request_successful?
end
post(endpoint, payload = {}) click to toggle source

Post payload

# File lib/bygpay/utils.rb, line 34
def post(endpoint, payload = {})
  url = "#{Bygpay.configuration.base_url}#{endpoint}"
  result = http_connect.post(url, json: payload)

  parse_response(result.body)
end
withdraw_status_endpoint() click to toggle source

Withdraw transactions status check endpoint

# File lib/bygpay/utils.rb, line 29
def withdraw_status_endpoint
  Bygpay.configuration.withdraw_status_path
end