usage_credits

Demo app for the 💳✨ usage_credits gem

The basics: get and spend credits

 

Subscribe to a plan: Buy credit packs: Get arbitrary bonuses: Spend credits:

Ledger status

Date Amount Category Expiration
Dec 05, 6:16 AM +5100 credits credit_pack_purchase –
Dec 05, 6:17 AM +10 credits bonus expiring_bonus_credits 🗑️ expired
Dec 05, 6:19 AM +1000 credits credit_pack_purchase –
Dec 05, 6:19 AM +10 credits signup_bonus signup –
Dec 05, 8:07 AM +10 credits subscription_credits first_cycle expires in about 1 month
Dec 05, 9:50 AM +5100 credits credit_pack_purchase –
Dec 05, 6:17 PM +10 credits subscription_credits first_cycle expires in about 1 month
Dec 05, 10:17 PM +10 credits credit_pack_purchase –
Dec 05, 10:17 PM +20 credits referral_bonus referral –
Dec 05, 10:18 PM +10 credits subscription_credits first_cycle expires in about 1 month
Dec 05, 10:18 PM +10 credits signup_bonus signup –
Dec 05, 10:18 PM +5100 credits credit_pack_purchase –

Payment records (pay gem)

The user has paid $646.99 total

Pay::Charge (5)
# {
                        :id => 4417,
               :customer_id => 6040,
           :subscription_id => nil,
              :processor_id => "X-b4d7XsF2V3edsC-_lVO",
                    :amount => 99,
                  :currency => nil,
    :application_fee_amount => nil,
           :amount_refunded => nil,
                  :metadata => {
         "purchase_type" => "credit_pack",
             "pack_name" => "tiny",
               "credits" => 10,
         "bonus_credits" => 0,
           "price_cents" => 99,
        "price_currency" => "USD"
    },
                      :data => {
        "payment_method_type" => "card",
                      "brand" => "Fake",
                      "last4" => 1234,
                  "exp_month" => 12,
                   "exp_year" => 2026
    },
            :stripe_account => nil,
                :created_at => 2026-12-05 22:17:34.307039000 UTC +00:00,
                :updated_at => 2026-12-05 22:17:34.307039000 UTC +00:00,
                      :type => "Pay::FakeProcessor::Charge"
}
# {
                        :id => 4415,
               :customer_id => 6040,
           :subscription_id => nil,
              :processor_id => "prRxTCnEBWVLNPwNmEoVW",
                    :amount => 4900,
                  :currency => nil,
    :application_fee_amount => nil,
           :amount_refunded => nil,
                  :metadata => {
         "purchase_type" => "credit_pack",
             "pack_name" => "starter",
               "credits" => 1000,
         "bonus_credits" => 0,
           "price_cents" => 4900,
        "price_currency" => "USD"
    },
                      :data => {
        "payment_method_type" => "card",
                      "brand" => "Fake",
                      "last4" => 1234,
                  "exp_month" => 12,
                   "exp_year" => 2026
    },
            :stripe_account => nil,
                :created_at => 2026-12-05 06:19:09.416224000 UTC +00:00,
                :updated_at => 2026-12-05 06:19:09.416224000 UTC +00:00,
                      :type => "Pay::FakeProcessor::Charge"
}
# {
                        :id => 4414,
               :customer_id => 6040,
           :subscription_id => nil,
              :processor_id => "saWuT4lgv8fS1SYX4CzK2",
                    :amount => 19900,
                  :currency => nil,
    :application_fee_amount => nil,
           :amount_refunded => nil,
                  :metadata => {
         "purchase_type" => "credit_pack",
             "pack_name" => "pro",
               "credits" => 5000,
         "bonus_credits" => 100,
           "price_cents" => 19900,
        "price_currency" => "USD"
    },
                      :data => {
        "payment_method_type" => "card",
                      "brand" => "Fake",
                      "last4" => 1234,
                  "exp_month" => 12,
                   "exp_year" => 2026
    },
            :stripe_account => nil,
                :created_at => 2026-12-05 06:16:07.379416000 UTC +00:00,
                :updated_at => 2026-12-05 06:16:07.379416000 UTC +00:00,
                      :type => "Pay::FakeProcessor::Charge"
}
# {
                        :id => 4416,
               :customer_id => 6040,
           :subscription_id => nil,
              :processor_id => "vOtd8QdVXNPEK25s-q1aq",
                    :amount => 19900,
                  :currency => nil,
    :application_fee_amount => nil,
           :amount_refunded => nil,
                  :metadata => {
         "purchase_type" => "credit_pack",
             "pack_name" => "pro",
               "credits" => 5000,
         "bonus_credits" => 100,
           "price_cents" => 19900,
        "price_currency" => "USD"
    },
                      :data => {
        "payment_method_type" => "card",
                      "brand" => "Fake",
                      "last4" => 1234,
                  "exp_month" => 12,
                   "exp_year" => 2026
    },
            :stripe_account => nil,
                :created_at => 2026-12-05 09:50:01.603360000 UTC +00:00,
                :updated_at => 2026-12-05 09:50:01.603360000 UTC +00:00,
                      :type => "Pay::FakeProcessor::Charge"
}
# {
                        :id => 4418,
               :customer_id => 6040,
           :subscription_id => nil,
              :processor_id => "yXURSACVAOp1klXTLOM-t",
                    :amount => 19900,
                  :currency => nil,
    :application_fee_amount => nil,
           :amount_refunded => nil,
                  :metadata => {
         "purchase_type" => "credit_pack",
             "pack_name" => "pro",
               "credits" => 5000,
         "bonus_credits" => 100,
           "price_cents" => 19900,
        "price_currency" => "USD"
    },
                      :data => {
        "payment_method_type" => "card",
                      "brand" => "Fake",
                      "last4" => 1234,
                  "exp_month" => 12,
                   "exp_year" => 2026
    },
            :stripe_account => nil,
                :created_at => 2026-12-05 22:18:35.689206000 UTC +00:00,
                :updated_at => 2026-12-05 22:18:35.689206000 UTC +00:00,
                      :type => "Pay::FakeProcessor::Charge"
}
Pay::Subscription (3)
# {
                         "id" => 1958,
                "customer_id" => 6040,
                       "name" => "default",
               "processor_id" => "6nIw3CYYL-ZEoc9CINysH",
             "processor_plan" => "abcdef123456",
                   "quantity" => 1,
                     "status" => "active",
       "current_period_start" => nil,
         "current_period_end" => nil,
              "trial_ends_at" => nil,
                    "ends_at" => nil,
                    "metered" => nil,
             "pause_behavior" => nil,
            "pause_starts_at" => nil,
           "pause_resumes_at" => nil,
    "application_fee_percent" => nil,
                   "metadata" => {
                   "purchase_type" => "credit_subscription",
               "subscription_name" => "test_plan",
              "fulfillment_period" => "1 month",
              "credits_per_period" => 10,
            "signup_bonus_credits" => 0,
                   "trial_credits" => 0,
                "rollover_enabled" => false,
        "expire_credits_on_cancel" => false,
        "credit_expiration_period" => nil,
                        "metadata" => {}
    },
                       "data" => nil,
             "stripe_account" => nil,
          "payment_method_id" => nil,
                 "created_at" => 2026-12-05 18:17:05.265463000 UTC +00:00,
                 "updated_at" => 2026-12-05 18:17:05.265463000 UTC +00:00,
                       "type" => "Pay::FakeProcessor::Subscription",
                    "prorate" => true
}
# {
                         "id" => 1957,
                "customer_id" => 6040,
                       "name" => "default",
               "processor_id" => "Fa79Gghn0CggoiWPyACGc",
             "processor_plan" => "abcdef123456",
                   "quantity" => 1,
                     "status" => "active",
       "current_period_start" => nil,
         "current_period_end" => nil,
              "trial_ends_at" => nil,
                    "ends_at" => nil,
                    "metered" => nil,
             "pause_behavior" => nil,
            "pause_starts_at" => nil,
           "pause_resumes_at" => nil,
    "application_fee_percent" => nil,
                   "metadata" => {
                   "purchase_type" => "credit_subscription",
               "subscription_name" => "test_plan",
              "fulfillment_period" => "1 month",
              "credits_per_period" => 10,
            "signup_bonus_credits" => 0,
                   "trial_credits" => 0,
                "rollover_enabled" => false,
        "expire_credits_on_cancel" => false,
        "credit_expiration_period" => nil,
                        "metadata" => {}
    },
                       "data" => nil,
             "stripe_account" => nil,
          "payment_method_id" => nil,
                 "created_at" => 2026-12-05 08:07:57.031305000 UTC +00:00,
                 "updated_at" => 2026-12-05 08:07:57.031305000 UTC +00:00,
                       "type" => "Pay::FakeProcessor::Subscription",
                    "prorate" => true
}
# {
                         "id" => 1959,
                "customer_id" => 6040,
                       "name" => "default",
               "processor_id" => "aDBI7QAw4kVwcd1MtwIcn",
             "processor_plan" => "abcdef123456",
                   "quantity" => 1,
                     "status" => "active",
       "current_period_start" => nil,
         "current_period_end" => nil,
              "trial_ends_at" => nil,
                    "ends_at" => nil,
                    "metered" => nil,
             "pause_behavior" => nil,
            "pause_starts_at" => nil,
           "pause_resumes_at" => nil,
    "application_fee_percent" => nil,
                   "metadata" => {
                   "purchase_type" => "credit_subscription",
               "subscription_name" => "test_plan",
              "fulfillment_period" => "1 month",
              "credits_per_period" => 10,
            "signup_bonus_credits" => 0,
                   "trial_credits" => 0,
                "rollover_enabled" => false,
        "expire_credits_on_cancel" => false,
        "credit_expiration_period" => nil,
                        "metadata" => {}
    },
                       "data" => nil,
             "stripe_account" => nil,
          "payment_method_id" => nil,
                 "created_at" => 2026-12-05 22:18:00.106846000 UTC +00:00,
                 "updated_at" => 2026-12-05 22:18:00.106846000 UTC +00:00,
                       "type" => "Pay::FakeProcessor::Subscription",
                    "prorate" => true
}

Model records

UsageCredits::Fulfillment (8)
# {
                          :id => 6370,
                   :wallet_id => 6048,
                 :source_type => "Pay::Charge",
                   :source_id => 4414,
    :credits_last_fulfillment => 5100,
            :fulfillment_type => "credit_pack",
           :last_fulfilled_at => 2026-12-05 06:16:07.383940000 UTC +00:00,
         :next_fulfillment_at => nil,
          :fulfillment_period => nil,
                    :stops_at => nil,
                    :metadata => {
        "purchase_charge_id" => 4414,
              "purchased_at" => "2026-12-05T06:16:07.379Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "pro",
                   "credits" => 5000,
             "bonus_credits" => 100,
               "price_cents" => 19900,
            "price_currency" => "USD"
    },
                  :created_at => 2026-12-05 06:16:07.384396000 UTC +00:00,
                  :updated_at => 2026-12-05 06:16:07.384396000 UTC +00:00
}
# {
                          :id => 6371,
                   :wallet_id => 6048,
                 :source_type => "Pay::Charge",
                   :source_id => 4415,
    :credits_last_fulfillment => 1000,
            :fulfillment_type => "credit_pack",
           :last_fulfilled_at => 2026-12-05 06:19:09.419874000 UTC +00:00,
         :next_fulfillment_at => nil,
          :fulfillment_period => nil,
                    :stops_at => nil,
                    :metadata => {
        "purchase_charge_id" => 4415,
              "purchased_at" => "2026-12-05T06:19:09.416Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "starter",
                   "credits" => 1000,
             "bonus_credits" => 0,
               "price_cents" => 4900,
            "price_currency" => "USD"
    },
                  :created_at => 2026-12-05 06:19:09.420215000 UTC +00:00,
                  :updated_at => 2026-12-05 06:19:09.420215000 UTC +00:00
}
# {
                          :id => 6372,
                   :wallet_id => 6048,
                 :source_type => "Pay::Subscription",
                   :source_id => 1957,
    :credits_last_fulfillment => 10,
            :fulfillment_type => "subscription",
           :last_fulfilled_at => 2026-12-05 08:07:57.036304000 UTC +00:00,
         :next_fulfillment_at => 2027-01-05 08:07:57.031305000 UTC +00:00,
          :fulfillment_period => "1 month",
                    :stops_at => nil,
                    :metadata => {
        "subscription_id" => 1957,
                   "plan" => "abcdef123456"
    },
                  :created_at => 2026-12-05 08:07:57.036977000 UTC +00:00,
                  :updated_at => 2026-12-05 08:07:57.036977000 UTC +00:00
}
# {
                          :id => 6373,
                   :wallet_id => 6048,
                 :source_type => "Pay::Charge",
                   :source_id => 4416,
    :credits_last_fulfillment => 5100,
            :fulfillment_type => "credit_pack",
           :last_fulfilled_at => 2026-12-05 09:50:01.608249000 UTC +00:00,
         :next_fulfillment_at => nil,
          :fulfillment_period => nil,
                    :stops_at => nil,
                    :metadata => {
        "purchase_charge_id" => 4416,
              "purchased_at" => "2026-12-05T09:50:01.603Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "pro",
                   "credits" => 5000,
             "bonus_credits" => 100,
               "price_cents" => 19900,
            "price_currency" => "USD"
    },
                  :created_at => 2026-12-05 09:50:01.608678000 UTC +00:00,
                  :updated_at => 2026-12-05 09:50:01.608678000 UTC +00:00
}
# {
                          :id => 6374,
                   :wallet_id => 6048,
                 :source_type => "Pay::Subscription",
                   :source_id => 1958,
    :credits_last_fulfillment => 10,
            :fulfillment_type => "subscription",
           :last_fulfilled_at => 2026-12-05 18:17:05.273848000 UTC +00:00,
         :next_fulfillment_at => 2027-01-05 18:17:05.265463000 UTC +00:00,
          :fulfillment_period => "1 month",
                    :stops_at => nil,
                    :metadata => {
        "subscription_id" => 1958,
                   "plan" => "abcdef123456"
    },
                  :created_at => 2026-12-05 18:17:05.274281000 UTC +00:00,
                  :updated_at => 2026-12-05 18:17:05.274281000 UTC +00:00
}
# {
                          :id => 6375,
                   :wallet_id => 6048,
                 :source_type => "Pay::Charge",
                   :source_id => 4417,
    :credits_last_fulfillment => 10,
            :fulfillment_type => "credit_pack",
           :last_fulfilled_at => 2026-12-05 22:17:34.312984000 UTC +00:00,
         :next_fulfillment_at => nil,
          :fulfillment_period => nil,
                    :stops_at => nil,
                    :metadata => {
        "purchase_charge_id" => 4417,
              "purchased_at" => "2026-12-05T22:17:34.307Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "tiny",
                   "credits" => 10,
             "bonus_credits" => 0,
               "price_cents" => 99,
            "price_currency" => "USD"
    },
                  :created_at => 2026-12-05 22:17:34.313541000 UTC +00:00,
                  :updated_at => 2026-12-05 22:17:34.313541000 UTC +00:00
}
# {
                          :id => 6376,
                   :wallet_id => 6048,
                 :source_type => "Pay::Subscription",
                   :source_id => 1959,
    :credits_last_fulfillment => 10,
            :fulfillment_type => "subscription",
           :last_fulfilled_at => 2026-12-05 22:18:00.114004000 UTC +00:00,
         :next_fulfillment_at => 2027-01-05 22:18:00.106846000 UTC +00:00,
          :fulfillment_period => "1 month",
                    :stops_at => nil,
                    :metadata => {
        "subscription_id" => 1959,
                   "plan" => "abcdef123456"
    },
                  :created_at => 2026-12-05 22:18:00.116664000 UTC +00:00,
                  :updated_at => 2026-12-05 22:18:00.116664000 UTC +00:00
}
# {
                          :id => 6377,
                   :wallet_id => 6048,
                 :source_type => "Pay::Charge",
                   :source_id => 4418,
    :credits_last_fulfillment => 5100,
            :fulfillment_type => "credit_pack",
           :last_fulfilled_at => 2026-12-05 22:18:35.693162000 UTC +00:00,
         :next_fulfillment_at => nil,
          :fulfillment_period => nil,
                    :stops_at => nil,
                    :metadata => {
        "purchase_charge_id" => 4418,
              "purchased_at" => "2026-12-05T22:18:35.689Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "pro",
                   "credits" => 5000,
             "bonus_credits" => 100,
               "price_cents" => 19900,
            "price_currency" => "USD"
    },
                  :created_at => 2026-12-05 22:18:35.693528000 UTC +00:00,
                  :updated_at => 2026-12-05 22:18:35.693528000 UTC +00:00
}
UsageCredits::Transaction (12)
# {
                :id => 10410,
         :wallet_id => 6048,
            :amount => 5100,
          :category => "credit_pack_purchase",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "purchase_charge_id" => 4414,
              "purchased_at" => "2026-12-05T06:16:07.379Z",
         "credits_fulfilled" => true,
              "fulfilled_at" => "2026-12-05T06:16:07.380Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "pro",
                   "credits" => 5000,
             "bonus_credits" => 100,
               "price_cents" => 19900,
            "price_currency" => "USD"
    },
        :created_at => 2026-12-05 06:16:07.382663000 UTC +00:00,
        :updated_at => 2026-12-05 06:16:07.382663000 UTC +00:00
}
# {
                :id => 10411,
         :wallet_id => 6048,
            :amount => 10,
          :category => "bonus",
        :expires_at => 2026-12-05 06:18:26.996400000 UTC +00:00,
    :fulfillment_id => nil,
          :metadata => {
        "reason" => "expiring_bonus_credits"
    },
        :created_at => 2026-12-05 06:17:26.999427000 UTC +00:00,
        :updated_at => 2026-12-05 06:17:26.999427000 UTC +00:00
}
# {
                :id => 10412,
         :wallet_id => 6048,
            :amount => 1000,
          :category => "credit_pack_purchase",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "purchase_charge_id" => 4415,
              "purchased_at" => "2026-12-05T06:19:09.416Z",
         "credits_fulfilled" => true,
              "fulfilled_at" => "2026-12-05T06:19:09.417Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "starter",
                   "credits" => 1000,
             "bonus_credits" => 0,
               "price_cents" => 4900,
            "price_currency" => "USD"
    },
        :created_at => 2026-12-05 06:19:09.418450000 UTC +00:00,
        :updated_at => 2026-12-05 06:19:09.418450000 UTC +00:00
}
# {
                :id => 10413,
         :wallet_id => 6048,
            :amount => 10,
          :category => "signup_bonus",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "reason" => "signup"
    },
        :created_at => 2026-12-05 06:19:11.356887000 UTC +00:00,
        :updated_at => 2026-12-05 06:19:11.356887000 UTC +00:00
}
# {
                :id => 10414,
         :wallet_id => 6048,
            :amount => 10,
          :category => "subscription_credits",
        :expires_at => 2027-01-05 08:12:57.031305000 UTC +00:00,
    :fulfillment_id => 6372,
          :metadata => {
        "subscription_id" => 1957,
                 "reason" => "first_cycle",
                   "plan" => "abcdef123456",
           "fulfilled_at" => "2026-12-05T08:07:57.033Z"
    },
        :created_at => 2026-12-05 08:07:57.034608000 UTC +00:00,
        :updated_at => 2026-12-05 08:07:57.034608000 UTC +00:00
}
# {
                :id => 10415,
         :wallet_id => 6048,
            :amount => 5100,
          :category => "credit_pack_purchase",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "purchase_charge_id" => 4416,
              "purchased_at" => "2026-12-05T09:50:01.603Z",
         "credits_fulfilled" => true,
              "fulfilled_at" => "2026-12-05T09:50:01.605Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "pro",
                   "credits" => 5000,
             "bonus_credits" => 100,
               "price_cents" => 19900,
            "price_currency" => "USD"
    },
        :created_at => 2026-12-05 09:50:01.607038000 UTC +00:00,
        :updated_at => 2026-12-05 09:50:01.607038000 UTC +00:00
}
# {
                :id => 10416,
         :wallet_id => 6048,
            :amount => 10,
          :category => "subscription_credits",
        :expires_at => 2027-01-05 18:22:05.265463000 UTC +00:00,
    :fulfillment_id => 6374,
          :metadata => {
        "subscription_id" => 1958,
                 "reason" => "first_cycle",
                   "plan" => "abcdef123456",
           "fulfilled_at" => "2026-12-05T18:17:05.271Z"
    },
        :created_at => 2026-12-05 18:17:05.272482000 UTC +00:00,
        :updated_at => 2026-12-05 18:17:05.272482000 UTC +00:00
}
# {
                :id => 10417,
         :wallet_id => 6048,
            :amount => 10,
          :category => "credit_pack_purchase",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "purchase_charge_id" => 4417,
              "purchased_at" => "2026-12-05T22:17:34.307Z",
         "credits_fulfilled" => true,
              "fulfilled_at" => "2026-12-05T22:17:34.310Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "tiny",
                   "credits" => 10,
             "bonus_credits" => 0,
               "price_cents" => 99,
            "price_currency" => "USD"
    },
        :created_at => 2026-12-05 22:17:34.311622000 UTC +00:00,
        :updated_at => 2026-12-05 22:17:34.311622000 UTC +00:00
}
# {
                :id => 10418,
         :wallet_id => 6048,
            :amount => 20,
          :category => "referral_bonus",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "reason" => "referral"
    },
        :created_at => 2026-12-05 22:17:37.818603000 UTC +00:00,
        :updated_at => 2026-12-05 22:17:37.818603000 UTC +00:00
}
# {
                :id => 10419,
         :wallet_id => 6048,
            :amount => 10,
          :category => "subscription_credits",
        :expires_at => 2027-01-05 22:23:00.106846000 UTC +00:00,
    :fulfillment_id => 6376,
          :metadata => {
        "subscription_id" => 1959,
                 "reason" => "first_cycle",
                   "plan" => "abcdef123456",
           "fulfilled_at" => "2026-12-05T22:18:00.109Z"
    },
        :created_at => 2026-12-05 22:18:00.112032000 UTC +00:00,
        :updated_at => 2026-12-05 22:18:00.112032000 UTC +00:00
}
# {
                :id => 10420,
         :wallet_id => 6048,
            :amount => 10,
          :category => "signup_bonus",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "reason" => "signup"
    },
        :created_at => 2026-12-05 22:18:11.017568000 UTC +00:00,
        :updated_at => 2026-12-05 22:18:11.017568000 UTC +00:00
}
# {
                :id => 10421,
         :wallet_id => 6048,
            :amount => 5100,
          :category => "credit_pack_purchase",
        :expires_at => nil,
    :fulfillment_id => nil,
          :metadata => {
        "purchase_charge_id" => 4418,
              "purchased_at" => "2026-12-05T22:18:35.689Z",
         "credits_fulfilled" => true,
              "fulfilled_at" => "2026-12-05T22:18:35.690Z",
             "purchase_type" => "credit_pack",
                 "pack_name" => "pro",
                   "credits" => 5000,
             "bonus_credits" => 100,
               "price_cents" => 19900,
            "price_currency" => "USD"
    },
        :created_at => 2026-12-05 22:18:35.691777000 UTC +00:00,
        :updated_at => 2026-12-05 22:18:35.691777000 UTC +00:00
}
UsageCredits::Allocation (0) none

Audit trail

Audit trail
[
    [ 0] [
        [0] "credit_pack_purchase",
        [1] 5100,
        [2] {
            "purchase_charge_id" => 4414,
                  "purchased_at" => "2026-12-05T06:16:07.379Z",
             "credits_fulfilled" => true,
                  "fulfilled_at" => "2026-12-05T06:16:07.380Z",
                 "purchase_type" => "credit_pack",
                     "pack_name" => "pro",
                       "credits" => 5000,
                 "bonus_credits" => 100,
                   "price_cents" => 19900,
                "price_currency" => "USD"
        }
    ],
    [ 1] [
        [0] "bonus",
        [1] 10,
        [2] {
            "reason" => "expiring_bonus_credits"
        }
    ],
    [ 2] [
        [0] "credit_pack_purchase",
        [1] 1000,
        [2] {
            "purchase_charge_id" => 4415,
                  "purchased_at" => "2026-12-05T06:19:09.416Z",
             "credits_fulfilled" => true,
                  "fulfilled_at" => "2026-12-05T06:19:09.417Z",
                 "purchase_type" => "credit_pack",
                     "pack_name" => "starter",
                       "credits" => 1000,
                 "bonus_credits" => 0,
                   "price_cents" => 4900,
                "price_currency" => "USD"
        }
    ],
    [ 3] [
        [0] "signup_bonus",
        [1] 10,
        [2] {
            "reason" => "signup"
        }
    ],
    [ 4] [
        [0] "subscription_credits",
        [1] 10,
        [2] {
            "subscription_id" => 1957,
                     "reason" => "first_cycle",
                       "plan" => "abcdef123456",
               "fulfilled_at" => "2026-12-05T08:07:57.033Z"
        }
    ],
    [ 5] [
        [0] "credit_pack_purchase",
        [1] 5100,
        [2] {
            "purchase_charge_id" => 4416,
                  "purchased_at" => "2026-12-05T09:50:01.603Z",
             "credits_fulfilled" => true,
                  "fulfilled_at" => "2026-12-05T09:50:01.605Z",
                 "purchase_type" => "credit_pack",
                     "pack_name" => "pro",
                       "credits" => 5000,
                 "bonus_credits" => 100,
                   "price_cents" => 19900,
                "price_currency" => "USD"
        }
    ],
    [ 6] [
        [0] "subscription_credits",
        [1] 10,
        [2] {
            "subscription_id" => 1958,
                     "reason" => "first_cycle",
                       "plan" => "abcdef123456",
               "fulfilled_at" => "2026-12-05T18:17:05.271Z"
        }
    ],
    [ 7] [
        [0] "credit_pack_purchase",
        [1] 10,
        [2] {
            "purchase_charge_id" => 4417,
                  "purchased_at" => "2026-12-05T22:17:34.307Z",
             "credits_fulfilled" => true,
                  "fulfilled_at" => "2026-12-05T22:17:34.310Z",
                 "purchase_type" => "credit_pack",
                     "pack_name" => "tiny",
                       "credits" => 10,
                 "bonus_credits" => 0,
                   "price_cents" => 99,
                "price_currency" => "USD"
        }
    ],
    [ 8] [
        [0] "referral_bonus",
        [1] 20,
        [2] {
            "reason" => "referral"
        }
    ],
    [ 9] [
        [0] "subscription_credits",
        [1] 10,
        [2] {
            "subscription_id" => 1959,
                     "reason" => "first_cycle",
                       "plan" => "abcdef123456",
               "fulfilled_at" => "2026-12-05T22:18:00.109Z"
        }
    ],
    [10] [
        [0] "signup_bonus",
        [1] 10,
        [2] {
            "reason" => "signup"
        }
    ],
    [11] [
        [0] "credit_pack_purchase",
        [1] 5100,
        [2] {
            "purchase_charge_id" => 4418,
                  "purchased_at" => "2026-12-05T22:18:35.689Z",
             "credits_fulfilled" => true,
                  "fulfilled_at" => "2026-12-05T22:18:35.690Z",
                 "purchase_type" => "credit_pack",
                     "pack_name" => "pro",
                       "credits" => 5000,
                 "bonus_credits" => 100,
                   "price_cents" => 19900,
                "price_currency" => "USD"
        }
    ]
]

Loaded config

Literal, raw config file
      # frozen_string_literal: true

UsageCredits.configure do |config|

  # Default test operations
  operation :small_operation do
    costs 1.credit
  end

  # operation :test_operation do
  #   costs 10.credits + 1.credits_per(:mb)
  #   validate ->(params) { params[:size].to_i <= 100.megabytes }, "File too large (max: 100 MB)"
  # end

  operation :prohibitive_operation do
    costs 1_000_000.credits
  end

  operation :this_operation_will_always_fail do
    costs 42.credits
  end


  # Define test credit packs
  credit_pack :tiny do
    gives 10.credits
    costs 99.cents
  end

  credit_pack :starter do
    gives 1000.credits
    costs 49.dollars
  end

  credit_pack :pro do
    gives 5000.credits
    bonus 100.credits  # Optional: give bonus credits
    costs 199.dollars
    currency :usd
  end


  # Define subscriptions
  subscription_plan :test_plan do
    processor_plan(:fake_processor, "abcdef123456")
    gives 10.credits.every(:month)
    unused_credits :expire
  end

  # Alert when balance drops below 100 credits
  # Set to nil to disable low balance alerts
  # config.low_balance_threshold = 20.credits

  # # Handle low credit balance alerts
  # config.on_low_balance do |user|
  #   # Send notification to user when their balance drops below the threshold
  #   ApplicationMailer.generic_email(to: user.email, body: "Heads up! You're low on credits.", subject: "Low credits alert").deliver_now
  # end

end

    
Credit-consuming operations
Credit packs
Credit subscription plans
Rest of the config
      {
  "default_currency": "usd",
  "rounding_strategy": "ceil",
  "credit_formatter": {},
  "fulfillment_grace_period": 300,
  "allow_negative_balance": false,
  "low_balance_threshold": null,
  "low_balance_callback": null
}