#muneeb-t4_code

1 messages ¡ Page 1 of 1 (latest)

waxen solsticeBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1337327622387929140

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

feral bobcat
zinc hull
#

req_WvYE7hql6w0XbR

feral bobcat
#

you seem to have already deleted the price that you used : price_1QplmoGromJI4G1jJqSf1nT5, it no longer exists in your Stripe account

#

can you try again with a new Price?

zinc hull
#

ok

#

req_rvVSyzmU4Gtq9F
You must provide at least one recurring price in subscription mode when using prices.

#

when i use
'mode' => 'payment',
i get this error
Invalid string: {:"0"=>"subscription", :"1"=>"payment"}
req_r6a97ZInooavSw

feral bobcat
zinc hull
#

Actually i want to make prices based on the number of months user is subscribing for, if it is for one month than it should be one-off payment but i am getting error with that. and if i am making a recurring payment how to set the end date of subscription, like one month 2 month month etc.

zinc hull
# feral bobcat The request shows your application passing in `{:\"0\"=>\"subscription\", :\"1\...

{
"cancel_url": "http://127.0.0.1:8000/pricing",
"customer": "cus_Riwd5xE1Jneqn9",
"line_items": {
"0": {
"price": "price_1QpmH7GromJI4G1jiG4ChjDc",
"quantity": "1"
}
},
"mode": {
"0": "subscription",
"1": "payment"
},
"subscription_data": {
"metadata": {
"name": "price_1QpmH7GromJI4G1jiG4ChjDc",
"type": "price_1QpmH7GromJI4G1jiG4ChjDc"
}
},
"success_url": "http://127.0.0.1:8000/dashboard"
}

'mode' => 'payment',

i am passing mode as payment not both, how to fix that?

    {
        return $request->user()
            ->newSubscription($plan, $plan)
            ->checkout([
                'mode' => 'payment',
                'success_url' => route('dashboard'),
                'cancel_url' => route('pricing'),
                'line_items' => [
                    [
                        'price' => $plan,
                        'quantity' => $request->params['quantity'],
                    ],
                ],
            ]);
    }```
feral bobcat
#

if it is for one month than it should be one-off payment but i am getting error with that.

I don't know what error you're referring to specifically, but this logic should be defined within your own application, as Stripe cannot determine that a one month payment should be mode='payment'.

if i am making a recurring payment how to set the end date of subscription, like one month 2 month month etc.

You need to use subscription schedules for this. You can read more about this here: https://docs.stripe.com/billing/subscriptions/subscription-schedules

You would probably want to listen for the invoice.paid webhook event : https://stripe.com/docs/billing/subscriptions/webhooks#events and check the billing_reason : https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason, and after the first invoice of the Subscription is paid, you then create a subscription schedule for the existing subscription, and subsequently update the subscription schedule to end after x number of iterations

Learn how to use subscription schedules to automate changes to subscriptions over time.

zinc hull
#

i 'll read the documentation and than let you know