Skip to main content

Creating a Subscription

require 'chargeover_ruby'

# Initialize the client
client = ChargeOver::Client.new("https://your-chargeover-url.com", "your_api_key", "your_api_secret")

# Define invoice data
subscription_data = {
'customer_id' => "12345", # Replace with the actual customer ID
'line_items' => [
{
'description' => "Service Charge",
'amount' => 100.00,
'quantity' => 1
}
],
'due_date' => "2024-12-31"
}

# Create the invoice
response = client.create(:package, subscription_data)

# Check if successful
if response['status'] == 'success'
puts "Subscription created successfully: #{response['response']}"
else
puts "Error: #{response['error']}"
end