#humblegawwwd

1 messages · Page 1 of 1 (latest)

upbeat knollBOT
tropic warren
#

this is what winds up loading from the url I generate

urban gust
#

Which one is the API and which one is the Dashboard?

tropic warren
#

The second one was generated from the API

#

I should note I played around a while with creating custom configurations through the API so I think I've got a list of like 10 or so different configs, but stopped referencing them in the session generation which I assumed would hit the default that I set up in the dashboard

urban gust
#

Did you provide a Configuration object for the on the API generated? You have to specify all the things you want to show up in the UI.

Here's the step in the guide on how to do that (though you may have done so already): https://stripe.com/docs/no-code/customer-portal#configure-portal

If you know which configuration you set for that portal link, you may want to reference it again to make sure that it's actually set up to display the things you want it to

Let your customers manage their own billing accounts with a portal that Stripe hosts.

tropic warren
#

I understand that I should not be doing this on each call, but I had this code and
• It appeared to be grabbing the price correctly
• It appeared to be grabbing the subscription correctly

But when the url opened it didn't allow me to edit anything about subscriptions

#
export const getCustomerPortalUrl = async (user: User) => {
  const userWithStripeId = await ensureStripeCustomerId(user);
  if (!userWithStripeId) return null;

  const remenuSubscription = await getRemenuSubscriptionProduct();
  const remenuSubscriptionPrice = await getRemenuSubscriptionPrice();

  if (!remenuSubscriptionPrice) {
    console.error("Cannot find price");
    return null;
  }

  if (!remenuSubscription) {
    console.error("Could not find remenu subscription");
    return null;
  }

  const configuration = await stripe.billingPortal.configurations.create({
    features: {
      invoice_history: {
        enabled: true,
      },
      customer_update: {
        enabled: true,
        allowed_updates: ["address", "email", "name", "phone"],
      },
      subscription_cancel: {
        enabled: true,
        mode: "at_period_end",
      },
      payment_method_update: { enabled: true },
      subscription_update: {
        enabled: true,
        default_allowed_updates: ["quantity"],
        proration_behavior: "none",
        products: [
          {
            prices: [remenuSubscriptionPrice.id],
            product: remenuSubscription.id,
          },
        ],
      },
    },
    business_profile: {
      headline: "Update Your Remenu Subscriptions",
      privacy_policy_url,
      terms_of_service_url,
    },
  });
  // Authenticate your user.
  const session = await stripe.billingPortal.sessions
    .create({
      configuration: configuration.id,
      customer: userWithStripeId.stripeCustomerId,
      return_url: RouteCalc.baseUrl,
    })
    .catch((e) => {
      console.error(e);
      return null;
    });

  if (!session) {
    console.error("No Session Generated");
    return null;
  }

  return session.url;
};
#

This is the link I generate

#

Just to prove that the subscription and price are there here are the json objects for those entites

{
  remenuSubscription: '{\n' +
    '  "id": "prod_OQ2247Jung6dFD",\n' +
    '  "object": "product",\n' +
    '  "active": true,\n' +
    '  "attributes": [],\n' +
    '  "created": 1691585950,\n' +
    '  "default_price": "price_1NdBykFsSRGomZLta2YD1Svt",\n' +
    '  "description": null,\n' +
    '  "images": [],\n' +
    '  "livemode": false,\n' +
    '  "metadata": {},\n' +
    '  "name": "Remenu Subscription",\n' +
    '  "package_dimensions": null,\n' +
    '  "shippable": null,\n' +
    '  "statement_descriptor": null,\n' +
    '  "tax_code": null,\n' +
    '  "type": "service",\n' +
    '  "unit_label": null,\n' +
    '  "updated": 1691585950,\n' +
    '  "url": null\n' +
    '}',
  remenuSubscriptionPrice: '{\n' +
    '  "id": "price_1NdBykFsSRGomZLta2YD1Svt",\n' +
    '  "object": "price",\n' +
    '  "active": true,\n' +
    '  "billing_scheme": "per_unit",\n' +
    '  "created": 1691585950,\n' +
    '  "currency": "usd",\n' +
    '  "custom_unit_amount": null,\n' +
    '  "livemode": false,\n' +
    '  "lookup_key": null,\n' +
    '  "metadata": {},\n' +
    '  "nickname": null,\n' +
    '  "product": "prod_OQ2247Jung6dFD",\n' +
    '  "recurring": {\n' +
    '    "aggregate_usage": null,\n' +
    '    "interval": "month",\n' +
    '    "interval_count": 1,\n' +
    '    "trial_period_days": null,\n' +
    '    "usage_type": "licensed"\n' +
    '  },\n' +
    '  "tax_behavior": "unspecified",\n' +
    '  "tiers_mode": null,\n' +
    '  "transform_quantity": null,\n' +
    '  "type": "recurring",\n' +
    '  "unit_amount": 4000,\n' +
    '  "unit_amount_decimal": "4000"\n' +
    '}'
}
urban gust
#

I'm not seeing a Subscription ID in any of that code. Do you have a Customer ID I can look at to confirm?

tropic warren
#

Is a subscription id different than a product id

urban gust
#

Yup. A subscription ID is the object that you add your Product and Price to. It facilitates recurring payments and represents the overall subscription that the customer is subscribed to

#

how are you creating subscriptions right now?

#

You can't do it through the customer portal. You can only update them through the customer portal

tropic warren
#

Ah, @urban gust if I create 1 subscription per customer as a default for signing up to platform (Whether they pay or not), could I adjust their quantity of subscritions / payment stuff all through that one subscription

tropic warren
#

Then whenever they open up their customer portal they will be able to manage their qt, and other properties

urban gust
#

Billing Portal allows them to manage upgrades/downgrades, but not subscribe to an entirely new subscription.

tropic warren
#

Okie dokie, I'm going to try and implement this tomorrow morning. This is extremely helpful.

#

Would this workflow make sense?

#

When they click my Manage Subscriptions button, if they don't have any subscriptions tied to the customer, I send them to a checkout session that is just to get the initial subscription started.

If they want to change quantity in the future that same button just directs them to the customer portal where they will be able to do so?

#

Also is there a concept of a "Inactive subscription", in other words if they cancel their subscription via the customer portal will they need to go back to the checkout page?

urban gust