Class: Plaid::Transfer::Refund::Client
- Inherits:
-
Object
- Object
- Plaid::Transfer::Refund::Client
- Defined in:
- lib/plaid/transfer/refund/client.rb
Instance Method Summary collapse
-
#cancel(request_options: {}, **params) ⇒ Plaid::Types::TransferRefundCancelResponse
Use the
/transfer/refund/cancelendpoint to cancel a refund. -
#create(request_options: {}, **params) ⇒ Plaid::Types::TransferRefundCreateResponse
Use the
/transfer/refund/createendpoint to create a refund for a transfer. -
#get(request_options: {}, **params) ⇒ Plaid::Types::TransferRefundGetResponse
The
/transfer/refund/getendpoint fetches information about the refund corresponding to the givenrefund_id. - #initialize(client:) ⇒ void constructor
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/plaid/transfer/refund/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#cancel(request_options: {}, **params) ⇒ Plaid::Types::TransferRefundCancelResponse
Use the /transfer/refund/cancel endpoint to cancel a refund. A refund is eligible for cancellation if it
has not yet been submitted to the payment network.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/plaid/transfer/refund/client.rb', line 145 def cancel(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "transfer/refund/cancel", body: Plaid::Transfer::Refund::Types::TransferRefundCancelRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::TransferRefundCancelResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#create(request_options: {}, **params) ⇒ Plaid::Types::TransferRefundCreateResponse
Use the /transfer/refund/create endpoint to create a refund for a transfer. A transfer can be refunded if
the transfer was initiated in the past 180 days.
Refunds come out of the available balance of the ledger used for the original debit transfer. If there are not enough funds in the available balance to cover the refund amount, the refund will be rejected. Plaid does not impose a hold time before a refund can be created; you do not need to wait for the original transfer to settle.
A refund can still be issued even if the Item's access_token is no longer valid (e.g. if the user revoked
OAuth consent or the Item was deleted via /item/remove), as long as the account and routing number pair used
to make the original transaction is still valid. A refund cannot be issued if the Item has an invalidated
TAN, which can occur at Chase or PNC.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/plaid/transfer/refund/client.rb', line 43 def create(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "transfer/refund/create", body: Plaid::Transfer::Refund::Types::TransferRefundCreateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::TransferRefundCreateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#get(request_options: {}, **params) ⇒ Plaid::Types::TransferRefundGetResponse
The /transfer/refund/get endpoint fetches information about the refund corresponding to the given
refund_id.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/plaid/transfer/refund/client.rb', line 94 def get(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "transfer/refund/get", body: Plaid::Transfer::Refund::Types::TransferRefundGetRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::TransferRefundGetResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |