Class: Straddle::Resources::Charges
- Inherits:
-
Object
- Object
- Straddle::Resources::Charges
- Defined in:
- lib/straddle/resources/charges.rb,
sig/straddle/resources/charges.rbs
Overview
Charges debit a customer's bank account through a paykey.
Instance Method Summary collapse
-
#cancel(id, reason: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeCancelParams for more details.
-
#create(amount:, config:, consent_type:, currency:, description:, device:, external_id:, paykey:, payment_date:, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeCreateParams for more details.
-
#hold(id, reason: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeHoldParams for more details.
-
#initialize(client:) ⇒ Charges
constructor
private
A new instance of Charges.
-
#list_unmasked(id, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::UnmaskedChargeResponse
Return a charge with its sensitive fields unmasked.
-
#refund(id, amount: nil, description: nil, external_id: nil, metadata: nil, payment_date: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::PayoutResponse
Some parameter documentations has been truncated, see Models::ChargeRefundParams for more details.
-
#release(id, reason: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeReleaseParams for more details.
-
#resubmit(id, description: nil, external_id: nil, payment_date: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeResubmitParams for more details.
-
#retrieve(id, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Returns a charge by its unique identifier.
-
#update(id, amount:, description:, payment_date:, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeUpdateParams for more details.
-
#upload_authorization_proof(id, file:, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeUploadAuthorizationProofParams for more details.
Constructor Details
#initialize(client:) ⇒ Charges
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Charges.
456 457 458 |
# File 'lib/straddle/resources/charges.rb', line 456 def initialize(client:) @client = client end |
Instance Method Details
#cancel(id, reason: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeCancelParams for more details.
Cancels a charge. The charge must have a status of created, scheduled, or
on_hold.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/straddle/resources/charges.rb', line 173 def cancel(id, params = {}) parsed, = Straddle::ChargeCancelParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :put, path: ["v1/charges/%1$s/cancel", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |
#create(amount:, config:, consent_type:, currency:, description:, device:, external_id:, paykey:, payment_date:, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeCreateParams for more details.
Creates a charge against a customer's paykey. Straddle submits the charge for
processing on payment_date unless the charge is on hold.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/straddle/resources/charges.rb', line 48 def create(params) parsed, = Straddle::ChargeCreateParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :post, path: "v1/charges", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |
#hold(id, reason: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeHoldParams for more details.
Places a charge on hold to prevent submission for processing. The charge must
have a status of created or scheduled.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/straddle/resources/charges.rb', line 216 def hold(id, params = {}) parsed, = Straddle::ChargeHoldParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :put, path: ["v1/charges/%1$s/hold", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |
#list_unmasked(id, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::UnmaskedChargeResponse
Return a charge with its sensitive fields unmasked.
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/straddle/resources/charges.rb', line 251 def list_unmasked(id, params = {}) parsed, = Straddle::ChargeListUnmaskedParams.dump_request(params) @client.request( method: :get, path: ["v1/charges/%1$s/unmask", id], headers: parsed.transform_keys( correlation_id: "correlation-id", request_id: "request-id", straddle_account_id: "straddle-account-id" ), model: Straddle::UnmaskedChargeResponse, options: ) end |
#refund(id, amount: nil, description: nil, external_id: nil, metadata: nil, payment_date: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::PayoutResponse
Some parameter documentations has been truncated, see Models::ChargeRefundParams for more details.
Creates a payout to return funds from a paid charge to the customer's bank
account. The payout is linked to the charge through related_payments. A charge
can be refunded once, either fully or partially.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/straddle/resources/charges.rb', line 301 def refund(id, params = {}) parsed, = Straddle::ChargeRefundParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :post, path: ["v1/charges/%1$s/refund", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::PayoutResponse, options: ) end |
#release(id, reason: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeReleaseParams for more details.
Releases a charge from on_hold and returns it to created for submission on
payment_date.
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/straddle/resources/charges.rb', line 344 def release(id, params = {}) parsed, = Straddle::ChargeReleaseParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :put, path: ["v1/charges/%1$s/release", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |
#resubmit(id, description: nil, external_id: nil, payment_date: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeResubmitParams for more details.
Creates a new charge from a failed, reversed, or cancelled charge. The request
can override description, external_id, and payment_date. Other payment
details come from the original charge.
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/straddle/resources/charges.rb', line 392 def resubmit(id, params = {}) parsed, = Straddle::ChargeResubmitParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :post, path: ["v1/charges/%1$s/resubmit", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |
#retrieve(id, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Returns a charge by its unique identifier.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/straddle/resources/charges.rb', line 83 def retrieve(id, params = {}) parsed, = Straddle::ChargeRetrieveParams.dump_request(params) @client.request( method: :get, path: ["v1/charges/%1$s", id], headers: parsed.transform_keys( correlation_id: "correlation-id", request_id: "request-id", straddle_account_id: "straddle-account-id" ), model: Straddle::ChargeResponse, options: ) end |
#update(id, amount:, description:, payment_date:, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeUpdateParams for more details.
Updates the description, amount, payment_date, or metadata. The charge must
have a status of created or on_hold.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/straddle/resources/charges.rb', line 130 def update(id, params) parsed, = Straddle::ChargeUpdateParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :put, path: ["v1/charges/%1$s", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |
#upload_authorization_proof(id, file:, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::ChargeResponse
Some parameter documentations has been truncated, see Models::ChargeUploadAuthorizationProofParams for more details.
Uploads a proof-of-authorization document for a charge. A later upload adds another document and does not replace an existing one.
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/straddle/resources/charges.rb', line 435 def (id, params) parsed, = Straddle::ChargeUploadAuthorizationProofParams.dump_request(params) header_params = { correlation_id: "correlation-id", idempotency_key: "idempotency-key", request_id: "request-id", straddle_account_id: "straddle-account-id" } @client.request( method: :post, path: ["v1/charges/%1$s/authorization", id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Straddle::ChargeResponse, options: ) end |