#masudrhossain

1 messages · Page 1 of 1 (latest)

subtle prairieBOT
midnight gust
heavy roost
#

I'm doing this below


@product = Stripe::Product.create({
          name: @service.title, 
          active: true, 
        })


Stripe::Price.create({
              unit_amount: (price[:unit_amount].to_i * 100).round,
              currency: params[:currency] || @organization.stripe_account.stripe_account_data["default_currency"],
              recurring: {
                interval: price[:recurring][:interval]
              },
              product: @product.id,
              metadata: {
                trial_period_days: price[:trial].to_i
              }, 
              active: true
            })

But it seems like stripes product id isn't being valid if i do it one aftr the other quickly.

#

req_8wnYWtU14EQYcy

midnight gust
#

You're making the request on this account --> acct_1JelkhKfpKuAV5N2

But the Product you're looking for exists on this account --> acct_1MSnC2G02uXfwr5H

heavy roost
#

Doing this for a connect account.

#

we set the access_token for the stripe connect account though. And the product gets successfully created on that connect account, so i don't get why it's gonna try to create the price for OUR platform account.

Stripe.api_key = @organization.stripe_account.access_token

midnight gust
#

Not sure. You would need to dig through your code and add log lines to see why the token appears to be unset at the time of the call. All I can say is that the Connect account's ID is not being included in the API call as of now

#

Hence the error

heavy roost
#

can i include the connect account id then?

#

oh, so thee connect id isn't being included hmm okay

subtle prairieBOT
heavy roost
#

It's a bit odd, but adding this line to each in the array fixes the issue. This issue wasn't happening before, so not sure what happened. I used to jsut leave that line of code at the top of the method and it worked fine.

#

Before, i just had it at the top. and normally, it SHOULD use this for all stripe requests.

midnight gust
#

It probably has to do with the scope of the block. Usually, you'd add that once at the top of the page, but I'm not super familiar with scope as it pertains to this language.