#Steven P

1 messages · Page 1 of 1 (latest)

strong elbowBOT
vast ivy
minor jewel
#
       let session = try stripe.sessions.create(
            cancelUrl: "http://localhost:4200/dashboard",
            paymentMethodTypes: [.card],
            successUrl: "http://localhost:4200/dashboard",
            allowPromotionCodes: nil,
            billingAddressCollection: .auto,
            customerEmail: user.email,
            lineItems: [[
                "price": price,
                "quantity": 1,
            ]],
            metadata: [
                "user_id": body.uid,
                "type": body.type.rawValue
            ],
            mode: .subscription).wait()

This creates metadata on the Checkout object, however I'd like to create metadata on the associated Subscription object. How would I do this?

vast ivy
minor jewel
#
let session = try stripe.sessions.create(
            cancelUrl: "http://localhost:4200/dashboard",
            paymentMethodTypes: [.card],
            successUrl: "http://localhost:4200/dashboard",
            allowPromotionCodes: nil,
            billingAddressCollection: .auto,
            customerEmail: user.email,
            lineItems: [[
                "price": price,
                "quantity": 1,
            ]],
            mode: .subscription,
            subscriptionData: [
                "meta_data": [
                    "user_id": body.uid,
                    "type": body.type.rawValue
                ]
            ]).wait()
#

this throws an error

#
subscriptionData: [
                "meta_data": [
                    "user_id": body.uid,
                    "type": body.type.rawValue
                ]
            ]
``` is the faulty param
#

how should i structure this?

vast ivy
#

what's the error?

minor jewel
#

[ WARNING ] StripeKit.StripeError [request-id: FE87D409-52EA-4350-A808-5998DA5E7256]

#

Not descriptive :/

vast ivy
#

are you using a third party library (instead of the official Stripe SDKs)?

minor jewel
#

correct

#
    if let subscriptionData = subscriptionData {
            subscriptionData.forEach { body["subscription_data[\($0)]"] = $1 }
        }```
#

here is where they set the value for this param

vast ivy
#

unfortunately, I can't help you if you're using a third party library. We don't have any insight / knowledge on how those libraries work so you'll need to reach out to them instead for guidance.