Class: PCPServerSDK::Endpoints::PaymentInformationApiClient
- Inherits:
-
BaseApiClient
- Object
- BaseApiClient
- PCPServerSDK::Endpoints::PaymentInformationApiClient
- 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 Attribute Summary
Attributes inherited from BaseApiClient
Instance Method Summary collapse
-
#create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::PaymentInformationResponse
Create a payment information.
-
#get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id) ⇒ PCPServerSDK::Models::PaymentInformationResponse
Get a payment information.
-
#initialize(config, http_client = nil) ⇒ PaymentInformationApiClient
constructor
A new instance of PaymentInformationApiClient.
-
#refund_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id, payload) ⇒ PCPServerSDK::Models::PaymentInformationRefundResponse
Refund a payment information.
Constructor Details
#initialize(config, http_client = nil) ⇒ 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, http_client = nil) super(config, http_client) end |
Instance Method Details
#create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) ⇒ PCPServerSDK::Models::PaymentInformationResponse
Create a payment information
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-information") 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
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-information/#{payment_information_id}") request_init = { method: 'GET', headers: {} } response = make_api_call(url.to_s, request_init) deserialize_json(response, PCPServerSDK::Models::PaymentInformationResponse) end |
#refund_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id, payload) ⇒ PCPServerSDK::Models::PaymentInformationRefundResponse
Refund a payment information
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb', line 67 def refund_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id, payload) 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? raise TypeError, PAYLOAD_REQUIRED_ERROR if payload.nil? url = URI.join(get_config.host, "/v1/#{merchant_id}/commerce-cases/#{commerce_case_id}/checkouts/#{checkout_id}/payment-information/#{payment_information_id}/refund") 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::PaymentInformationRefundResponse) end |