#CameronBryce

1 messages ยท Page 1 of 1 (latest)

muted matrixBOT
crude pawn
#

Hello ๐Ÿ˜„

#

So, I'm using the Stripe API to filter through each subscription, if the customer has paid already, it will collect the metadata:

guildIdentification
1073466319254601839
userIdentification
812809631767986226

I was wondering how I could manually input this information?
I created a fake account, at the very top image, to test.

#

When clicking their account, it says I need to create a subscription:

wild veldt
#

You can open the Customer directly in Dashboard and find the Metadata section, then click "Edit"

crude pawn
#
    const subscriptions = await stripe.subscriptions.list({ status: 'active' });
    const activeSubscriptions = subscriptions.data;

activeSubscriptions.forEach(subscription => {
      if (subscription.metadata.guildIdentification === interaction.guild.id) {
        // Code here ...
      }
    });
#

Would this still be able to access that metadata?

wild veldt
#

So this is Subscription metadata, not Customer metadata, right?

crude pawn
#

Yes, sorry. It's accessing all the subscription metadata.

crude pawn
# crude pawn

So, I figured I can make a customer account for them, then create a subscription. Though, unsure how I can label it as free.

wild veldt
#

I am a bit confused. If you are looking for editing metadata on a Subscription, then go directly to its page and click on Edit of the metadata section

crude pawn
#

I apologize, I'm not the best with Stripe yet.

#

Do you mean going to the products, then selecting the product, then editing the metadata through there? Or is there another way to do that?

#

Wait, I think I might just be leaving information out.

#
PAYMENT COLLECTION METHOD
  async execute(interaction) {
    await interaction.deferReply({ ephemeral: true });
    const session = await stripe.checkout.sessions.create({
      success_url: '...',
      line_items: [{ price: '...', quantity: 1 }],

      subscription_data: {
        'metadata': { userIdentification: interaction.member.id, guildIdentification: interaction.guild.id },
      },

      allow_promotion_codes: true,
      mode: 'subscription',
    });
PAYMENT FILTER METHOD
    const subscriptions = await stripe.subscriptions.list({ status: 'active' });
    const activeSubscriptions = subscriptions.data;

activeSubscriptions.forEach(subscription => {
      if (subscription.metadata.guildIdentification === interaction.guild.id) {
        // Code here ...
      }
    });
#

So, when going to view the product, there is no metadata.

#

Though, when I click on a customer, it shows if they're paying for it:

#

By clicking the active subscription, that's where it's storing the metadata:

wild veldt
#

Yep. each object can have its own metadata. Think it like a tagging system. Here when you created the Checkout Session, you specified

subscription_data: {
    'metadata': { userIdentification: interaction.member.id, guildIdentification: interaction.guild.id },
},
#

That means the Subscription will have metadata

crude pawn
#

Got it, how might I be able to edit the subscriptions metadata manually on the dashbaord?

wild veldt
#

On the Subscription page in Dashboard you are seeing the Metadata section, right? right hand side it has "Edit Metadata"

crude pawn
#

Where would I need to go? Sorry

wild veldt
#

That's the Customer page! You have a screen above of the Subscription

wild veldt
crude pawn
# crude pawn

Got it, I normally have to select a customer to get that data, when selecting the manual made one, it doesn't show that info, it shows this

wild veldt
#

Yep Customer and Subscription are 2 different objects

crude pawn
#

So, how might I create a subscription for a customer without the API?

wild veldt
crude pawn
#

When doing this, would I need to input a card? I'm looking to give them free access, for as long as the subscription exists.

#

If I do this, applying this coupon, would it be safe to use my own card?

#

If it's 100% off, forever

wild veldt
#

Technically yes but I would recommend test on Test mode first

crude pawn
#

Okay, got it. Would there be any other way?

wild veldt
#

For not using Test mode?

crude pawn
#

Just to give a customer a subscription, for free

wild veldt
#

You can setup a trial period until when you want to offer for free, or you can give the Customer some credit note before hand, or add some negative Invoice Item into their first Invoice. There are various ways to achieve that, just play with it in Test mode ๐Ÿ™‚