#nunu0951_docs

1 messages ¡ Page 1 of 1 (latest)

fervent spruceBOT
#

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

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

violet ravine
#

Hi there, is it about creating subscriptions on connected accounts?

#

Are you using Checkout Sessions API or Subscirptions API to create subscriptions?

idle charm
#

we are using subscriptions API
we are dealing only single product
we use createSubscription api with plan id
now we need to implement cart (so can have subscriptions or one time in cart)

violet ravine
#

You should specify a stripe_account in the request.

By specifying a stripe_account, you are telling Stripe that you want to make an API call on behalf of a connected account. You can refer to this doc to learn more about making API request for connected account (https://stripe.com/docs/connect/authentication)

Learn how to add the right information to your API calls so you can make calls for your connected accounts.

idle charm
#

we have already implemented connect fucntionality
but now the requirement is a shopping cart , that can be a mixed cart
that means now need to support multiple products purchase in a single request

violet ravine
#

To clarify, are you trying to create a subscription or an one-time payment?

idle charm
#

currently our system support both , user can either purchase a one time plan or a subscription plan
but while implementing shopping cart we may have to support both in a single request

violet ravine
#

No Stripe doesn't have an API to create a subscription and an one-time payment simulatnesouly.

#

What you can do is to collect a payment method from your customer, and use that payment method to create a subscription and an off-session payment separately.

idle charm
#

is there any sample code or any doc link?

violet ravine
idle charm
#

so that means if we have both subscription and one time
save payment method, create subscription and use that payment method if there is one time , right?

violet ravine
#

yes you are right

idle charm
#

ok thanks,
then if i have 2 one time plans , just add and create payment intent for total amount , right

violet ravine
#

Sure, you can update the paymentIntent amount, or create a new paymentIntent. It's entirely up to you.

idle charm
#

ok , one more doubt

#

we have created a subscription using createsubscription api with coupon
now if use updrades to a higher plan , will the coupon remains there?

violet ravine
#
idle charm
violet ravine
idle charm
#

ok what is the solution

#

our code
$this->update_data["payment_behavior"] = "pending_if_incomplete";//"error_if_incomplete"";
$this->update_data["proration_behavior"] = 'always_invoice';
//$this->update_data["off_session"] = true;
//JS$this->update_data["plan"] = $this->new_plan->stripe_id;
$this->checkCouponPresent($stripe_subscription);
//JS
$this->update_data["items"] = [
[
'id' => $stripe_subscription->items->data[0]->id,
'plan' => $this->new_plan->stripe_id,
],
];

        $purchase = $request->has('purchase') ? $request->input('purchase') : false;
        /*if ($purchase){
            $this->update_data["trial_end"] = "now";
        }*/
        if (! $this->hasPreviousSubscriptions() && ! $purchase && $this->school->in_trial == 1){
            //$data['trial_period_days'] = $this->school->plan_trial_days;
            $this->can_give_trial = true;
            $data["expand"] =  ['pending_setup_intent'];
        }else{
            $this->update_data["expand"] =  ['latest_invoice.payment_intent'];
        }
        //$stripe_subscription->save();

        //Calculate prorata
        if ($disable_proration){
            $this->update_data["proration_behavior"] = 'none';
        }else{
            if (($subscription->plan_id != config('school.default_plan_id')) && ($subscription->plan_id != config('plan.beta_plan_id'))){
                $proration_date = $this->calculatePlanChangeProrata($subscription);
                //$stripe_subscription->proration_date = $proration_date;
                $this->update_data["proration_date"] = $proration_date;
                //$stripe_subscription->save();
            }
        }
#

$this->update_data['coupon'] not supporting

violet ravine
idle charm
#

ok

idle charm
#

so $this->update_data['discounts]['coupon'] will help, right?

violet ravine
#

No I don't see discounts in the list of supported attributes either