richnologies / ngx-stripe

Angular 6+ wrapper for StripeJS
MIT License
217 stars 77 forks source link

Some questions around subscriptions #261

Closed ecancil closed 1 month ago

ecancil commented 1 month ago

Hello, thanks for your awesome library.

I have some questions around subscriptions.

On the backend I am creating a subscription and returning the client secret from the subscription intent like so

const subscription = await stripe.subscriptions.create({
            customer: customer.id,
            items: [{ price: priceId }],
            payment_behavior: 'default_incomplete',
            payment_settings: {
                payment_method_types: ['card']
            },
            payment_settings: {
                save_default_payment_method: 'on_subscription'
            },
            expand: ['latest_invoice.payment_intent']
        });

        await userRef.update({
            subscriptionId: subscription.id
        });

        res.json({ clientSecret: subscription.latest_invoice.payment_intent.client_secret });        

On the frontend (angular) I am using the payment element like so

@if(!elementsOptions.clientSecret){
  <mat-progress-bar mode="indeterminate"></mat-progress-bar>
  } @else{
  <ngx-stripe-elements [stripe]="stripe" [elementsOptions]="elementsOptions">
    <ngx-stripe-payment [options]="paymentElementOptions"></ngx-stripe-payment>
  </ngx-stripe-elements>
  }

This is where I get tripped up, the payment methods that show after i set the client secret does not respect the types that are set in the subscription, or the types that are set in my dashboard. It always defaults to card, cashapp, and bank transfer

Any suggestions / help would be welcome.

Thanks!

ecancil commented 1 month ago

Doh, it was me having payment_settings twice in the subscription. again thank you for the amazing library!

ecancil commented 1 month ago

Closing