Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
pull_request:
branches: [master, main]
push:
branches: [master, main]

jobs:
test:
name: Ruby Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true # Caches gems for faster builds

- name: Install dependencies
run: bundle install --jobs 4 --retry 3

- name: Run RSpec tests
run: bundle exec rspec --format documentation --color

lint:
name: RuboCop Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Install dependencies
run: bundle install --jobs 4 --retry 3

- name: Run RuboCop
run: bundle exec rubocop --parallel
continue-on-error: true # Don't fail the build on lint warnings
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.9] - 2026-02-03
- Added documentation for restore_subscription method
- Added restore_subscription to README.md usage examples
- Added tests for restore_subscription method

## [0.1.4] - 2026-01-14
- Client Specs enhancements

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
solidgate-ruby-sdk (0.1.8)
solidgate-ruby-sdk (0.1.9)
faraday
faraday-multipart

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ client.cancel_subscription(
cancel_at_period_end: true,
reason: 'Customer requested cancellation'
)

# Restore a cancelled subscription
client.restore_subscription(
subscription_id: 'sub_123'
)
```

### Subscription Pause Scheduling
Expand Down
18 changes: 18 additions & 0 deletions lib/solidgate/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,24 @@ def generate_signature(json_string, public_key: config.public_key, private_key:
Base64.strict_encode64(instance.hexdigest)
end

# Restores a previously cancelled subscription.
# Use this to reactivate a subscription that was cancelled but is still within
# the restoration period.
#
# @param params [Hash] restoration parameters:
# - :subscription_id [String] the subscription identifier to restore
# @return [Hash] restored subscription details including:
# - :id [String] subscription identifier
# - :status [String] new subscription status (typically 'active')
# @raise [InvalidRequestError] if subscription cannot be restored (expired, already active, etc.)
#
# @example Restore a cancelled subscription
# client.restore_subscription(subscription_id: 'sub_12345')
#
def restore_subscription(params)
post("/api/v1/subscription/restore", params)
end

private

# Builds a Configuration object from the provided options.
Expand Down
2 changes: 1 addition & 1 deletion lib/solidgate/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Solidgate
VERSION = "0.1.8"
VERSION = "0.1.9"
end
34 changes: 34 additions & 0 deletions spec/solidgate/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,40 @@
end
end

describe "#restore_subscription" do
let(:restore_params) do
{
subscription_id: "sub_123"
}
end

it "sends POST request to /api/v1/subscription/restore" do
client.restore_subscription(restore_params)

expect(WebMock).to have_requested(:post, "https://subscriptions.solidgate.com/api/v1/subscription/restore")
.with(body: restore_params.to_json)
end

it "includes Merchant header with public key" do
client.restore_subscription(restore_params)

expect(WebMock).to have_requested(:post, "https://subscriptions.solidgate.com/api/v1/subscription/restore")
.with(headers: { "Merchant" => public_key })
end

it "includes Signature header" do
client.restore_subscription(restore_params)

expect(WebMock).to have_requested(:post, "https://subscriptions.solidgate.com/api/v1/subscription/restore")
.with { |req| !req.headers["Signature"].nil? && !req.headers["Signature"].empty? }
end

it "returns restored subscription response" do
result = client.restore_subscription(restore_params)
expect(result).to eq(success_response)
end
end

# ==================== Product Methods ====================

describe "#create_product" do
Expand Down
Loading