Module: Bygpay::Utils

Included in:
Deposits, Withdrawals
Defined in:
lib/bygpay/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def amount
  @amount
end

#meta_dataObject

Returns the value of attribute meta_data.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def 
  @meta_data
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def response
  @response
end

#response_textObject

Returns the value of attribute response_text.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def response_text
  @response_text
end

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def result
  @result
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def status
  @status
end

#transaction_idObject

Returns the value of attribute transaction_id.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def transaction_id
  @transaction_id
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#card_deposit_endpointObject

Mobile Deposit transactions endpoint



31
32
33
# File 'lib/bygpay/utils.rb', line 31

def card_deposit_endpoint
  Bygpay.configuration.deposit_card_path
end

#deposit_status_endpointObject

Deposit transactions status check endpoint



36
37
38
# File 'lib/bygpay/utils.rb', line 36

def deposit_status_endpoint
  Bygpay.configuration.deposit_status_path
end

#expresspay_deposit_endpointObject



18
19
20
# File 'lib/bygpay/utils.rb', line 18

def expresspay_deposit_endpoint
  Bygpay.configuration.deposit_expresspay_path
end

#get_status(endpoint, uuid) ⇒ Object

Get transaction status



59
60
61
62
63
64
# File 'lib/bygpay/utils.rb', line 59

def get_status(endpoint, uuid)
  url = "#{Bygpay.configuration.base_url}#{endpoint}"
  result = http_connect.get("#{url}/#{uuid}")

  parse_response(result.body)
end

#http_connectObject

global Bygpay connect



80
81
82
# File 'lib/bygpay/utils.rb', line 80

def http_connect
  HTTP[Authorization: Bygpay.configuration.api_key]
end

#hubtel_deposit_endpointObject



26
27
28
# File 'lib/bygpay/utils.rb', line 26

def hubtel_deposit_endpoint
  Bygpay.configuration.deposit_hubtel_path
end

#mobile_deposit_endpointObject

Mobile Deposit transactions endpoint



9
10
11
# File 'lib/bygpay/utils.rb', line 9

def mobile_deposit_endpoint
  Bygpay.configuration.deposit_mobile_path
end

#mobile_withdraw_endpointObject

Mobile Withdrawal transactions endpoint



41
42
43
# File 'lib/bygpay/utils.rb', line 41

def mobile_withdraw_endpoint
  Bygpay.configuration.withdraw_mobile_path
end

#parse_response(json_payload) ⇒ Object

Parse on JSON Body to BygResponse for parsing and processing



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/bygpay/utils.rb', line 67

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
  @meta_data = @response.
  @status = @response.transaction_status
  @result = @response.request_successful?
end

#paystack_deposit_endpointObject



22
23
24
# File 'lib/bygpay/utils.rb', line 22

def paystack_deposit_endpoint
  Bygpay.configuration.deposit_paystack_path
end

#post(endpoint, payload = {}) ⇒ Object

Post payload



51
52
53
54
55
56
# File 'lib/bygpay/utils.rb', line 51

def post(endpoint, payload = {})
  url = "#{Bygpay.configuration.base_url}#{endpoint}"
  result = http_connect.post(url, json: payload)

  parse_response(result.body)
end

#rave_deposit_endpointObject

Rave Deposit transactions endpoint



14
15
16
# File 'lib/bygpay/utils.rb', line 14

def rave_deposit_endpoint
  Bygpay.configuration.deposit_rave_path
end

#withdraw_status_endpointObject

Withdraw transactions status check endpoint



46
47
48
# File 'lib/bygpay/utils.rb', line 46

def withdraw_status_endpoint
  Bygpay.configuration.withdraw_status_path
end