Class: DevDraftAI::TestPaymentsApi
- Inherits:
-
Object
- Object
- DevDraftAI::TestPaymentsApi
- Defined in:
- lib/devdraft/api/test_payments_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#initialize(api_client = ApiClient.default) ⇒ TestPaymentsApi
constructor
A new instance of TestPaymentsApi.
-
#test_payment_controller_create_payment_v0(body, idempotency_key, opts = {}) ⇒ PaymentResponseDto
Process a test payment Creates a new payment.
-
#test_payment_controller_create_payment_v0_with_http_info(body, idempotency_key, opts = {}) ⇒ Array<(PaymentResponseDto, Integer, Hash)>
Process a test payment Creates a new payment.
-
#test_payment_controller_get_payment_v0(id, opts = {}) ⇒ PaymentResponseDto
Get payment details by ID.
-
#test_payment_controller_get_payment_v0_with_http_info(id, opts = {}) ⇒ Array<(PaymentResponseDto, Integer, Hash)>
Get payment details by ID.
-
#test_payment_controller_refund_payment_v0(id, idempotency_key, opts = {}) ⇒ RefundResponseDto
Refund a payment Refunds an existing payment.
-
#test_payment_controller_refund_payment_v0_with_http_info(id, idempotency_key, opts = {}) ⇒ Array<(RefundResponseDto, Integer, Hash)>
Refund a payment Refunds an existing payment.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ TestPaymentsApi
Returns a new instance of TestPaymentsApi.
16 17 18 |
# File 'lib/devdraft/api/test_payments_api.rb', line 16 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
14 15 16 |
# File 'lib/devdraft/api/test_payments_api.rb', line 14 def api_client @api_client end |
Instance Method Details
#test_payment_controller_create_payment_v0(body, idempotency_key, opts = {}) ⇒ PaymentResponseDto
Process a test payment Creates a new payment. Requires an idempotency key to prevent duplicate payments on retry. ## Idempotency Key Best Practices 1. **Generate unique keys**: Use UUIDs or similar unique identifiers, prefixed with a descriptive operation name 2. **Store keys client-side**: Save the key with the original request so you can retry with the same key 3. **Key format**: Between 6-64 alphanumeric characters 4. Expiration: Keys expire after 24 hours by default 5. **Use case**: Perfect for ensuring payment operations are never processed twice, even during network failures ## Example Request (curl) “‘bash curl -X POST \ api.example.com/rest-api/v0/test-payment \ -H ’Content-Type: application/json’ \ -H ‘Client-Key: your-api-key’ \ -H ‘Client-Secret: your-api-secret’ \ -H ‘Idempotency-Key: payment_123456_unique_key’ \ -d ‘{ "amount": 100.00, "currency": "USD", "description": "Test payment for order #12345", "customerId": "cus_12345" }’ “‘ ## Example Response (First Request) “`json { "id": "pay_abc123xyz456", "amount": 100.00, "currency": "USD", "status": "succeeded", "timestamp": "2023-07-01T12:00:00.000Z" } “` ## Example Response (Duplicate Request) The exact same response will be returned for any duplicate request with the same idempotency key, without creating a new payment. ## Retry Scenario Example Network failure during payment submission: 1. Client creates payment request with idempotency key: "payment_123456_unique_key" 2. Request begins processing, but network connection fails before response received 3. Client retries the exact same request with the same idempotency key 4. Server detects duplicate idempotency key and returns the result of the first request 5. No duplicate payment is created If you retry with same key but different parameters (e.g., different amount), you’ll receive a 409 Conflict error.
25 26 27 28 |
# File 'lib/devdraft/api/test_payments_api.rb', line 25 def test_payment_controller_create_payment_v0(body, idempotency_key, opts = {}) data, _status_code, _headers = test_payment_controller_create_payment_v0_with_http_info(body, idempotency_key, opts) data end |
#test_payment_controller_create_payment_v0_with_http_info(body, idempotency_key, opts = {}) ⇒ Array<(PaymentResponseDto, Integer, Hash)>
Process a test payment Creates a new payment. Requires an idempotency key to prevent duplicate payments on retry. ## Idempotency Key Best Practices 1. **Generate unique keys**: Use UUIDs or similar unique identifiers, prefixed with a descriptive operation name 2. **Store keys client-side**: Save the key with the original request so you can retry with the same key 3. **Key format**: Between 6-64 alphanumeric characters 4. Expiration: Keys expire after 24 hours by default 5. **Use case**: Perfect for ensuring payment operations are never processed twice, even during network failures ## Example Request (curl) ```bash curl -X POST \ api.example.com/rest-api/v0/test-payment \ -H 'Content-Type: application/json' \ -H 'Client-Key: your-api-key' \ -H 'Client-Secret: your-api-secret' \ -H 'Idempotency-Key: payment_123456_unique_key' \ -d '{ "amount": 100.00, "currency": "USD", "description": "Test payment for order #12345", "customerId": "cus_12345" }' ``` ## Example Response (First Request) ```json { "id": "pay_abc123xyz456", "amount": 100.00, "currency": "USD", "status": "succeeded", "timestamp": "2023-07-01T12:00:00.000Z" } ``` ## Example Response (Duplicate Request) The exact same response will be returned for any duplicate request with the same idempotency key, without creating a new payment. ## Retry Scenario Example Network failure during payment submission: 1. Client creates payment request with idempotency key: "payment_123456_unique_key" 2. Request begins processing, but network connection fails before response received 3. Client retries the exact same request with the same idempotency key 4. Server detects duplicate idempotency key and returns the result of the first request 5. No duplicate payment is created If you retry with same key but different parameters (e.g., different amount), you'll receive a 409 Conflict error.
36 37 38 39 40 41 42 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 78 79 80 81 82 83 |
# File 'lib/devdraft/api/test_payments_api.rb', line 36 def test_payment_controller_create_payment_v0_with_http_info(body, idempotency_key, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TestPaymentsApi.test_payment_controller_create_payment_v0 ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling TestPaymentsApi.test_payment_controller_create_payment_v0" end # verify the required parameter 'idempotency_key' is set if @api_client.config.client_side_validation && idempotency_key.nil? fail ArgumentError, "Missing the required parameter 'idempotency_key' when calling TestPaymentsApi.test_payment_controller_create_payment_v0" end # resource path local_var_path = '/api/v0/test-payment' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params[:'idempotency-key'] = idempotency_key # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(body) return_type = opts[:return_type] || 'PaymentResponseDto' auth_names = opts[:auth_names] || [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type) if @api_client.config.debugging @api_client.config.logger.debug "API called: TestPaymentsApi#test_payment_controller_create_payment_v0\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#test_payment_controller_get_payment_v0(id, opts = {}) ⇒ PaymentResponseDto
Get payment details by ID
88 89 90 91 |
# File 'lib/devdraft/api/test_payments_api.rb', line 88 def test_payment_controller_get_payment_v0(id, opts = {}) data, _status_code, _headers = test_payment_controller_get_payment_v0_with_http_info(id, opts) data end |
#test_payment_controller_get_payment_v0_with_http_info(id, opts = {}) ⇒ Array<(PaymentResponseDto, Integer, Hash)>
Get payment details by ID
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 129 130 131 132 133 134 135 136 137 |
# File 'lib/devdraft/api/test_payments_api.rb', line 97 def test_payment_controller_get_payment_v0_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TestPaymentsApi.test_payment_controller_get_payment_v0 ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling TestPaymentsApi.test_payment_controller_get_payment_v0" end # resource path local_var_path = '/api/v0/test-payment/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] return_type = opts[:return_type] || 'PaymentResponseDto' auth_names = opts[:auth_names] || [] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type) if @api_client.config.debugging @api_client.config.logger.debug "API called: TestPaymentsApi#test_payment_controller_get_payment_v0\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#test_payment_controller_refund_payment_v0(id, idempotency_key, opts = {}) ⇒ RefundResponseDto
Refund a payment Refunds an existing payment. Requires an idempotency key to prevent duplicate refunds on retry. ## Idempotency Key Benefits for Refunds Refunds are critical financial operations where duplicates can cause serious issues. Using idempotency keys ensures: 1. **Prevent duplicate refunds**: Even if a request times out or fails, retrying with the same key won’t issue multiple refunds 2. **Safe retries**: Network failures or timeouts won’t risk creating multiple refunds 3. **Consistent response**: Always get the same response for the same operation ## Example Request (curl) “‘bash curl -X POST \ api.example.com/rest-api/v0/test-payment/pay_abc123xyz456/refund \ -H ’Content-Type: application/json’ \ -H ‘Client-Key: your-api-key’ \ -H ‘Client-Secret: your-api-secret’ \ -H ‘Idempotency-Key: refund_123456_unique_key’ “‘ ## Example Response (First Request) “`json { "id": "ref_xyz789", "paymentId": "pay_abc123xyz456", "amount": 100.00, "status": "succeeded", "timestamp": "2023-07-01T14:30:00.000Z" } “` ## Example Response (Duplicate Request) The exact same response will be returned for any duplicate request with the same idempotency key, without creating a new refund. ## Idempotency Key Guidelines - Use a unique key for each distinct refund operation - Store keys client-side to ensure you can retry with the same key if needed - Keys expire after 24 hours by default
144 145 146 147 |
# File 'lib/devdraft/api/test_payments_api.rb', line 144 def test_payment_controller_refund_payment_v0(id, idempotency_key, opts = {}) data, _status_code, _headers = test_payment_controller_refund_payment_v0_with_http_info(id, idempotency_key, opts) data end |
#test_payment_controller_refund_payment_v0_with_http_info(id, idempotency_key, opts = {}) ⇒ Array<(RefundResponseDto, Integer, Hash)>
Refund a payment Refunds an existing payment. Requires an idempotency key to prevent duplicate refunds on retry. ## Idempotency Key Benefits for Refunds Refunds are critical financial operations where duplicates can cause serious issues. Using idempotency keys ensures: 1. **Prevent duplicate refunds**: Even if a request times out or fails, retrying with the same key won't issue multiple refunds 2. **Safe retries**: Network failures or timeouts won't risk creating multiple refunds 3. **Consistent response**: Always get the same response for the same operation ## Example Request (curl) ```bash curl -X POST \ api.example.com/rest-api/v0/test-payment/pay_abc123xyz456/refund \ -H 'Content-Type: application/json' \ -H 'Client-Key: your-api-key' \ -H 'Client-Secret: your-api-secret' \ -H 'Idempotency-Key: refund_123456_unique_key' ``` ## Example Response (First Request) ```json { "id": "ref_xyz789", "paymentId": "pay_abc123xyz456", "amount": 100.00, "status": "succeeded", "timestamp": "2023-07-01T14:30:00.000Z" } ``` ## Example Response (Duplicate Request) The exact same response will be returned for any duplicate request with the same idempotency key, without creating a new refund. ## Idempotency Key Guidelines - Use a unique key for each distinct refund operation - Store keys client-side to ensure you can retry with the same key if needed - Keys expire after 24 hours by default
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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/devdraft/api/test_payments_api.rb', line 155 def test_payment_controller_refund_payment_v0_with_http_info(id, idempotency_key, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TestPaymentsApi.test_payment_controller_refund_payment_v0 ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling TestPaymentsApi.test_payment_controller_refund_payment_v0" end # verify the required parameter 'idempotency_key' is set if @api_client.config.client_side_validation && idempotency_key.nil? fail ArgumentError, "Missing the required parameter 'idempotency_key' when calling TestPaymentsApi.test_payment_controller_refund_payment_v0" end # resource path local_var_path = '/api/v0/test-payment/{id}/refund'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'idempotency-key'] = idempotency_key # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] return_type = opts[:return_type] || 'RefundResponseDto' auth_names = opts[:auth_names] || [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type) if @api_client.config.debugging @api_client.config.logger.debug "API called: TestPaymentsApi#test_payment_controller_refund_payment_v0\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |