Class: Io::Flow::V0::Clients::PaymentRequests

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PaymentRequests

Returns a new instance of PaymentRequests.



7467
7468
7469
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7467

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#get_by_id(organization, id) ⇒ Object

Returns information about a specific payment request



7480
7481
7482
7483
7484
7485
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7480

def get_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post(organization, payment_request_form) ⇒ Object

Creates a new payment



7472
7473
7474
7475
7476
7477
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7472

def post(organization, payment_request_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = payment_request_form; x.is_a?(::Io::Flow::V0::Models::PaymentRequestForm) ? x : ::Io::Flow::V0::Models::PaymentRequestForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests").with_json(payment_request_form.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_capture_by_id(organization, id, payment_capture_form) ⇒ Object

Captures payment



7498
7499
7500
7501
7502
7503
7504
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7498

def post_capture_by_id(organization, id, payment_capture_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_capture_form; x.is_a?(::Io::Flow::V0::Models::PaymentCaptureForm) ? x : ::Io::Flow::V0::Models::PaymentCaptureForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/capture").with_json(payment_capture_form.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_payment_and_method_and_data_by_id(organization, id, payment_method_data) ⇒ Object

Update the payment method data to progress the payment through relevant actions



7508
7509
7510
7511
7512
7513
7514
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7508

def post_payment_and_method_and_data_by_id(organization, id, payment_method_data)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_method_data; x.is_a?(::Io::Flow::V0::Models::PaymentMethodData) ? x : ::Io::Flow::V0::Models::PaymentMethodData.from_json(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/payment/method/data").with_json(payment_method_data.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_payment_method_data_by_id(organization, id, payment_method_data) ⇒ Object

Update the payment method data to progress the payment through relevant actions



7518
7519
7520
7521
7522
7523
7524
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7518

def post_payment_method_data_by_id(organization, id, payment_method_data)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_method_data; x.is_a?(::Io::Flow::V0::Models::PaymentMethodData) ? x : ::Io::Flow::V0::Models::PaymentMethodData.from_json(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/payment_method_data").with_json(payment_method_data.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_refund_and_reversal_by_id(organization, id) ⇒ Object

Reverses the authorization hold if the authorization is not captured yet otherwise refunds the payment entirely.



7537
7538
7539
7540
7541
7542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7537

def post_refund_and_reversal_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/refund/reversal").post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_refund_by_id(organization, id, payment_refund_form) ⇒ Object

Refunds the payment



7527
7528
7529
7530
7531
7532
7533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7527

def post_refund_by_id(organization, id, payment_refund_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_refund_form; x.is_a?(::Io::Flow::V0::Models::PaymentRefundForm) ? x : ::Io::Flow::V0::Models::PaymentRefundForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/refund").with_json(payment_refund_form.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_reversal_by_id(organization, id, payment_reversal_form) ⇒ Object

Reverses payment authorization



7545
7546
7547
7548
7549
7550
7551
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7545

def post_reversal_by_id(organization, id, payment_reversal_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_reversal_form; x.is_a?(::Io::Flow::V0::Models::PaymentReversalForm) ? x : ::Io::Flow::V0::Models::PaymentReversalForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/reversal").with_json(payment_reversal_form.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#post_reverse_by_id(organization, id, payment_reversal_form) ⇒ Object

Reverses payment authorization



7554
7555
7556
7557
7558
7559
7560
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7554

def post_reverse_by_id(organization, id, payment_reversal_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_reversal_form; x.is_a?(::Io::Flow::V0::Models::PaymentReversalForm) ? x : ::Io::Flow::V0::Models::PaymentReversalForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}/reverse").with_json(payment_reversal_form.to_json).post
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end

#put_by_id(organization, id, payment_request_form) ⇒ Object

Updates payment request, i.e. by adding authorization data or a new payment method



7489
7490
7491
7492
7493
7494
7495
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7489

def put_by_id(organization, id, payment_request_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  (x = payment_request_form; x.is_a?(::Io::Flow::V0::Models::PaymentRequestForm) ? x : ::Io::Flow::V0::Models::PaymentRequestForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/payment/requests/#{CGI.escape(id)}").with_json(payment_request_form.to_json).put
  ::Io::Flow::V0::Models::PaymentRequest.new(r)
end