class Bygpay::BygResponse
Constants
- FAILED
- PENDING
- SUCCESS
Attributes
data[RW]
Public Class Methods
new(hash = {})
click to toggle source
# File lib/bygpay/byg_response.rb, line 11 def initialize(hash = {}) @data = Hashie::Mash.new(hash) end
parse_response(json_payload)
click to toggle source
Hash strucuture {
"status": "success", "message": "Some messages", "data": { "uuid": "d1f3395e-ea08-4599-b8a5-41f5e7a4", "status": "accepted", "currency": "GHS", "trnx_code": "DTX00000008", "provider_txid": null, "extrnx_code": null, "walletno": "0276967627", "amount": 0.1, "provider": "TIGO" }
} This may throw JSON::ParserError if the json_payload is not valid JSON.
# File lib/bygpay/byg_response.rb, line 77 def self.parse_response(json_payload) data = JSON.parse(json_payload, symbolize_names: true) resp = BygResponse.new(data) resp end
Public Instance Methods
amount()
click to toggle source
# File lib/bygpay/byg_response.rb, line 52 def amount data.data.amount end
currency()
click to toggle source
# File lib/bygpay/byg_response.rb, line 48 def currency data.data.currency end
failed?()
click to toggle source
# File lib/bygpay/byg_response.rb, line 24 def failed? data.data.status == FAILED end
pending?()
click to toggle source
# File lib/bygpay/byg_response.rb, line 28 def pending? PENDING.include?(data.data.status) end
processor_transaction_id()
click to toggle source
# File lib/bygpay/byg_response.rb, line 40 def processor_transaction_id data.data.provider_txid end
provider()
click to toggle source
# File lib/bygpay/byg_response.rb, line 56 def provider data.data.provider end
request_successful?()
click to toggle source
Check if Bygpay
Gateway processed requests without any issues
# File lib/bygpay/byg_response.rb, line 16 def request_successful? data.status == SUCCESS end
success?()
click to toggle source
# File lib/bygpay/byg_response.rb, line 20 def success? data.data.status == SUCCESS end
transaction_id()
click to toggle source
# File lib/bygpay/byg_response.rb, line 36 def transaction_id data.data.trnx_code end
transaction_status()
click to toggle source
# File lib/bygpay/byg_response.rb, line 44 def transaction_status data.data.status end
uuid()
click to toggle source
# File lib/bygpay/byg_response.rb, line 32 def uuid data.data.uuid end