#taviksha-akar_api

1 messages ¡ Page 1 of 1 (latest)

rocky mothBOT
#

👋 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/1277609716045971587

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

quasi juniper
#

hi there!

#

can you clarify what is your question? do you get an error when you run your code?

uncut tartan
#

my question is how to set start date of phase 2 to the 48 hours before the collection date

for example, if my colleciton date is 29 aug so set date to 48 hours ago from 29 aug to the phase 2.

#

in my provided code above, it is giving me this error -

"message": "`start_date` must be less than each phase's `end_date` or its derived end date based on `iterations` and `plans`."
#

// Phase 1: $0 amount to account for the 10% already paid
$phases[] = [
'items' => $this->setSubscriptionCreateItems($requestData['products'], 0)['recurringItems'], // Set items with $0 price
'billing_cycle_anchor' => 'phase_start',
'proration_behavior' => 'none',
// 'iterations' => $daysBeforePhase2, // Only 1 iteration for this phase
'end_date' => strtotime($requestData['collection_date']) - 48 * 3600,
];

    // Phase 2: 90% remaining amount, starts 48 hours before the collection date
    $phases[] = [
        'items' => $this->setSubscriptionCreateItems($requestData['products'], 90)['recurringItems'], // Set items with 90% of the amount
        'billing_cycle_anchor' => 'phase_start',
        'proration_behavior' => 'none',
        'iterations' => 1, // Only 1 iteration for this phase
    ];

    // Phase 3: Regular pricing for all subsequent iterations
    $phases[] = [
        'items' => $items,
        'add_invoice_items' => $charges,
        'billing_cycle_anchor' => 'phase_start',
        'description' => $requestData['description'] ?? null,
        'proration_behavior' => 'none'
        'discounts' => $requestData['coupon_id'] ?? [],
        'iterations' => 2
    ];

    // Conditional phase for 25% discount after 3 iterations
    if ($twentyFivePercentDiscount) {
        $phases[] = [
            'items' => $items, // Set items with 25% discount
            'billing_cycle_anchor' => 'phase_start',
            'discounts' => [
                ['coupon' => config('coupon-constants.twenty_five_percent_coupon')],
            ]
        ];
    }
quasi juniper
uncut tartan
#

req_IBIifgj8NcpqAC

quasi juniper
#

thanks! give me a few minutes to look into this.

uncut tartan
#

ok thanks

quasi juniper
#

you set start_date: 2024-08-28 for the Subscription, and end_date: "2024-08-26" for the first phase. that doesn't make any sense, so it's expected to return an error. how can the first phase start before the beginning of the subscription?

rocky mothBOT
uncut tartan
#

Actually in my case, I want to set a phase with start date to 48 hours less than collection date. So if collection date is 29 aug then payment should be done before 48 hours.

I am doing it with one more case, I need to take 10% for the initial invoice then in second phase that I have mentioned 48 hours before collection date so on this date remaining 90% payment.

So as suggested by your team previously-

he Subscription Schedule can look like :
phase 1 : $0 price to take into account the 10% that was already paid
phase 2 : 90% remaining amount (start date will be 48 hours before col. date)
phase 3 : regular pricing
phase 4: 25% discount if applicable after 3 months

#

so how can i set 90% payment start date.

#

For this I tried it by setting end date to 2024-08-26 so that next phase i.e second phase should start after this

#

and 90% payment will be set according to by 48 hours condition

#

that's why i was trying like that

#

can you please suggest me how can i do this. I am trying it from a long time

#

there?

cunning token
#

I think what you are missing from that suggestion is the phase 1 with the $0 price. From your description it sounds like you are taking payment and then should create a schedule that charges $0 for 48 hours and then changes to the next phase which has an actual chargable price

uncut tartan
#

In phase 1, I am setting the unit_amount to 0. and iterations to 1 but how can i schedule the 90% payment to any partcular date, start_date is not there to pass for particular phase. I am taking 10% using one off and if that success then creating subscripion

#

???

cunning token
uncut tartan
#

You can either do that by creating a one time 10% coupon and adding that to the second phase -> I need to take payment on particular date? how to set start date

cunning token
uncut tartan
#

yes but as discussed this earlier, I want to set a phase with start date to 48 hours less than collection date. So if collection date is 29 aug then payment should be done before 48 hours.

so the collectio n date is 29 aug and phase 1 end date is 26 aug which will return error that end date cannot be less then start date. so how to set phase 2 date based on 48 hours condition.

cunning token
#

You will want to define phase 1 as starting on 26 aug and ending on 29 aug. Then phase 2 will start on 29 aug and you can define the next end date from there

uncut tartan
#

No, this is not what I need.

#

i need to take 90% payment before 48 hours of collection date

cunning token
#

Can you lay out for me a quick timeline of what you would want these payments to look like for a $10 subscription?

uncut tartan
#

so according to $10, i want to take 10% of it immediately then if collection date is 29th aug then set phase start date to 48 hours before 29th aug to take remaining 90% payment of $10 then set phases for regular pricing

cunning token
#

Unfortunately I am still not clear on what I got wrong before. Can you lay out a timeline in chronological order with exact amounts starting on Aug 1?

#

Like when is the $1 being paid, when is the $9 being paid, etc

uncut tartan
#

Aug 1 -> $1 will be paid immediately and then checking the collection date set phase start date to 48 hours before collection date and set amount $9 to pay

#

so if its future date then set phase date

#

and if not future then charge

cunning token
#

What I am currently confused on is that you said that my suggestion would not work because

i need to take 90% payment before 48 hours of collection date
But in your example you just said that the 48 hours comes before the $9 payment

#

So are you saying Aug 1 take a $1 payment and then Aug 3 take a $9 payment? Or something else?