#nunu0951_docs
1 messages ¡ Page 1 of 1 (latest)
đ 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.
Hi there, is it about creating subscriptions on connected accounts?
Are you using Checkout Sessions API or Subscirptions API to create subscriptions?
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)
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)
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
To clarify, are you trying to create a subscription or an one-time payment?
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
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.
is there any sample code or any doc link?
https://docs.stripe.com/api/subscriptions/create#create_subscription-default_payment_method this is how you specify a payemnt method when creating a subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=stripe-hosted#charge-saved-payment-method this is how you create an off-session charge with a saved payment method
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?
yes you are right
ok thanks,
then if i have 2 one time plans , just add and create payment intent for total amount , right
Sure, you can update the paymentIntent amount, or create a new paymentIntent. It's entirely up to you.
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?
It depends on whether the coupon is still valid for the customers, which can be determined by the following https://docs.stripe.com/api/coupons/object#coupon_object-duration https://docs.stripe.com/api/coupons/object#coupon_object-redeem_by
https://docs.stripe.com/api/coupons/object#coupon_object-max_redemptions
https://docs.stripe.com/api/coupons/object#coupon_object-valid
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok , now one more question
if at the time of subscription creation, coupon is NOT present, but when upgrades we need to provide coupon
we get this error on upgrade
When payment_behavior is set to pending_if_incomplete, you can only pass supported params. coupon is not supported. See https://stripe.com/docs/billing/subscriptions/pending-updates-reference#supported-attributes for more details.
Yes, this is expected. Did you get a chance to read https://docs.stripe.com/billing/subscriptions/pending-updates-reference#supported-attributes ?
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
I'd recommend you read https://docs.stripe.com/billing/subscriptions/pending-updates-reference#supported-attributes and use the supported params.
ok
so $this->update_data['discounts]['coupon'] will help, right?
No I don't see discounts in the list of supported attributes either