#developer.designer

1 messages · Page 1 of 1 (latest)

sour sirenBOT
lament kestrel
#

If the price is set to yearly price, then it will only show the charged time period on one year basis and it can't be broken down to two line items for two different periods

severe pewter
#

Can you please let me know it is correct or not?

sour sirenBOT
lament kestrel
severe pewter
#

How can I make that as per the user selection?

#

like if user select 2 then it will be subscribed for 2 years.

tacit cliff
#

Hi @severe pewter I'm taking over this thread

severe pewter
#

Sure please

tacit cliff
severe pewter
#

I have already price_id form the stripe product. with that this a causing any issue?

tacit cliff
#

What's the price ID?

severe pewter
tacit cliff
#

Sorry, the maximum billing period is one year, so what I mentioned earlier doesn't work.

severe pewter
#

so how can I fix that for the 2 years? with recurring payments

tacit cliff
#

I don't have a solution at this moment. Can you reach out to Stripe support and see if they have other suggestions? https://support.stripe.com/contact/email

severe pewter
#

As simple I have a product price of $240. I have selected the 2 years so recurring payment work like 1st year $120 and 2nd year $120. and want the 2-year subscription. is that possible?

tacit cliff
#

Just to clarify, it's still a yearly subscription, it's just that you want it to be automatically cancelled after 2 years, am I right?

severe pewter
#

yes, correct and I need to show into the invoice that like it's 2 years subscription.

tacit cliff
#

You can use subscription schedule to automate it https://stripe.com/docs/api/subscription_schedules/create?lang=dotnet#create_subscription_schedule, so you just need to add one phase with the yearly price and set the iterations to 2, and also set end_behaviour to cancel so that the subscription will be canceled in 2 years.

#

About the invoices, Stripe will generate the invoice upon renewal, so your customer will receive first invoice upon subscription, and 2nd invoice 1 year later

severe pewter
#

Are you able to update my code?

tacit cliff
#

I'm afraid that I can't write code for you. I'd suggest you to take a look at the API reference that I sent earlier. the API doc provides example code.

severe pewter
#

sure, let me try that and get back to you

tacit cliff
#

You set iterations to 3, so you want to create a 3-year subscription instead of 2-year?

severe pewter
#

it's dynamic 1,3 or 5 years

#

so is this correct now with recurring payment?

tacit cliff
#

Yes, it looks good to me.

severe pewter
#

okay but when I try with the monthly price then in the iterations I need to set months?

tacit cliff
#

You mean monthly subscription for 3 years? if so the iteractions should be 36

severe pewter
#

okay noted. and can you please let me know how can I add the metadata to it?
I'm trying like this right now but it's not visible
$subscription = $stripe->subscriptionSchedules->create([
'customer' => $customer->id,
'start_date' => $start_dates,
'end_behavior' => 'cancel',
'phases' => [
[
'items' => [
[
'price' => $price_id,
'quantity' => $quantity,
],
],
'metadata' => [
'payment_splits' => $payment_total_splits,
'price' => $price_id,
'quantity' => $quantity,
'maintenance_period' => $maintenance_period,
'num_years' => $num_years,
],
'iterations' => (int)$payment_splits,
],
],
]);

tacit cliff
#

Metadata on a schedule’s phase will update the underlying subscription’s metadata when the phase is entered.

Did you check the subscription's metadata?

severe pewter
#

Yes in the subscription that works but with this it's not work. can you please check both code and let me know where I need to put?

#

Old code works with meta data
\Stripe\Subscription::create([
'customer' => $customer->id,
'items' => [
[
'price' => $price_id,
'quantity' => $quantity,
],
],
'collection_method' => 'charge_automatically',
'trial_period_days' => $trial_days,
'proration_behavior' => 'none',
'payment_behavior' => 'default_incomplete',
'expand' => ['latest_invoice.payment_intent'],
'metadata' => [
'payment_splits' => $payment_total_splits,
'price' => $price_id,
'quantity' => $quantity,
'maintenance_period' => $maintenance_period,
'num_years' => $num_years,
],
])

New code works but not showing metadata
$stripe->subscriptionSchedules->create([
'customer' => $customer->id,
'start_date' => $start_dates,
'end_behavior' => 'cancel',
'phases' => [
[
'items' => [
[
'price' => $price_id,
'quantity' => $quantity,
],
],
'metadata' => [
'payment_splits' => $payment_total_splits,
'price' => $price_id,
'quantity' => $quantity,
'maintenance_period' => $maintenance_period,
'num_years' => $num_years,
],
'iterations' => (int)$payment_splits,
],
],
])

tacit cliff
#

What do you mean by "doesn't work" ?

severe pewter
#

Meta data not visible with new code

tacit cliff
#

The metadata is set on the phase, i'll be applied to the subscription object that schedule would create, not on the subscription schedule itself.

severe pewter
#

Okay

#

Also I'm getting this error
parameter_invalid_integer - start_date
Invalid integer: false

When I'm trying to add a start date like this 2024-03-15
with 2023 it's works fine

tacit cliff
severe pewter
#

Hello @tacit cliff , Are you still with me?

tacit cliff
#

Hi, discord is busy, I'm be with you shortly

#

problem is here -> start_date: "false", you should put a timestamp value here.

severe pewter
#

I'm using this
$start_dates = strtotime($jsonObj->start_date);

$jsonObj->start_date is
"2024-03-15"

tacit cliff
#

you might want to do an echo $start_dates in your php code and see its value. Based on the request log, the value of $start_dates is "false"

severe pewter
#

this is solved.

#

but still metadata not showing, I've tried same code which you shared with me

tacit cliff
#

request ID?

severe pewter
tacit cliff
severe pewter
tacit cliff
#

Hmm, I don't think the subscription schedule Dashboard shows the metadata

severe pewter
#

Can you please check that if is possible or not?

tacit cliff
#

I've checked, the metadata is set successfully, it's just that the metadata is not displayed in the Dashboard.

severe pewter
#

Is that possible to display?

tacit cliff
#

You can always use API to retrieve the subscription schedule object and check its metadata.

severe pewter
#

I want to display that in dashboard in stripe

#

Like this

tacit cliff
#

Thanks for the feedback, can I suggest you to reach out to Stripe support and let them know about your feature request? https://support.stripe.com/contact/email