#letscode
1 messages · Page 1 of 1 (latest)
can you share the full request ID req_xxx from the error?
yeah you can't do all this in one API call, it needs to be two.
first you would use SubscriptionSchedule.create with fromSubscription
then you use SubscriptionSchedule.update with the phases/iterations, passing the ID of the Schedule created in the first call.
Can you check this: req_Q66yCrlIuaqDLc
same thing
if you observe my code.. same i did
SubscriptionScheduleCreateParams params = SubscriptionScheduleCreateParams.builder()
.setFromSubscription(session.getSubscription())
.build();
And Created SubscriptionSchedule using SubscriptionScheduleCreateParams
SubscriptionSchedule subscriptionSchedule = SubscriptionSchedule.create(params);
Created SubscriptionSchedule with session
is it correct?
I know the code you shared looks like it creates the Schedule and then updates but that's not the API calls that are happening
so you must not be running the code you think you are(maybe you didn't save the file or didn't deploy the code)
Okay let me try again
can u confirm following code will work
log.info("now update schedule with iterations");
Map<String, Object> updateParams = new HashMap<>();
List<Object> phases = new ArrayList<>();
List<Object> items = new ArrayList<>();
Map<String, Object> item1 = new HashMap<>();
item1.put("price", priceId); //already in existed in subscription
item1.put("quantity", 1);
items.add(item1);
Map<String, Object> phase1 = new HashMap<>();
phase1.put("items", items);
phase1.put("iterations", 3);
phases.add(phase1);
updateParams.put("start_date", updateDateInEpoch);
updateParams.put("end_behavior", "release");
updateParams.put("phases", phases);
log.info("updateParams");
log.info(updateParams.toString());
SubscriptionSchedule updatedSubscriptionSchedule =
subscriptionSchedule.update(updateParams);
for Update
not sure, you'd have to run it and see!
I think you don't need start_date though and can remove that part
okay
just setting the iterations on the phase should be enough
if i didnt specify the start_date --> req_pKQgKKPXJDE8uG
The subscription schedule update is missing at least one phase with a start_date to anchor end dates to.; request-id: req_pKQgKKPXJDE8uG
ah, ok
then do pass start_date — the value can just be the current start date, which I think is something like subscriptionSchedule.getPhases().getData()[0].getStartDate()
sorry, I haven't done this in Java but your IDE should help auto-complete it. Basically you want to get the start_date of the current phase, and re-pass that back in when making the update call.
let subscriptionSchedule = await stripe.subscriptionSchedules.create({from_subscription:subscription.id});
subscriptionSchedule = await stripe.subscriptionSchedules.update(subscriptionSchedule.id, {
phases: [
{
start_date:subscriptionSchedule.phases[0].start_date,
items: [
{
price: 'price_xxxx',
quantity: 1,
},
],
iterations: 3,
},
],
});
for example, this is what works for me. So the same thing, but in Java.
it's working
need to pass start_date with in phase
One query: if subscription payment failed. So do we nned to cancel from API? or Stripe will take care
from my side, i'm updating my DB in checkout.session.async_payment_failed
it depends what setings you have configured for what to do when payments on a Subscription fail : https://dashboard.stripe.com/settings/billing/automatic