solidgate-ruby-sdk 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d961fde0b15268aa678aa14a4578f1de1ad1585d3729c4bdc75168760825bc1
4
- data.tar.gz: bf319d42486fed3f868d17994da9041214c89daa63b02d24be45ea9afdd53ac7
3
+ metadata.gz: ba80035d65a601fc4acd8eef2809b188d165589931403b8fa2b7b05d8766b393
4
+ data.tar.gz: dcb4ec3eac2443669916e75eefcc040a65cfe00e271aab353473305b07c23b57
5
5
  SHA512:
6
- metadata.gz: 02e23da68d02d2af05bc92880877f671c59c7eb55290e46bb5657207f3c8360fc19c1d31a4df8f0237e9f4fadf381270db3cec098b3ab0df80a1aa04ac21fb31
7
- data.tar.gz: c2fa5f81f3d65fab20906c03f427fd15848962b3052801e6148871b02bfe4068547dcee3c45da97a428d905944094c208febcb9b8ffa2bb4b47e2c3aa4c0b298
6
+ metadata.gz: 46322d80c7d7694a1e662be9545740af7fb16f2bb6b6d4189476a17ba01d7f65cba006ad22e3c7986c755ed8d5333bc16d7557bff30ce26560984cacf5f16d63
7
+ data.tar.gz: bfa35892c6ec90740614e4d773abe38e22d800b52196ff5b287135d8ca0214f95ba66d673eb613c76147a7fc2371d3db3c08494030bb35842433529106f07cc7
data/CHANGELOG.md CHANGED
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.10] - 2026-02-03
11
+ - Added refund method example to README
12
+
10
13
  ## [0.1.9] - 2026-02-03
11
14
  - Added documentation for restore_subscription method
12
15
  - Added restore_subscription to README.md usage examples
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solidgate-ruby-sdk (0.1.9)
4
+ solidgate-ruby-sdk (0.1.11)
5
5
  faraday
6
6
  faraday-multipart
7
7
 
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/solidgate-ruby-sdk.svg)](https://badge.fury.io/rb/solidgate-ruby-sdk)
2
+
1
3
  # Solidgate Ruby SDK
2
4
 
3
5
  A Ruby (unofficial) SDK for integrating with the Solidgate payment gateway API.
@@ -101,11 +103,8 @@ client.capture_payment('payment_id_123', amount: 500)
101
103
  # Void an authorized payment (before settlement)
102
104
  client.void_payment('payment_id_123')
103
105
 
104
- # Refund a captured payment
105
- client.refund_payment('payment_id_123')
106
-
107
- # Partial refund
108
- client.refund_payment('payment_id_123', amount: 500, reason: 'Customer request')
106
+ # Refund by order ID (pay.solidgate.com)
107
+ client.refund(order_id: 'order_123', amount: 1000)
109
108
  ```
110
109
 
111
110
  ### Subscription Management
@@ -140,6 +139,15 @@ client.cancel_subscription(
140
139
  client.restore_subscription(
141
140
  subscription_id: 'sub_123'
142
141
  )
142
+
143
+ ### Update subscription payment method
144
+
145
+ # Update the payment token associated with an existing subscription
146
+ client.update_subscription_payment_method(
147
+ subscription_id: 'sub_123',
148
+ token: 'tok_abc123'
149
+ )
150
+
143
151
  ```
144
152
 
145
153
  ### Subscription Pause Scheduling
@@ -60,7 +60,7 @@ module Solidgate
60
60
  # @raise [AuthenticationError] if API credentials are invalid
61
61
  #
62
62
  def create_payment(params)
63
- post("/v1/charge", params)
63
+ post("/v1/charge", body: params)
64
64
  end
65
65
 
66
66
  # Retrieves payment details and current status.
@@ -88,7 +88,7 @@ module Solidgate
88
88
  # @raise [InvalidRequestError] if payment cannot be captured (wrong status, already captured, etc.)
89
89
  #
90
90
  def capture_payment(payment_id, params = {})
91
- post("/v1/charge/#{payment_id}/capture", params)
91
+ post("/v1/charge/#{payment_id}/capture", body: params)
92
92
  end
93
93
 
94
94
  # Voids a payment that has not yet been settled.
@@ -113,7 +113,7 @@ module Solidgate
113
113
  # @raise [InvalidRequestError] if payment cannot be refunded
114
114
  #
115
115
  def refund_payment(payment_id, params = {})
116
- post("/v1/charge/#{payment_id}/refund", params)
116
+ post("/v1/charge/#{payment_id}/refund", body: params)
117
117
  end
118
118
 
119
119
  # Settles a payment for final processing.
@@ -138,7 +138,7 @@ module Solidgate
138
138
  # @raise [InvalidRequestError] if subscription parameters are invalid
139
139
  #
140
140
  def create_subscription(params)
141
- post("/v1/subscription", params)
141
+ post("/v1/subscription", body: params)
142
142
  end
143
143
 
144
144
  # Retrieves the current status and details of a subscription.
@@ -152,7 +152,7 @@ module Solidgate
152
152
  # @raise [InvalidRequestError] if subscription_id is not found
153
153
  #
154
154
  def subscription_status(subscription_id)
155
- post("/api/v1/subscription/status", { subscription_id: subscription_id })
155
+ post("/api/v1/subscription/status", body: { subscription_id: subscription_id })
156
156
  end
157
157
 
158
158
  # Switches a subscription to a different product/plan.
@@ -171,7 +171,7 @@ module Solidgate
171
171
  # )
172
172
  #
173
173
  def switch_subscription_product(params)
174
- post("/api/v1/subscription/switch-subscription-product", params)
174
+ post("/api/v1/subscription/switch-subscription-product", body: params)
175
175
  end
176
176
 
177
177
  # Updates an existing pause schedule for a subscription.
@@ -184,7 +184,7 @@ module Solidgate
184
184
  # @raise [InvalidRequestError] if subscription has no pause schedule or params are invalid
185
185
  #
186
186
  def update_subscription_pause(subscription_id, params)
187
- patch("/api/v1/subscriptions/#{subscription_id}/pause-schedule", params)
187
+ patch("/api/v1/subscriptions/#{subscription_id}/pause-schedule", body: params)
188
188
  end
189
189
 
190
190
  # Creates a pause schedule for a subscription.
@@ -198,7 +198,7 @@ module Solidgate
198
198
  # @raise [InvalidRequestError] if subscription is invalid or already has a pause schedule
199
199
  #
200
200
  def create_subscription_pause(subscription_id, params)
201
- post("/api/v1/subscriptions/#{subscription_id}/pause-schedule", params)
201
+ post("/api/v1/subscriptions/#{subscription_id}/pause-schedule", body: params)
202
202
  end
203
203
 
204
204
  # Deletes/cancels a pending pause schedule for a subscription.
@@ -221,7 +221,7 @@ module Solidgate
221
221
  # @raise [InvalidRequestError] if subscription is invalid or already cancelled
222
222
  #
223
223
  def cancel_subscription(params)
224
- post("/api/v1/subscription/cancel", params)
224
+ post("/api/v1/subscription/cancel", body: params)
225
225
  end
226
226
 
227
227
  # Creates a new product in the Solidgate catalog.
@@ -234,7 +234,7 @@ module Solidgate
234
234
  # @raise [InvalidRequestError] if product parameters are invalid
235
235
  #
236
236
  def create_product(params)
237
- post("/api/v1/products", params)
237
+ post("/api/v1/products", body: params)
238
238
  end
239
239
 
240
240
  # Creates a new price for an existing product.
@@ -248,7 +248,7 @@ module Solidgate
248
248
  # @raise [InvalidRequestError] if product_id is invalid or price params are invalid
249
249
  #
250
250
  def create_price(product_id, params)
251
- post("/api/v1/products/#{product_id}/prices", params)
251
+ post("/api/v1/products/#{product_id}/prices", body: params)
252
252
  end
253
253
 
254
254
  # Retrieves all products from the Solidgate catalog.
@@ -322,7 +322,39 @@ module Solidgate
322
322
  # client.restore_subscription(subscription_id: 'sub_12345')
323
323
  #
324
324
  def restore_subscription(params)
325
- post("/api/v1/subscription/restore", params)
325
+ post("/api/v1/subscription/restore", body: params)
326
+ end
327
+
328
+ # Creates a refund for a transaction.
329
+ #
330
+ # @param params [Hash] refund parameters:
331
+ # - :order_id [String] the order identifier to refund
332
+ # - :amount [Integer] refund amount in minor units (for partial refunds)
333
+ # @return [Hash] refund response including refund status and details
334
+ # @raise [InvalidRequestError] if refund parameters are invalid
335
+ #
336
+ # @example Create a refund
337
+ # client.refund(order_id: 'ord_12345', amount: 1000)
338
+ #
339
+ def refund(params)
340
+ post("/api/v1/refund", body: params, base_url: "https://pay.solidgate.com")
341
+ end
342
+
343
+ # Updates the payment method (token) associated with an existing subscription.
344
+ #
345
+ # @param params [Hash] update parameters including:
346
+ # - :subscription_id [String] the subscription to update
347
+ # - :token [String] new payment token / payment method identifier
348
+ # @return [Hash] response from the API with updated subscription/payment method details
349
+ # @raise [InvalidRequestError] if params are invalid
350
+ #
351
+ # @example Update a subscription's payment method
352
+ # client.update_subscription_payment_method(
353
+ # subscription_id: 'sub_123',
354
+ # token: 'tok_abc123'
355
+ # )
356
+ def update_subscription_payment_method(params)
357
+ post("/api/v1/subscription/update-token", body: params)
326
358
  end
327
359
 
328
360
  private
@@ -347,8 +379,17 @@ module Solidgate
347
379
  # @return [Faraday::Connection] configured HTTP connection
348
380
  #
349
381
  def connection
350
- @connection ||= Faraday.new(
351
- url: config.api_url,
382
+ @connection ||= connection_for(config.api_url)
383
+ end
384
+
385
+ # Creates a Faraday HTTP connection for the specified base URL.
386
+ #
387
+ # @param base_url [String] the base URL for the connection
388
+ # @return [Faraday::Connection] configured HTTP connection
389
+ #
390
+ def connection_for(base_url)
391
+ Faraday.new(
392
+ url: base_url,
352
393
  headers: default_headers
353
394
  ) do |conn|
354
395
  conn.request :multipart
@@ -386,10 +427,11 @@ module Solidgate
386
427
  #
387
428
  # @param path [String] API endpoint path
388
429
  # @param body [Hash] request body parameters
430
+ # @param base_url [String, nil] optional base URL to override the default API URL
389
431
  # @return [Hash] parsed response body
390
432
  #
391
- def post(path, body = {})
392
- request(:post, path, body)
433
+ def post(path, body: {}, base_url: nil)
434
+ request(:post, path, body: body, base_url: base_url)
393
435
  end
394
436
 
395
437
  # Performs a PATCH request to the specified path.
@@ -398,8 +440,8 @@ module Solidgate
398
440
  # @param body [Hash] request body parameters
399
441
  # @return [Hash] parsed response body
400
442
  #
401
- def patch(path, body = {})
402
- request(:patch, path, body)
443
+ def patch(path, body: {})
444
+ request(:patch, path, body: body)
403
445
  end
404
446
 
405
447
  # Performs a DELETE request to the specified path.
@@ -416,16 +458,19 @@ module Solidgate
416
458
  # @param method [Symbol] HTTP method (:get, :post, :patch, :delete)
417
459
  # @param path [String] API endpoint path
418
460
  # @param body [Hash, nil] optional request body
461
+ # @param base_url [String, nil] optional base URL to override the default API URL
419
462
  # @return [Hash] parsed response body
420
463
  # @raise [TimeoutError] if request times out
421
464
  # @raise [ConnectionError] if connection fails
422
465
  # @raise [Error] for other unexpected errors
423
466
  #
424
- def request(method, path, body = nil)
467
+ def request(method, path, body: nil, base_url: nil)
425
468
  body_json = body ? JSON.generate(body) : ''
426
469
  signature = generate_signature(body_json)
427
470
 
428
- response = connection.send(method) do |req|
471
+ conn = base_url ? connection_for(base_url) : connection
472
+
473
+ response = conn.send(method) do |req|
429
474
  req.url path
430
475
  req.headers["Merchant"] = config.public_key
431
476
  req.headers["Signature"] = signature
@@ -64,14 +64,15 @@ module Solidgate
64
64
  # @param amount [Integer] amount to refund in cents (optional, defaults to full amount)
65
65
  # @param reason [String] refund reason (optional)
66
66
  # @return [Hash] refund response
67
- def refund(payment_id, amount: nil, reason: nil)
68
- raise ArgumentError, "payment_id is required" if payment_id.nil? || payment_id.empty?
67
+ def refund(order_id, amount: nil, reason: nil)
68
+ raise ArgumentError, "order_id is required" if order_id.nil? || order_id.empty?
69
69
 
70
70
  params = {}
71
- params[:amount] = amount if amount
72
- params[:reason] = reason if reason
71
+ params[:amount] = amount if amount
72
+ params[:reason] = reason if reason
73
+ params[:order_id] = order_id
73
74
 
74
- client.refund_payment(payment_id, params)
75
+ client.refund(params)
75
76
  end
76
77
 
77
78
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solidgate
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidgate-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hector Carrillo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-02-03 00:00:00.000000000 Z
11
+ date: 2026-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday