Class: Transbank::Onepay::Refund
- Inherits:
-
Object
- Object
- Transbank::Onepay::Refund
- Extended by:
- Utils::NetHelper, Utils::RequestBuilder
- Defined in:
- lib/transbank/sdk/onepay/models/refund.rb
Constant Summary collapse
- REFUND_TRANSACTION =
Manages Refunds
'nullifytransaction'.freeze
- TRANSACTION_BASE_PATH =
'/ewallet-plugin-api-services/services/transactionservice/'.freeze
Class Method Summary collapse
-
.create(amount:, occ:, external_unique_number:, authorization_code:, options: nil) ⇒ Object
Create a request for a Refund [Transaction] to be refunded will be refunded is successfully committed (with the #commit method of [Transaction]).
-
.refund_path ⇒ String
Return the string url to POST to.
Methods included from Utils::NetHelper
http_delete, http_get, http_post, http_put, keys_to_camel_case, patpass_comercio_headers, snake_to_camel_case, webpay_headers
Class Method Details
.create(amount:, occ:, external_unique_number:, authorization_code:, options: nil) ⇒ Object
Create a request for a Refund
- Transaction
-
to be refunded
will be refunded is successfully committed (with the #commit method of [Transaction])
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/transbank/sdk/onepay/models/refund.rb', line 21 def create(amount:, occ:, external_unique_number:, authorization_code:, options: nil) refund_request = refund_transaction(refund_amount: amount, occ: occ, external_unique_number: external_unique_number, authorization_code: , options: ) response = http_post(uri_string: refund_path, body: refund_request.to_h) if response.nil? || !JSON.parse(response.body)['responseCode'] raise Errors::RefundCreateError, 'Could not obtain a response from the service.' end refund_create_response = RefundCreateResponse.new(JSON.parse(response.body)) unless refund_create_response.response_ok? raise Errors::RefundCreateError, refund_create_response.full_description end refund_create_response end |
.refund_path ⇒ String
Return the string url to POST to
43 44 45 |
# File 'lib/transbank/sdk/onepay/models/refund.rb', line 43 def refund_path Base.current_integration_type_url + TRANSACTION_BASE_PATH + REFUND_TRANSACTION end |