#josula_api

1 messages ยท Page 1 of 1 (latest)

calm jungleBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

wicked island
#

๐Ÿ‘‹ happy to help

rancid cloak
#

We are integrating Mondu right now and I want to confirm confirm a payment with mondu in my nextjs app. I updated all my stripe packages:

    "@stripe/react-stripe-js": "3.6.0",
    "@stripe/stripe-js": "7.0.0",
const form = document.getElementById('payment-form');

form.addEventListener('submit', async function(event) {
  event.preventDefault();

  // Set the clientSecret of the PaymentIntent
  const { error } = await stripe.confirmPayment({
    clientSecret: clientSecret,
    confirmParams: {
      payment_method_data: {
        type: 'mondu',
      },
      // Return URL where the customer should be redirected after the authorization
      return_url: 
wicked island
#

would you mind elaborating please

rancid cloak
#

I follow above code taken from the docs.

wicked island
#

did you activate Mondu on your account?

#

Mondu is a private preview feature

#

so if you don't have access to that feature you can't integrate

rancid cloak
#

Yes I have activated it! Even signed it with your CS to use it

But I get this type error and then run time error in my app:

No overload matches this call.
  The last overload gave the following error.
    Object literal may only specify known properties, and 'type' does not exist in type '{ billing_details?: BillingDetails | undefined; allow_redisplay?: "always" | "limited" | "unspecified" | undefined; }'.ts(2769)
payment-intents.d.ts(1532, 3): The expected type comes from property 'payment_method_data' which is declared here on type 'ConfirmPaymentData'

And then my stripe response:

No such PaymentMethod: 'mondu'
#

My inital thought was that the stripe package needs an update.

#

So either the docs are wrong / outdatet or my stripe version is too old or something else obv

wicked island
#

would you mind sharing your account ID please

rancid cloak
#

acct_1QolrzHqliFa6vlS

wicked island
#

actually I just noticed, you don't have to pass payment_method_data: { type: 'mondu', }, when you confirm

rancid cloak
#

No we use the bare metal api

#

so we create an invoice, then attach the payment method to the payment intent and confirm it,

#

so at the time the payment intent is created we have no clue what the customer will choose

wicked island
#

exactly why I advise you to follow the code snippet in that doc I sent

#

minus of course the intent creation call since you already have the PaymentIntent's client secret from the invoice

rancid cloak
#

Ok thank you sir!

#

will check!

#

But we do not use the "elements" object anywhere

wicked island
#

so you're not really using the PaymentElement?

rancid cloak
#
     <Elements stripe={stripePromise}>
          <StripePaymentButton
            customer={customer}
          />
        </Elements>

This is our elements wrapper,

then on the button:

function getStripeConfirmationMethod(
  stripe: Stripe,
  clientSecret: string,
  cart: HttpTypes.StoreCart,
  countryCode: string
): Promise<PaymentIntentResult> {
  switch (cart.metadata.payment?.type) {
    case "card":
      return stripe.confirmCardPayment(clientSecret)

    case "paypal":
      return stripe.confirmPayPalPayment(clientSecret, {
        return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/${countryCode}/order/status?cartId=${cart?.id}`,
      })

    case "sofort":
      return stripe.confirmSofortPayment(clientSecret, {
        return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/${countryCode}/order/status?cartId=${cart?.id}`,
      })
    case "sepa_debit":
      return stripe.confirmSepaDebitPayment(clientSecret, {
        return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/${countryCode}/order/status?cartId=${cart?.id}`,
      })

    case "invoice":
      return stripe.confirmPayment({
        clientSecret: clientSecret,
        confirmParams: {
          return_url: `${window.location.href}`,
        },
      })
#

PaymentElement => we use the bare metal stripe api as I said

#

the "invoice" case is the one i want to be handled by mondu

#

the last case basically

wicked island
#

so you're using your own UI to let your customer decide which payment method they'll use, right?

rancid cloak
#

Yes!

#

Right!

wicked island
#

in that case you can use confirmMonduPayment

rancid cloak
#
Property 'confirmMonduPayment' does not exist on type 'Stripe'. Did you mean 'confirmPayment'?ts(2551)
#
     return stripe.confirmMonduPayment({
        clientSecret: clientSecret,
        confirmParams: {
          return_url: `${window.location.href}`,
        },
      })

This is the code

wicked island
#

which stripe-js version are you using?

rancid cloak
#

"@stripe/react-stripe-js": "3.6.0",
"@stripe/stripe-js": "7.0.0",

wicked island
#

Property 'confirmMonduPayment' does not exist on type 'Stripe'. Did you mean 'confirmPayment'?ts(2551)
try to #ts-ignore this and run it

#

it should work

rancid cloak
#

ok great! Will try

wicked island
rancid cloak
#

Where do I get my beta flag from in stripe?

const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY!, {
betas: ["mondu_beta"],
})

#

mondu_beta is just a placeholder right now

calm jungleBOT
wicked island
#

I don't think it needs a beta

rancid cloak
#
IntegrationError: You cannot call `stripe.confirmMonduPayment` without supplying an appropriate beta flag when initializing Stripe.js.
#

I do need it

wicked island
#

hmmm

#

ok will check that

rancid cloak
#

๐Ÿ™

rancid cloak
#

ok interesting

#

hmm

wicked island
#

mondu_pm_beta_1

#

I will let the docs team know to fix this

rancid cloak
#

the tag works! but now I get this issue:

Invalid value for stripe.confirmMonduPayment intent secret: value should be a client_secret string. You specified: {"clientSecret":"<STRIPE CLIENT SECRET","confirmParams":{"return_url":"http://localhost:8000/de/order/status?cartId=abc"}}.

Its quite hard without types or docs to debug.

Any idea?

#
       stripe
          .confirmMonduPayment({
            clientSecret: clientSecret,
            confirmParams: {
              return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/${countryCode}/order/status?cartId=${cart?.id}`,
            },
          })

Am I missing anything?

distant meadow
#

Hi there ๐Ÿ‘‹ are you logging the contents of your clientSecret variable just before that error is thrown? Based on the error, it looks like that variable is holidng the string <STRIPE CLIENT SECRET instead of an actual client-secret from an intent.

rancid cloak
#

no its an actual secret

#

wasnt sure if i should post it here

#

its a long string

distant meadow
#

Kind of a gray area. Those secrets are, well, secrets. But if you're doing everything in testmode then there aren't any real risks of sharing it. Worst case scenario some confirms that testmode payment.

rancid cloak
#

"pi_3RByCIQWc5EeQut91qRfPebS_secret_O8tLQFfi7samq1PMdCQNQFu87"

#

thats the secret

#

it works with all other confirmPayment() calls we make (e.g. paypal or sofort)

distant meadow
#

Is it safe to assume the string value itself doesn't contain the double quotes you included?

rancid cloak
#

Invalid value for stripe.confirmMonduPayment intent secret: value should be a client_secret string. You specified: {"clientSecret":"pi_3RByCIQWc5EeQut91qRfPebS_secret_O8tLQFfi7samq1PMdCQNQFu87","confirmParams":{"return_url":"http://localhost:8000/de/order/status?cartId=cart_abc"}}.

distant meadow
#

Were you given a support contact when you were being granted access to this private preview feature? I'd suggest reaching out to them about the expected behavior of this type of payment method and to raise these issues to them.

We aren't super familiar with implementing features that aren't generally available in this forum.

rancid cloak
#

I figured it out

#

thanks!

#

Sorry one more question: Is there any description anywhere what the confirmMonduPaymentI() expects? I am guessing it here without types and docs

#

E.g. below throws an error:

 stripe
          .confirmMonduPayment(clientSecret, {
            return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/${countryCode}/order/status?cartId=${cart?.id}`,
            payment_method: {
              type: "mondu",
           
            },
          })

Error:

ERROR IN INVOICE IntegrationError: Missing value for confirmMonduPayment: payment_method.mondu should be an object or element.
distant meadow
#

Not that I'm seeing, but that's a good question for the support contact for this private preview feature if you were given a contact when being given access to this beta.

#

In the Mondu guide we seem to recommend confirmPayment rather than confirmMonduPayment. Were you given guidance to implement this differently than the guide shows?

I think you should raise all of this feedback to the beta contact so they can review their documentation and ensure it's accurate/complete.

rancid cloak
#

well look above what tarzan wrote...