Class: Airtel::Pesa::RefundPayment
- Inherits:
-
Object
- Object
- Airtel::Pesa::RefundPayment
- Defined in:
- lib/airtel/pesa/refund_payment.rb
Constant Summary collapse
- STAGING_URL =
"https://openapiuat.airtel.africa".freeze
- PRODUCTION_URL =
"https://openapi.airtel.africa".freeze
Instance Attribute Summary collapse
-
#airtel_money_id ⇒ Object
readonly
Returns the value of attribute airtel_money_id.
-
#transaction_country_code ⇒ Object
readonly
Returns the value of attribute transaction_country_code.
-
#transaction_currency_code ⇒ Object
readonly
Returns the value of attribute transaction_currency_code.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(airtel_money_id, transaction_country_code, transaction_currency_code) ⇒ RefundPayment
constructor
A new instance of RefundPayment.
Constructor Details
#initialize(airtel_money_id, transaction_country_code, transaction_currency_code) ⇒ RefundPayment
Returns a new instance of RefundPayment.
21 22 23 24 25 |
# File 'lib/airtel/pesa/refund_payment.rb', line 21 def initialize(airtel_money_id, transaction_country_code, transaction_currency_code) @airtel_money_id = airtel_money_id @transaction_country_code = transaction_country_code @transaction_currency_code = transaction_currency_code end |
Instance Attribute Details
#airtel_money_id ⇒ Object (readonly)
Returns the value of attribute airtel_money_id.
15 16 17 |
# File 'lib/airtel/pesa/refund_payment.rb', line 15 def airtel_money_id @airtel_money_id end |
#transaction_country_code ⇒ Object (readonly)
Returns the value of attribute transaction_country_code.
15 16 17 |
# File 'lib/airtel/pesa/refund_payment.rb', line 15 def transaction_country_code @transaction_country_code end |
#transaction_currency_code ⇒ Object (readonly)
Returns the value of attribute transaction_currency_code.
15 16 17 |
# File 'lib/airtel/pesa/refund_payment.rb', line 15 def transaction_currency_code @transaction_currency_code end |
Class Method Details
.call(airtel_money_id:, transaction_country_code:, transaction_currency_code:) ⇒ Object
17 18 19 |
# File 'lib/airtel/pesa/refund_payment.rb', line 17 def self.call(airtel_money_id:, transaction_country_code:, transaction_currency_code:) new(airtel_money_id, transaction_country_code, transaction_currency_code).call end |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/airtel/pesa/refund_payment.rb', line 27 def call url = URI("#{env_url}/standard/v1/payments/refund") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request["Authorization"] = "Bearer #{token}" request["X-Country"] = transaction_country_code request["X-Currency"] = transaction_currency_code request.body = JSON.dump(body) response = http.request(request) parsed_response = JSON.parse(response.read_body) result = Airtel::Pesa.to_recursive_ostruct(parsed_response) OpenStruct.new(result: result, error: nil) rescue JSON::ParserError => error OpenStruct.new(result: nil, error: error) end |