#satvik-techie_code

1 messages ยท Page 1 of 1 (latest)

vapid timberBOT
#

๐Ÿ‘‹ 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/1290613632115277915

๐Ÿ“ 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.

acoustic coyote
#

in above code i am creating a monthly subscription, i want to collect first payment different than other 11 months payment is it possible ?

vapid timberBOT
terse notch
#

Hi, let me help you with this.

#

first payment different
How different? Do you want to charge a higher amount?

acoustic coyote
#

yes a little higher

#

e.g firstpayment would be 3.36 pound
and remaining 11 installment would be 3 pound

terse notch
acoustic coyote
#

ok let me check and get back to you

#

var invoiceItems = new List<SubscriptionAddInvoiceItemOptions>();
invoiceItems.Add(new SubscriptionAddInvoiceItemOptions()
{
Price = "3.36"
});

subscriptionOptions.AddInvoiceItems = invoiceItems;

#

like this ?

terse notch
acoustic coyote
#

ok let me modify

#

tried but getting error

#

Stripe.StripeException: 'The price specified is set to type=recurring but this field only accepts prices with type=one_time.'

terse notch
acoustic coyote
#

okay

#

i think the issue is with the price and product, as i have created prouduct and price as recurring, but add_invoice_items accept only one time payment params

#

any guess ?

opaque talon
#

Hey! Taking over for my colleague. Let me catch up.

acoustic coyote
#

okay

#

so did you get the issue scenario ?

#

there ?

opaque talon
#

Sorry, still checking...

#

The price specified is set to type=recurring but this field only accepts prices with type=one_time.
Here is the error message

#

In the add_invoice_items[0][price] you need to pass one time prices and not recurring.

acoustic coyote
#

i know that, but the main issue is i want to make first payment different amount and remaining 11 payments are with different amount

#

how come that is possbile with monthly subscription ?

#

thats why i have created price , product object as recurring

opaque talon
#

how come that is possbile with monthly subscription ?
You can achieve this using Susbcription Scheduler

acoustic coyote
#

okay let me check and implement

#

if any issue i will get back to you

#

so what is price_digital ?

opaque talon
#

It's a recurring price

acoustic coyote
#

one more question, how to get clientsecret ?

opaque talon
#

What Client Secret ?

acoustic coyote
#

to get the payment

#

i need to pass clientsecret

#

var elements = stripe.elements({
clientSecret: this.clientSecret,
});
const paymentElement = elements.create(
"payment",

      {
        layout: "accordion",
        defaultValues: {
          billingDetails: {
            email: this.email,
            address: {
              city: this.city,
              country: "GB",
              postal_code: this.postCode,
            },
          },
        },
      }
    );

    paymentElement.mount("#payment-element");
opaque talon
#

When you create a PaymentIntent, you have the client secret

acoustic coyote
#

no not that way, while creating a subscription i was getting clientsecret from
Subscription subscription = await subscriptionService.CreateAsync(subscriptionOptions, requestOptions);

vapid timberBOT
acoustic coyote
#

but using scheduling how to get clientsecret ?

opaque talon
#

You can retrieve it from the latest invoice of the Subscription

harsh kindle
#

hi! I'm taking over this thread. let me know if you have nother questions.

acoustic coyote
#

i want to collect first payment different than other 11 months payment is it possible ?

#

while creating a monthly subscription

harsh kindle
#

what do you mean by "different"? what are you trying to do exactly?

acoustic coyote
#

i am creating a montly payment subscription

#

now i want to take first payment as diffrent amount

#

and remaing 11 payment have different amount

#

e.g
1st payment = 3.36 pound
remaining 11 payment = 3.12 pound

harsh kindle
#

sure that's possible. how do you create the Subscription? With Checkout Session, the Subscription endpoint, something else?

acoustic coyote
#

ok let me share the code

#

attached is the code

harsh kindle
#

so you directly call the Subscription endpoint.
the simplest solution is to create a subscription with two prices:

  • a recurring price of 3.12 pounds
  • a one time price of 0.24 pounds
    this way, the first month will be 3.36 pounds, and the other months 3.12 pounds
acoustic coyote
#

so do i need to create 2 (price , product) with one time payment
and 2 (price , product) with recurring payment
and then adding both price in below code

var subscriptionOptions = new SubscriptionCreateOptions
{
    Customer = customer.Id,
    Items = new List<SubscriptionItemOptions>

{
new SubscriptionItemOptions
{
Price = price.Id,

},

},
PaymentSettings = paymentSettings,
PaymentBehavior = "default_incomplete",
}; ?

#

i mean in subscriptionitemoptions

harsh kindle
acoustic coyote
#

tried, but getting exception

#

'The price specified is set to type=one_time but this field only accepts prices with type=recurring.'

harsh kindle
#

did you read my above message? you need to use add_invoice_items for the one time price

acoustic coyote
#

okay let me check