#mas_subscription-proration

1 messages ¡ Page 1 of 1 (latest)

crude frostBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1233532999199490110

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

muted otterBOT
atomic vigil
#

Here's my code, in case you need it. Works fine, just checking if we can bill them the diff now.

def upgrade
      # Set the Stripe API key
      Stripe.api_key = @organization.stripe_account.access_token

      begin
        # We get the service price first
        service_price = @service.service_prices.first

        # Retrieve the current subscription ID
        current_subscription_id = @service_checkout.stripe_subscription_data["id"]
        
        # Retrieve the current subscription
        subscription = Stripe::Subscription.retrieve(current_subscription_id)
    
        # Retrieve the new Price ID
        new_price_id = service_price.stripe_price

        subscription_item_id = subscription.items.data[0].id

        updated_subscription  = Stripe::Subscription.update(
          current_subscription_id,
          {
            items: [
              {
                id: subscription_item_id,
                price: new_price_id,
              },
            ],
          },
        )

        render json: {success: true, subscription: subscription, updated_subscription: updated_subscription}
    
        puts "Subscription successfully upgraded to #{new_price_id}!"
      rescue Stripe::StripeError => e
        puts "Error: #{e.message}"
      end
    end


celest hawk
#

mas_subscription-proration

atomic vigil
#

Ah sorry, missed that