Home > Software design >  Rails. I can't see my plan subscription in Stripe::Customer.retrieve("cus_XYZ") conso
Rails. I can't see my plan subscription in Stripe::Customer.retrieve("cus_XYZ") conso

Time:11-13

I have created my product with price and when I go to consult the clients the subscription field does not appear.

# rails console
Stripe::Customer.retrieve("cus_XYZ")

However, the subscription appears when I run in the console:

Stripe::Subscription.retrieve("sub_1XYZ")

I'd like it to appear when I do a query Stripe::Customer.retrieve, as I need the "subscription" field appears it

If there is any way to retrieve the subscription field in customer I would be very grateful to know.

CodePudding user response:

As noted in the API reference, the subscriptions are expandable and not included by default.

You can get these, but you need to explicitly request them via expansion:

Stripe::Customer.retrieve({
  id: 'cus_123',
  expand: ['subscriptions'],
})
  • Related