Class: PCPServerSDK::Endpoints::PaymentInformationApiClient

Inherits:
BaseApiClient
  • Object
show all
Defined in:
lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb

Constant Summary collapse

PAYMENT_INFORMATION_ID_REQUIRED_ERROR =
'Payment Information ID is required'

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PaymentInformationApiClient

Returns a new instance of PaymentInformationApiClient.



14
15
16
# File 'lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb', line 14

def initialize(config)
  super(config)
end

Instance Method Details

#create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::PaymentInformationResponse

Create a payment information

Parameters:

  • merchant_id (String)

    The merchant identifier

  • commerce_case_id (String)

    The commerce case identifier

  • checkout_id (String)

    The checkout identifier

  • payload (PCPServerSDK::Models::PaymentInformationRequest)

    The payment information request

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb', line 24

def create_payment_information(merchant_id, commerce_case_id, checkout_id, payload)
  validate_ids(merchant_id, commerce_case_id, checkout_id)

  url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}/payment-informations")

  request_init = {
    method: 'POST',
    headers: { 'Content-Type' => 'application/json' },
    body: JSON.generate(payload)
  }

  response = make_api_call(url.to_s, request_init)
  deserialize_json(response, PCPServerSDK::Models::PaymentInformationResponse)
end

#get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id) ⇒ PCPServerSDK::Models::PaymentInformationResponse

Get a payment information

Parameters:

  • merchant_id (String)

    The merchant identifier

  • commerce_case_id (String)

    The commerce case identifier

  • checkout_id (String)

    The checkout identifier

  • payment_information_id (String)

    The payment information identifier

Returns:

Raises:

  • (TypeError)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb', line 45

def get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id)
  validate_ids(merchant_id, commerce_case_id, checkout_id)
  raise TypeError, PAYMENT_INFORMATION_ID_REQUIRED_ERROR if payment_information_id.nil? || payment_information_id.empty?

  url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}/payment-informations/#{payment_information_id}")

  request_init = {
    method: 'GET',
    headers: {}
  }

  response = make_api_call(url.to_s, request_init)
  deserialize_json(response, PCPServerSDK::Models::PaymentInformationResponse)
end