#akashpatil7596_code

1 messages ยท Page 1 of 1 (latest)

viscid umbraBOT
#

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

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

chilly valley
#

hi there!

shut kindle
#

Hello

chilly valley
#

I don't understand your question. the subscription you shared has expired.

#

can you share more details on what you are trying to do, what you expected to happen, and what is the issue?

shut kindle
#

Wait

#

sub_1RWxPLAGlCdR56ap9JvuchuR

#

In web I directly go to the page but in mobile app I redirected to webpage in browser and then done payment.

shut kindle
chilly valley
#

what do you mean "happening"?

shut kindle
#

means the invoice stays opens, it should be paid

chilly valley
#

why? did you retrive the client_secret of the first invoice, load it in the Payment Element, enter the payment details, and confirm the PaymentIntent?

shut kindle
#

Yes I Think so

chilly valley
#

creating the Subscription is just the first step. then you need to collect a payment method to actually pay te invoice.

shut kindle
#

How can I do that?

I Catch the invoice.created webhook, in that can I finalize and pay the invoice manually?

chilly valley
#

do you have a payment method for the customer?

shut kindle
#

Yes

chilly valley
#

OK, so the customer has a default payment method saved, and you expect that when you create a subscription, the default payment method gets automatically used to pay for the subscription?

shut kindle
#

Yes

chilly valley
#

having a look

shut kindle
#

It works fine in web but in mobile it creates a problem

chilly valley
#

can you share an example subscription ID where it worked as expected?

shut kindle
#

sub_1RWv6iAGlCdR56apl4GJl1di

#

wait for 10 minutes, don't end this thread

chilly valley
#

I'm confused about your payment flow.
can you explain in details what are all the steps you do after you create the Subscription? and what you expected to happen?

shut kindle
#

Ok wait

#
if (subscription.payment_type === PaymentTypeEnum.ONETIME) {
      if (price > 0) {
        const temp = await this.stripeService.createPaymentIntent({
          customerId: stripeCustomerId,
          price: price,
          payment_method_id: paymentMethodId,
          metadata: {
            priceId: getProduct.default_price as string,
            productName: subscription.title,
            couponId: coupon ? coupon.id : null,
          },
        });

        subscriptionEntitiesAttribute = {
          end_date:
            subscription.duration_unit === DurationUnitEnum.LIFETIME
              ? null
              : add(new Date(), {
                  [subscription.duration_unit === DurationUnitEnum.MONTH ? 'months' : 'years']: subscription.duration,
                }),

          stripe_subscription_id: temp.id,
        };
        client_secret = temp?.client_secret;
      } else {
        subscriptionEntitiesAttribute = {
          end_date:
            subscription.duration_unit === DurationUnitEnum.LIFETIME
              ? null
              : add(new Date(), {
                  [subscription.duration_unit === DurationUnitEnum.MONTH ? 'months' : 'years']: subscription.duration,
                }),
          subscription_status: SubscriptionStatusEnum.ACTIVE,
        };
      }
    } else {
      const temp: any = await this.stripeService.createSubscription({
        customerId: stripeCustomerId,
        priceId: getProduct.default_price as string,
        coupon: coupon?.stripe_id,
      });

      const timeUnit = subscription.duration_unit === DurationUnitEnum.MONTH ? 'months' : 'years';

      subscriptionEntitiesAttribute = {
        end_date: add(new Date(), { [timeUnit]: subscription.duration }),
        stripe_subscription_id: temp.id,
      };
      client_secret = temp?.latest_invoice.payment_intent?.client_secret;
    }
#

Webhook:

try {
        if (data?.type === 'invoice.created') {
          const isSubscriptionExist = await this.subscriptionRepo.isSubscriptionExist(data, transaction);

          if (isSubscriptionExist) {
            const invoice = await this.stripeService.retrieveInvoice(data?.data?.object?.id);
            if (invoice?.status === 'draft') {
              await this.stripeService.finalizeInvoice(data?.data?.object?.id);
            }
          }
        } else if (data?.type === 'invoice.payment_succeeded') {
          await this.subscriptionRepo.recurringSubscriptionWebhookHandle(data, transaction);
        } else if (data?.type === 'payment_intent.succeeded') {
          const metadata = data.data.object.metadata;

          if (metadata) {
            if (metadata.type === 'giftCardPurchase') {
              await this.giftCardRepository.handleGiftCardPayment(data, transaction);
            } else if (metadata.type === 'Course') {
              await this.coursePurchaseRepo.handleCoursePayment(data, transaction);
            } else if (metadata.type === 'LiveAslAssessment') {
              await this.liveAssessmentRepository.setLiveAssessment(data, transaction);
            } else {
              await this.subscriptionRepo.oneTimeSubscriptionWebhookHandle(data, transaction);
            }
          }
        }
        await transaction.commit();
      } catch (error) {
        await transaction.rollback();
        logger.error('Error in stripeWebhookHandle' + JSON.stringify(error, undefined, 1));
      }
chilly valley
#

I don't need your code. can you explain with words what you do and what you expect to happen?

shut kindle
#

I simply created a subscription on that I want to invoice get paid, but sometimes it went to open and I don't get confirmation on payment is successeded or not

#

like this one : sub_1RWxsmAGlCdR56apltoUSFwF

#

or maybe on buy the subscription I'm not getting the confirm API called from stripe side

viscid umbraBOT
sinful mist
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

shut kindle
#

ok

#

Hello

#

I think I got the issue

sinful mist
#

yes sorry for taking too long

sinful mist
shut kindle
#

In mobile on pay now I called my API to create the subscription but don't get the confirm API of stripe,
in web I get the confirm API, what is the confirm API?

I send you some images to look into

#

Did you get something?

sinful mist
#

sorry I'm still looking

#

for the mobile is it an app with a webview or are you testing it on a mobile browser?

shut kindle
sinful mist
#

you should use PaymentSheet in mobile apps

shut kindle
#

Meaning?

#

Actually it is not available for flutter at the moment

sinful mist
#

then you should use Checkout Sessions instead

#

we really don't recommend using stripe-js within an app webview

#

it doesn't work as expected

shut kindle
#

yes but right now this is the thing I have to work with, isn't that possible?

shut kindle
sinful mist
#

i mean you could open the checkout session outside of your app in the browser

shut kindle
#

can you just tell me what is this confirm API? how can i get it in app webview?

#

right now I have been told to do it like this, that's why

sinful mist
#

right now I have been told to do it like this, that's why
by whom?

shut kindle
#

by my seniors

#

or is it the wrong method?

sinful mist
#

and you should tell your seniors what I just told you above

we really don't recommend using stripe-js within an app webview
it doesn't work as expected

#

you can't use the same code for web and mobile unfortunately

shut kindle
#

Okay, this will take care of payment in-app, right?

sinful mist
#

yes

shut kindle
#

Hey

#

I reasearch about it, the play store and app store won't allow the methods other than in-app purchase.

#

@sinful mist

#

If we use any built-in payment integration methods other than in-app purchase than there is a chance that our app may not get verified.

sinful mist
#

for subscriptions you mean?

shut kindle
#

I'm talking about in-general payment

sinful mist
#

for digital goods, it's only available on iOS

#

so you can link out to either a Checkout Session or to a Custom form using PaymentElement

#

for Android you need to use the native in-app purchases using Play Store

shut kindle
#

I need to do for both android and IOS I'm using flutter.

sinful mist
#

if it's for digital goods then yes

viscid umbraBOT
shut kindle
acoustic adder
#

Sounds like a question for Google, not us

#

(we're not super familair with their in-app purchasing requirements)

shut kindle
#

Hmmm

#

But Will applying checkout session will be good?

#

I mean will it work fine?

acoustic adder
#

It'll 'work' yes if you're redirecting users out of your app to a browser. Whether or not Google allow that is unclear

#

Apple do now due to a recent court ruling